Refactor formatting functions and improve item production logic; update UI components for better layout and usability

This commit is contained in:
Kirill
2026-06-21 17:27:31 +03:00
parent 934d890887
commit 2d2979a1cf
10 changed files with 115 additions and 61 deletions
+17 -15
View File
@@ -23,10 +23,7 @@ func cycle(delta: float) -> void:
_check_locked_items()
func produce(item_id: String, amount: int) -> void:
print("prdcng ", item_id, " ", amount)
#if item_id == "S" or item_id == 'H':
#entities[item_id].amount += 1
func produce(item_id: String, amount: float) -> void:
var entity: OwniverseEntity = entities[item_id]
var entity_transaction = {}
@@ -38,10 +35,9 @@ func produce(item_id: String, amount: int) -> void:
entity_transaction[elem] = -amount * entity.cost[elem]
print("→: ", entity_transaction)
for elem in entity_transaction:
_process_enitity(elem, amount)
_process_enitity(entity, amount)
_process_enitity(elem, entity_transaction[elem])
_process_enitity(item_id, amount)
func automated_production(_delta: float) -> void:
@@ -51,24 +47,30 @@ func automated_production(_delta: float) -> void:
func get_available_to_produce(item_id: String) -> float:
#print(item_id)
return 1_000
var entity: OwniverseEntity = entities[item_id]
if entity.cost == {}: return 0
var amount: float = 1E50
for elem in entity.cost:
amount = min(floorf(current_amount[elem] / entity.cost[elem]), amount)
#print(elem, amount)
return amount
# add to all lists
func _process_enitity(entity: OwniverseEntity, amount: int) -> void:
func _process_enitity(entity_id: String, amount: float) -> void:
if amount == 0: return
_count_amount(entity, amount)
items_to_update[entity.id] = current_amount[entity.id]
_count_amount(entity_id, amount)
items_to_update[entity_id] = current_amount[entity_id]
func _count_amount(entity: OwniverseEntity, amount: int) -> void:
current_amount[entity.id] += amount
func _count_amount(entity_id: String, amount: float) -> void:
current_amount[entity_id] += amount
var entity: OwniverseEntity = entities[entity_id]
if entity.group_as != "":
current_amount[entity.group_as] += amount
if amount <= 0: return
cumulative_amount[entity.id] += amount
cumulative_amount[entity_id] += amount
if entity.group_as != "":
cumulative_amount[entity.group_as] += amount
+32
View File
@@ -43,6 +43,8 @@
[ext_resource type="Texture2D" uid="uid://4tpbmpe6tbk0" path="res://ui/indicators/trends/trend_bar5.png" id="40_50rdj"]
[ext_resource type="Texture2D" uid="uid://cnf3ml5gj2cvl" path="res://ui/indicators/trends/trend_icon_5.png" id="41_mi6gc"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ifjjt"]
[sub_resource type="GDScript" id="GDScript_behgl"]
script/source = "extends Node
@@ -248,6 +250,14 @@ custom_minimum_size = Vector2(1080, 1024)
layout_mode = 2
mouse_filter = 1
[node name="ActionBorder" parent="Stage/StageRows/PageScroller/HBoxContainer/ForcePage" unique_id=101392860 instance=ExtResource("12_58wjt")]
layout_mode = 2
[node name="Panel" type="PanelContainer" parent="Stage/StageRows/PageScroller/HBoxContainer/ForcePage" unique_id=609868831]
custom_minimum_size = Vector2(0, 216)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_ifjjt")
[node name="ResourcePage" type="VBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer" unique_id=1417647206]
layout_mode = 2
@@ -391,6 +401,14 @@ layout_mode = 2
size_flags_horizontal = 3
context_menu_enabled = true
[node name="ActionBorder" parent="Stage/StageRows/PageScroller/HBoxContainer/ResourcePage" unique_id=1789647912 instance=ExtResource("12_58wjt")]
layout_mode = 2
[node name="Panel" type="PanelContainer" parent="Stage/StageRows/PageScroller/HBoxContainer/ResourcePage" unique_id=1336208519]
custom_minimum_size = Vector2(0, 216)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_ifjjt")
[node name="StarPage" type="VBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer" unique_id=270059674]
layout_mode = 2
@@ -501,6 +519,9 @@ layout_mode = 2
custom_minimum_size = Vector2(1080, 1024)
layout_mode = 2
[node name="ActionBorder" parent="Stage/StageRows/PageScroller/HBoxContainer/StarPage" unique_id=136439467 instance=ExtResource("12_58wjt")]
layout_mode = 2
[node name="Actions" parent="Stage/StageRows/PageScroller/HBoxContainer/StarPage" unique_id=503388208 instance=ExtResource("17_ifjjt")]
layout_mode = 2
@@ -638,6 +659,9 @@ layout_mode = 2
custom_minimum_size = Vector2(1080, 1024)
layout_mode = 2
[node name="ActionBorder" parent="Stage/StageRows/PageScroller/HBoxContainer/StructurePage" unique_id=449208508 instance=ExtResource("12_58wjt")]
layout_mode = 2
[node name="Actions" parent="Stage/StageRows/PageScroller/HBoxContainer/StructurePage" unique_id=1391835556 instance=ExtResource("17_ifjjt")]
layout_mode = 2
@@ -836,6 +860,14 @@ offset_top = 512.0
offset_right = 1080.0
offset_bottom = 1024.0
[node name="ActionBorder" parent="Stage/StageRows/PageScroller/HBoxContainer/LifePage" unique_id=160841192 instance=ExtResource("12_58wjt")]
layout_mode = 2
[node name="Panel" type="PanelContainer" parent="Stage/StageRows/PageScroller/HBoxContainer/LifePage" unique_id=116394684]
custom_minimum_size = Vector2(0, 216)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_ifjjt")
[node name="Border" parent="Stage/StageRows" unique_id=145801370 instance=ExtResource("12_58wjt")]
layout_mode = 2