2026-03-05 20:13:45 +03:00
|
|
|
extends Node
|
|
|
|
|
|
2026-03-30 00:48:20 +03:00
|
|
|
const SPEED_LIMIT = 4
|
|
|
|
|
|
2026-03-05 20:13:45 +03:00
|
|
|
var Settings: Dictionary = {
|
|
|
|
|
"filename": "save-0001",
|
|
|
|
|
"sound_volume": 1.0,
|
|
|
|
|
"language": "en",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# TODO getter setter for locale
|
|
|
|
|
|
|
|
|
|
var Owniverse: Dictionary = {
|
|
|
|
|
"datetime": {},
|
|
|
|
|
"sector": "",
|
|
|
|
|
"location": "",
|
|
|
|
|
"charsheet": {},
|
|
|
|
|
"fleet": {},
|
|
|
|
|
"inventory": {},
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 00:48:20 +03:00
|
|
|
var Locales: Dictionary = {}
|
|
|
|
|
var Locale = "en"
|
|
|
|
|
|
2026-04-05 20:15:07 +03:00
|
|
|
var Entities: Dictionary = {}
|
2026-03-30 00:48:20 +03:00
|
|
|
|
|
|
|
|
func get_localized_item_description(entity_id: String, item: String) -> String:
|
|
|
|
|
if Locales[Locale].has(entity_id):
|
|
|
|
|
return Locales[Locale][entity_id][item]
|
|
|
|
|
return ""
|
|
|
|
|
|
2026-03-05 20:13:45 +03:00
|
|
|
func _ready() -> void:
|
|
|
|
|
Entities = _read_from_csv("res://Autoload/entities.csv")
|
2026-03-30 00:48:20 +03:00
|
|
|
|
|
|
|
|
Locales["en"] = _read_from_csv("res://Autoload/locale.en.csv")
|
|
|
|
|
Locales["ru"] = _read_from_csv("res://Autoload/locale.ru.csv")
|
2026-03-05 20:13:45 +03:00
|
|
|
|
|
|
|
|
func _read_from_csv(file_path: String) -> Dictionary:
|
|
|
|
|
if not FileAccess.file_exists(file_path):
|
|
|
|
|
printerr("File not found: " + file_path)
|
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
var file = FileAccess.open(file_path, FileAccess.READ)
|
|
|
|
|
if file == null:
|
|
|
|
|
printerr("File can not be opened:" + file_path)
|
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
var headers: PackedStringArray = []
|
|
|
|
|
var data: Array = []
|
|
|
|
|
|
|
|
|
|
if not file.eof_reached():
|
|
|
|
|
headers = PackedStringArray()
|
|
|
|
|
for val in file.get_csv_line("|"):
|
|
|
|
|
headers.append(val.strip_edges())
|
|
|
|
|
|
|
|
|
|
while not file.eof_reached():
|
|
|
|
|
var raw_row = file.get_csv_line("|")
|
|
|
|
|
if raw_row.is_empty(): # пропускаем пустые строки
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
var trimmed_row: PackedStringArray = []
|
|
|
|
|
for val in raw_row:
|
|
|
|
|
trimmed_row.append(val.strip_edges())
|
|
|
|
|
|
|
|
|
|
data.append(trimmed_row)
|
|
|
|
|
|
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
|
|
var dict_data: Dictionary = {}
|
|
|
|
|
for row in data:
|
|
|
|
|
if row.size() < 2: continue
|
|
|
|
|
|
|
|
|
|
if row.size() == headers.size():
|
|
|
|
|
var dict: Dictionary = {}
|
|
|
|
|
for i in headers.size():
|
|
|
|
|
dict[headers[i]] = row[i]
|
|
|
|
|
dict_data[row[0]] = dict
|
|
|
|
|
|
|
|
|
|
return dict_data
|
|
|
|
|
|
|
|
|
|
func _print_dict(dict_to_print: Dictionary):
|
|
|
|
|
for d in dict_to_print:
|
|
|
|
|
print(d, " → ", dict_to_print[d])
|