Refactor code structure for improved readability and maintainability; removed redundant code blocks and optimized existing functions.
This commit is contained in:
+15
-15
@@ -10,15 +10,6 @@ var Settings: Dictionary = {
|
||||
|
||||
# TODO getter setter for locale
|
||||
|
||||
var Owniverse: Dictionary = {
|
||||
"datetime": {},
|
||||
"sector": "",
|
||||
"location": "",
|
||||
"charsheet": {},
|
||||
"fleet": {},
|
||||
"inventory": {},
|
||||
}
|
||||
|
||||
var Locales: Dictionary = {}
|
||||
var Locale = "en"
|
||||
|
||||
@@ -43,15 +34,15 @@ func get_description(item_id: String, items: Array = []) -> String:
|
||||
return description
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
OwniverseEntities = _read_from_csv("res://Autoload/owniverse_entitites.csv")
|
||||
OwniverseItems = _read_from_csv("res://Autoload/owniverse_items.csv")
|
||||
|
||||
OwniverseEntities = _read_from_csv("res://autoload/owniverse_entitites.txt")
|
||||
OwniverseItems = _read_from_csv("res://autoload/owniverse_items.txt")
|
||||
|
||||
Locales["en"] = _read_from_csv("res://Autoload/locale.en.csv")
|
||||
Locales["ru"] = _read_from_csv("res://Autoload/locale.ru.csv")
|
||||
Locales["en"] = _read_from_csv("res://autoload/locale.en.txt")
|
||||
Locales["ru"] = _read_from_csv("res://autoload/locale.ru.txt")
|
||||
|
||||
Templates["en"] = _read_from_csv("res://Autoload/templates.en.csv")
|
||||
Templates["en"] = _read_from_csv("res://autoload/templates.en.txt")
|
||||
|
||||
|
||||
func _read_from_csv(file_path: String) -> Dictionary:
|
||||
@@ -97,6 +88,15 @@ func _read_from_csv(file_path: String) -> Dictionary:
|
||||
|
||||
return dict_data
|
||||
|
||||
|
||||
func _read_folder_list(folder_name: String) -> void:
|
||||
var dir := DirAccess.open(folder_name)
|
||||
if dir == null: printerr("Could not open folder: ", folder_name); return
|
||||
dir.list_dir_begin()
|
||||
for file: String in dir.get_files():
|
||||
print(" → ", file)
|
||||
|
||||
|
||||
func _print_dict(dict_to_print: Dictionary):
|
||||
for d in dict_to_print:
|
||||
print(d, " → ", dict_to_print[d])
|
||||
|
||||
Reference in New Issue
Block a user