Add new entity and item definitions, refactor related code

- Introduced new CSV files for entities and items, defining various properties and characteristics.
- Refactored the stage.gd script to handle item selection and descriptions instead of entities.
- Updated item button script to reflect changes in item properties and signals.
- Created a new entity.gd script to define the OwniverseEntity class with initialization and parsing methods.
- Modified owniverse.gd to initialize entities from the new definitions.
- Adjusted versioning in export presets and project files to reflect recent changes.
This commit is contained in:
Kirill
2026-04-08 00:23:22 +03:00
parent 41977692a5
commit fc86261a9d
11 changed files with 357 additions and 193 deletions
+39 -37
View File
@@ -26,7 +26,7 @@ const SWIPE_DELAY = 2000 # msec
$StageRows/PageScroller/HBoxContainer/LifePage/Planets/Civ4
]
@onready var g_entity_descriptions: Array = [
@onready var g_item_descriptions: Array = [
$StageRows/PageScroller/HBoxContainer/ForcePage/Description,
$StageRows/PageScroller/HBoxContainer/ResourcePage/Description,
$StageRows/PageScroller/HBoxContainer/StarPage/Description,
@@ -65,7 +65,7 @@ var g_counters: Dictionary[String, Counter] = {
"swipe": Counter.new(),
}
var ActiveEntities: Dictionary = {}
var ActiveItems: Dictionary = {}
var owniverse = Owniverse.new()
@@ -77,65 +77,66 @@ func _on_indicator_pressed(indicator_name: String, page: int = 0):
_set_description(indicator_name, page)
func entity_activated(entity: OwniverseEntity) -> void:
_control_page(entity)
_set_entity_description(entity)
func item_selected(item: OwniverseItem) -> void:
_control_page(item)
_set_item_description(item)
func _set_entity_description(entity: OwniverseEntity) -> void:
func _set_item_description(item: OwniverseItem) -> void:
var description: String = "[b]" \
+ Global.get_localized_item_description(entity.entity_name, "label") \
+ Global.get_localized_item_description(item.item_name, "label") \
+"[/b]" \
+"\n" \
+ Global.get_localized_item_description(entity.entity_name, "description")
var desc_page = clamp(entity.entity_page, 0, 4)
g_entity_descriptions[desc_page].text = description
+ Global.get_localized_item_description(item.item_name, "description")
var desc_page = clamp(item.item_page, 0, 4)
g_item_descriptions[desc_page].text = description
func _set_description(item_name: String, page: int) -> void:
var description = Global.get_description(item_name + ".Name")
description += "\n"
description += Global.get_description(item_name + ".Description")
g_entity_descriptions[page].text = description
g_item_descriptions[page].text = description
func _control_page(entity: OwniverseEntity) -> void:
if !ActiveEntities.has(entity.entity_page):
ActiveEntities[entity.entity_page] = null
func _control_page(item: OwniverseItem) -> void:
if !ActiveItems.has(item.item_page):
ActiveItems[item.item_page] = null
var current_entity: OwniverseEntity = ActiveEntities[entity.entity_page]
if current_entity == entity:
var current_item: OwniverseItem = ActiveItems[item.item_page]
if current_item == item:
return
ActiveEntities[entity.entity_page] = entity
ActiveItems[item.item_page] = item
if current_entity != null and current_entity.entity_page == entity.entity_page:
current_entity.set_selection(false)
if current_item != null and current_item.item_page == item.item_page:
current_item.set_selection(false)
entity.set_selection(true)
item.set_selection(true)
# subpages
if entity.sub_page != -1:
item_pages[entity.sub_page].visible = true
if item.item_sub_page != -1:
item_pages[item.item_sub_page].visible = true
if current_entity == null \
or current_entity.sub_page == -1 \
or current_entity.sub_page == entity.sub_page:
if current_item == null \
or current_item.item_sub_page == -1 \
or current_item.item_sub_page == item.item_sub_page:
return
item_pages[current_entity.sub_page].visible = false
item_pages[current_item.item_sub_page].visible = false
func _init_entities() -> bool:
for e_id in Global.Entities:
var entity_properties: Dictionary = Global.Entities[e_id]
var entity: OwniverseEntity = ITEM_BUTTON.instantiate()
if !entity_properties.has("page"):
printerr("Entity `", e_id, "` has no `page` key.")
func _init_items() -> bool:
for item_id in Global.OwniverseItems:
var item_props: Dictionary = Global.OwniverseItems[item_id]
var item: OwniverseItem = ITEM_BUTTON.instantiate()
if !item_props.has("page"):
printerr("Item `", item_id, "` has no `page` key.")
return false
var page: int = int(entity_properties.page)
item_pages[page].add_child(entity)
entity.init_button(entity_properties)
entity.entity_activated.connect(entity_activated)
var page: int = int(item_props.page)
item_pages[page].add_child(item)
item.init_button(item_props)
item.item_activated.connect(item_selected)
return false
@@ -196,7 +197,8 @@ func _input(event: InputEvent) -> void:
func _ready() -> void:
_init_entities()
owniverse.init_enitities()
_init_items()
func _process(delta: float) -> void: