Refactor code structure for improved readability and maintainability

This commit is contained in:
Kirill
2026-04-05 23:26:43 +03:00
parent 81fe51ff4e
commit 094726a793
8 changed files with 1246 additions and 1140 deletions
+17
View File
@@ -23,17 +23,34 @@ var Locales: Dictionary = {}
var Locale = "en"
var Entities: Dictionary = {}
var Templates: Dictionary = {}
func get_localized_item_description(entity_id: String, item: String) -> String:
if Locales[Locale].has(entity_id):
return Locales[Locale][entity_id][item]
return ""
func get_description(item_id: String, values: Array = []) -> String:
if !Templates[Locale].has(item_id):
return ""
#print(Templates[Locale])
var description: String = Templates[Locale][item_id]["text"]
var value = 0
for item in values:
description.replace("value"+str(value), str(item))
return description
func _ready() -> void:
Entities = _read_from_csv("res://Autoload/entities.csv")
Locales["en"] = _read_from_csv("res://Autoload/locale.en.csv")
Locales["ru"] = _read_from_csv("res://Autoload/locale.ru.csv")
Templates["en"] = _read_from_csv("res://Autoload/templates.en.csv")
func _read_from_csv(file_path: String) -> Dictionary:
if not FileAccess.file_exists(file_path):