Basically putting all the translation stuff together before I refactor things to use it.

This commit is contained in:
2025-05-25 12:53:34 -05:00
parent 1e2d971643
commit f5cb84e0c9
31 changed files with 254 additions and 327 deletions

View File

@@ -1,6 +1,6 @@
class_name Recipe extends Node
@export var recipe_text:String = ""
@export var title:String = ""
@export var ingredients:Array[ItemResource] = []
@export var outputs:Array[ItemResource] = []

View File

@@ -18,9 +18,9 @@ func start() -> void:
var text:String = "";
match getType:
GetType.FOUND:
text = "Found " + str(quantity) + " " + Item.getItemName(itemType, quantity) + ".";
text = "Found " + str(quantity) + " " + ITEM.getItemName(itemType, quantity) + ".";
GetType.GIVEN:
text = "Received " + str(quantity) + " " + Item.getItemName(itemType, quantity) + ".";
text = "Received " + str(quantity) + " " + ITEM.getItemName(itemType, quantity) + ".";
_:
pass
VN.getTextbox().setText(text);

View File

@@ -1,13 +0,0 @@
class_name Onion extends "res://scripts/Item/Item.gd"
func getName() -> String:
return "Onion"
func getCategory() -> ItemCategory:
return ItemCategory.MEDICINE;
func isConsumable() -> bool:
return true;
func consume() -> void:
print("Consuming Potion");

View File

@@ -1 +0,0 @@
uid://bmfaw3kid1pqx

View File

@@ -7,7 +7,7 @@ enum ItemSortType {
class ItemStackNameComparator:
static func _sort(a, b):
return Item.getItemName(a).to_lower() < Item.getItemName(b).to_lower()
return ITEM.getItemName(a).to_lower() < ITEM.getItemName(b).to_lower()
class ItemStackTypeComparator:
static func _sort(a, b):
@@ -22,7 +22,7 @@ func isPlayerInventory() -> bool:
return self == ITEM.PLAYER_INVENTORY
func addItem(type:Item.Type, quantity: int = 1) -> void:
if !Item.isStackable(type):
if !ITEM.isStackable(type):
# Item cannot be stacked, add each item to inv
for i in range(quantity):
contents.append(ItemStack.new(type, 1))

View File

@@ -1,4 +1,4 @@
class_name Item
class_name Item extends Node
enum Type {
# Items
@@ -9,7 +9,7 @@ enum Type {
SWEET_POTATO = 3,
# Recipe outputs
ASH_BAKED_SWEET_POTATO = 4,
BAKED_SWEET_POTATO = 4,
};
enum Category {
@@ -19,70 +19,8 @@ enum Category {
FOOD
};
static func isStackable(itemType:Type) -> bool:
match itemType:
_:
return true
static func getItemName(itemType:Type, count:int = 1) -> String:
match itemType:
Type.POTION:
if count != 1:
return "Potions"
return "Potion"
Type.ONION:
if count != 1:
return "Onions"
return "Onion"
Type.SWEET_POTATO:
if count != 1:
return "Sweet Potatoes"
return "Sweet Potato"
Type.ASH_BAKED_SWEET_POTATO:
if count != 1:
return "Ash-Baked Sweet Potatoes"
return "Ash-Baked Sweet Potato"
_:
assert(false, "Invalid item type")
return ""
static func getItemDescription(itemType:Type) -> String:
match itemType:
Type.POTION:
return "A potent healing drink, infused with magical properties. Restores health and stamina."
Type.ONION:
return "A common vegetable, known for its strong flavor and aroma. Can be used in cooking."
Type.SWEET_POTATO:
return "A nutritious root vegetable, sweet and starchy. Can be used in cooking."
Type.ASH_BAKED_SWEET_POTATO:
return "Tender, warm, and sweet meal, made by baking a sweet potato in campfire embers. Comforting, simple, and gently filling."
_:
assert(false, "Invalid item type")
return ""
static func getItemCategory(itemType:Type) -> Category:
match itemType:
Type.POTION:
return Category.MEDICINE
Type.ONION:
return Category.INGREDIENT
Type.SWEET_POTATO:
return Category.INGREDIENT
Type.ASH_BAKED_SWEET_POTATO:
return Category.FOOD
_:
assert(false, "Invalid item type")
return Category.KEY_ITEM
@export var title:String = ""
@export var description_text:String = ""
@export var type:Type = Type.POTION
@export var category:Category = Category.INGREDIENT
@export var stackable:bool = true

View File

@@ -1,13 +0,0 @@
class_name Potion extends "res://scripts/Item/Item.gd"
func getName() -> String:
return "Potion"
func getCategory() -> ItemCategory:
return ItemCategory.MEDICINE;
func isConsumable() -> bool:
return true;
func consume() -> void:
print("Consuming Potion");

View File

@@ -0,0 +1 @@
class_name ItemOnion extends "res://scripts/Item/Item.gd"

View File

@@ -0,0 +1 @@
uid://dipe47ljyvycv

View File

@@ -0,0 +1 @@
class_name ItemPotion extends Item

View File

@@ -0,0 +1 @@
uid://b6v2o563casay

View File

@@ -1,6 +1,6 @@
class_name Quest extends Node
@export var questName:String = "Some quest"
@export var title:String = ""
@export var questKey:QuestSystem.QuestKey = QuestSystem.QuestKey.TEST_QUEST
var questStarted:bool = false

View File

@@ -4,7 +4,7 @@ enum Type {
Item,
}
@export var objectiveName:String = "Some objective"
@export var title:String = ""
@export var objectiveType:Type = Type.Item
@export var itemType:Item.Type = Item.Type.POTION

View File

@@ -0,0 +1,6 @@
class_name MainMenuScene extends Node
func _enter_tree() -> void:
$Control/Label.text = tr("main_menu.label").format({
inputIcon = "[img=32x32]res://icon.svg[/img]"
})

View File

@@ -1,9 +1,57 @@
extends Node
class_name ItemSystem extends Node
const Inventory = preload("res://scripts/Item/Inventory.gd")
# # Item Constants
# static var POTION = preload("res://scripts/Item/Potion.gd").new();
# static var ONION = preload("res://scripts/Item/Ingredient/Onion.gd").new();
# Static inventories
static var PLAYER_INVENTORY = Inventory.new();
static var ITEM_MAP:Dictionary[Item.Type,Item]
func _addItemRecursively(node:Node) -> void:
if node is Item:
if ITEM_MAP.has(node.type):
assert(false, "Duplicate item type found: " + str(node.type))
ITEM_MAP[node.type] = node
for childIndex in node.get_child_count():
_addItemRecursively(node.get_child(childIndex))
func _enter_tree() -> void:
# Add all items
ITEM_MAP = {}
_addItemRecursively(self)
# Check if we are missing any item types.
for itemType in Item.Type.values():
if !ITEM_MAP.has(itemType):
assert(false, "Missing item type: " + Item.Type.find_key(itemType))
static func isStackable(itemType:Item.Type) -> bool:
if not ITEM_MAP.has(itemType):
return false
var item:Item = ITEM_MAP[itemType]
return item.stackable
static func getItemName(itemType:Item.Type, count:int = 1) -> String:
if not ITEM_MAP.has(itemType):
return ""
var item:Item = ITEM_MAP[itemType]
if count > 1:
return str(count) + "x " + item.title
else:
return item.title
static func getItemDescription(itemType:Item.Type) -> String:
if not ITEM_MAP.has(itemType):
return ""
var item:Item = ITEM_MAP[itemType]
return item.description_text
static func getItemCategory(itemType:Item.Type) -> Item.Category:
if not ITEM_MAP.has(itemType):
return Item.Category.INGREDIENT
var item:Item = ITEM_MAP[itemType]
return item.category

View File

@@ -36,7 +36,7 @@ var region:Region = -1
signal localeChanged
func _init() -> void:
var preferred = OS.get_locale_language()
var preferred = OS.get_locale()
self.setLocaleFromLocaleString(preferred)
func setLocaleFromLocaleString(localeString:String) -> void:
@@ -77,7 +77,6 @@ func setLocaleFromLocaleString(localeString:String) -> void:
self.setLocale(lang, reg)
func setLocale(language:Language, region:Region) -> void:
print("Setting locale to: " + str(language) + "_" + str(region))
if self.language == language and self.region == region:
return

View File

@@ -1 +1,11 @@
class_name RecipeSystem extends Node
enum Type {
ASH_BAKED_SWEET_POTATO,
}
func _init() -> void:
pass

View File

@@ -1,5 +1,5 @@
class_name ItemLine extends HBoxContainer
func setStack(stack:ItemStack) -> void:
$ItemName.text = Item.getItemName(stack.type, 1)
$ItemName.text = ITEM.getItemName(stack.type, 1)
$ItemQuantity.text = str(stack.quantity)

View File

@@ -9,7 +9,6 @@ class_name QuestMenu extends Panel
var currentQuestKey
var currentQuestObjective
func _ready() -> void:
hide()
@@ -43,11 +42,11 @@ func setQuest(questKey = null):
var quest = QUEST.quests[questKey];
questList.select(questKey)
questName.text = quest.questName
questName.text = quest.title
questObjectiveList.clear()
questObjectiveList.deselect_all()
for objective in quest.objectives:
questObjectiveList.add_item(objective.objectiveName)
questObjectiveList.add_item(objective.title)
func setQuestObjective(objective = null):
@@ -63,7 +62,7 @@ func setQuestObjective(objective = null):
var questObjective = quest.objectives[objective]
questObjectiveList.select(objective)
questObjectiveInfo.text = questObjective.objectiveName + "\n"
questObjectiveInfo.text = questObjective.title + "\n"
func open(questKey = null) -> void:
@@ -85,7 +84,7 @@ func _updateQuestList():
questList.deselect_all()
for questKey in QUEST.quests:
var q = QUEST.quests[questKey]
var n = q.questName;
var n = q.title;
if q.isCompleted():
n += " (Complete)"
elif q.isStarted():