Crafting tabs (tools, weapons, cooking, building...); panel fits at 1280x720; steadier smoothness test

This commit is contained in:
Paul Bailey
2026-11-04 22:01:54 +00:00
parent a211fe4c63
commit 47fc116839
4 changed files with 117 additions and 6 deletions

View File

@@ -52,8 +52,29 @@ func define_recipe(r: Dictionary) -> void:
return
r.count = int(r.get("count", 1))
r.station = String(r.get("station", ""))
r.category = String(r.get("category", guess_category(items[r.output])))
if not CATEGORIES.has(r.category):
r.category = "other"
recipes[r.id] = r
## The crafting screen's tabs, in order: id -> label.
const CATEGORIES := {"tools": "Tools", "weapons": "Weapons", "cooking": "Cooking", "building": "Building",
"stations": "Stations", "furniture": "Furniture", "clothing": "Clothing", "other": "Other"}
## For recipes (an addon's, say) that don't say: worked out from what they make.
static func guess_category(item: Dictionary) -> String:
if item.has("food"):
return "cooking"
if item.has("weapon") or item.has("bow"):
return "weapons"
if item.has("tool") or item.has("fishing") or item.has("light"):
return "tools"
if item.has("wear"):
return "clothing"
if item.has("place"):
return "building" if item.place.has("kind") else "furniture"
return "other"
func _load_fishing(path: String) -> void:
var data = JSON.parse_string(FileAccess.get_file_as_string(path))
if typeof(data) != TYPE_DICTIONARY or not data.has("waters"):