diff --git a/gui/production_chart.gd b/gui/production_chart.gd new file mode 100644 index 0000000..41ae7f2 --- /dev/null +++ b/gui/production_chart.gd @@ -0,0 +1,12 @@ +extends VBoxContainer + +func _ready() -> void: + Economy.productions_update.connect(sync) + +func sync(productions: Array[Production]): + for child in get_children(): + child.queue_free() + for p in productions: + var display := preload("res://gui/production_display.tscn").instantiate() + display.production = p + add_child(display) diff --git a/gui/production_chart.gd.uid b/gui/production_chart.gd.uid new file mode 100644 index 0000000..8b618d4 --- /dev/null +++ b/gui/production_chart.gd.uid @@ -0,0 +1 @@ +uid://6u0icldaifvd diff --git a/gui/production_chart.tscn b/gui/production_chart.tscn new file mode 100644 index 0000000..08a490b --- /dev/null +++ b/gui/production_chart.tscn @@ -0,0 +1,6 @@ +[gd_scene format=3 uid="uid://desvyn6e28oar"] + +[ext_resource type="Script" uid="uid://6u0icldaifvd" path="res://gui/production_chart.gd" id="1_esxju"] + +[node name="ProductionChart" type="VBoxContainer" unique_id=1301678172] +script = ExtResource("1_esxju") diff --git a/gui/production_display.gd b/gui/production_display.gd new file mode 100644 index 0000000..b618ed0 --- /dev/null +++ b/gui/production_display.gd @@ -0,0 +1,7 @@ +extends Control + +@export var production: Production + +func _ready() -> void: + %Name.text = production.currency.name + %Amount.text = str(production.amount) diff --git a/gui/production_display.gd.uid b/gui/production_display.gd.uid new file mode 100644 index 0000000..b835f41 --- /dev/null +++ b/gui/production_display.gd.uid @@ -0,0 +1 @@ +uid://ck17fbo6svid8 diff --git a/gui/production_display.tscn b/gui/production_display.tscn new file mode 100644 index 0000000..0255058 --- /dev/null +++ b/gui/production_display.tscn @@ -0,0 +1,18 @@ +[gd_scene format=3 uid="uid://dmka51sldrutn"] + +[ext_resource type="Script" uid="uid://ck17fbo6svid8" path="res://gui/production_display.gd" id="1_dfe88"] + +[node name="ProductionDisplay" type="MarginContainer" unique_id=253822540] +custom_minimum_size = Vector2(400, 0) +script = ExtResource("1_dfe88") + +[node name="Name" type="Label" parent="." unique_id=1739229616] +unique_name_in_owner = true +layout_mode = 2 +text = "" + +[node name="Amount" type="Label" parent="." unique_id=660284845] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 8 +text = "0" diff --git a/gui/production_ledger.gd b/gui/production_ledger.gd new file mode 100644 index 0000000..8307090 --- /dev/null +++ b/gui/production_ledger.gd @@ -0,0 +1,10 @@ +extends VBoxContainer + +func _ready() -> void: + Economy.production_log.connect(append) + +func append(producer: Currency, production: Production): + var display := preload("res://gui/production_log.tscn").instantiate() + display.producer = producer + display.production = production + add_child(display) diff --git a/gui/production_ledger.gd.uid b/gui/production_ledger.gd.uid new file mode 100644 index 0000000..7a8243f --- /dev/null +++ b/gui/production_ledger.gd.uid @@ -0,0 +1 @@ +uid://5u2qeh5gvhhl diff --git a/gui/production_ledger.tscn b/gui/production_ledger.tscn new file mode 100644 index 0000000..6e3d4e5 --- /dev/null +++ b/gui/production_ledger.tscn @@ -0,0 +1,6 @@ +[gd_scene format=3 uid="uid://cxv743rjsolk5"] + +[ext_resource type="Script" uid="uid://5u2qeh5gvhhl" path="res://gui/production_ledger.gd" id="1_8f0gq"] + +[node name="ProductionChart" type="VBoxContainer" unique_id=1301678172] +script = ExtResource("1_8f0gq") diff --git a/gui/production_log.gd b/gui/production_log.gd new file mode 100644 index 0000000..182ada2 --- /dev/null +++ b/gui/production_log.gd @@ -0,0 +1,14 @@ +extends Control + +@export var producer: Currency +@export var production: Production + +func _ready() -> void: + %producer.text = producer.name + %amount.text = str(abs(production.amount)) + if production.amount > 0: + %type.text = "produced" + else: + %type.text = "consumed" + + %production.text = production.currency.name diff --git a/gui/production_log.gd.uid b/gui/production_log.gd.uid new file mode 100644 index 0000000..32571ef --- /dev/null +++ b/gui/production_log.gd.uid @@ -0,0 +1 @@ +uid://cm5y8byaoeda5 diff --git a/gui/production_log.tscn b/gui/production_log.tscn new file mode 100644 index 0000000..ee56be1 --- /dev/null +++ b/gui/production_log.tscn @@ -0,0 +1,37 @@ +[gd_scene format=3 uid="uid://dth0nxini731n"] + +[ext_resource type="Script" uid="uid://cm5y8byaoeda5" path="res://gui/production_log.gd" id="1_ei3g1"] + +[node name="ProductionLog" type="MarginContainer" unique_id=253822540] +script = ExtResource("1_ei3g1") + +[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=1073672077] +layout_mode = 2 + +[node name="producer" type="Label" parent="HBoxContainer" unique_id=1739229616] +unique_name_in_owner = true +layout_mode = 2 +text = "" + +[node name="type" type="Label" parent="HBoxContainer" unique_id=660284845] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 8 +text = "produced" + +[node name="amount" type="Label" parent="HBoxContainer" unique_id=146404186] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 8 +text = "0" + +[node name="text_produced2" type="Label" parent="HBoxContainer" unique_id=1784666448] +layout_mode = 2 +size_flags_horizontal = 8 +text = "of" + +[node name="production" type="Label" parent="HBoxContainer" unique_id=1547964707] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 8 +text = "" diff --git a/test/test_economy.gd b/test/test_economy.gd new file mode 100644 index 0000000..e07a0bf --- /dev/null +++ b/test/test_economy.gd @@ -0,0 +1 @@ +extends Control diff --git a/test/test_economy.gd.uid b/test/test_economy.gd.uid new file mode 100644 index 0000000..51db366 --- /dev/null +++ b/test/test_economy.gd.uid @@ -0,0 +1 @@ +uid://6438cbkn3fhm diff --git a/test/test_economy.tscn b/test/test_economy.tscn new file mode 100644 index 0000000..ba5af42 --- /dev/null +++ b/test/test_economy.tscn @@ -0,0 +1,24 @@ +[gd_scene format=3 uid="uid://d06w1wtct0mfs"] + +[ext_resource type="Script" uid="uid://6438cbkn3fhm" path="res://test/test_economy.gd" id="1_s48qe"] +[ext_resource type="PackedScene" uid="uid://desvyn6e28oar" path="res://gui/production_chart.tscn" id="2_jd86c"] +[ext_resource type="PackedScene" uid="uid://cxv743rjsolk5" path="res://gui/production_ledger.tscn" id="3_jd7cj"] + +[node name="TestEconomy" type="Control" unique_id=629898212] +layout_mode = 3 +anchors_preset = 0 +script = ExtResource("1_s48qe") + +[node name="ProductionChart" parent="." unique_id=1301678172 instance=ExtResource("2_jd86c")] +layout_mode = 0 + +[node name="ScrollContainer" type="ScrollContainer" parent="." unique_id=1023925432] +custom_minimum_size = Vector2(600, 100) +layout_mode = 0 +offset_left = 153.0 +offset_top = 346.0 +offset_right = 161.0 +offset_bottom = 346.0 + +[node name="ProductionChart2" parent="ScrollContainer" unique_id=1698529519 instance=ExtResource("3_jd7cj")] +layout_mode = 2