diff --git a/bribe_button.gd b/bribe_button.gd new file mode 100644 index 0000000..bd76a36 --- /dev/null +++ b/bribe_button.gd @@ -0,0 +1,15 @@ +extends Button + +@export var bribe: Production + +signal bribe_succees + +func _ready() -> void: + sync() + +func sync(): + text = str(bribe.amount) + " of " + bribe.currency.name + +func _on_pressed() -> void: + if Economy.do_bribing(bribe): + bribe_succees.emit() diff --git a/bribe_button.gd.uid b/bribe_button.gd.uid new file mode 100644 index 0000000..cb7df12 --- /dev/null +++ b/bribe_button.gd.uid @@ -0,0 +1 @@ +uid://olr6663hny8n diff --git a/economy.gd b/economy.gd index 7f21028..947a287 100644 --- a/economy.gd +++ b/economy.gd @@ -17,6 +17,15 @@ func get_currency(c: Currency) -> Production: currencies.append(p) return p +func do_bribing(p: Production) -> bool: + produce(negate_production(p)) + return true + +func negate_production(p: Production) -> Production: + var pp := p.duplicate() + pp.amount = -pp.amount + return pp + func sync_currency(): var did_remove := true while did_remove: diff --git a/gui/bribe_button.tscn b/gui/bribe_button.tscn new file mode 100644 index 0000000..6ca6c6b --- /dev/null +++ b/gui/bribe_button.tscn @@ -0,0 +1,9 @@ +[gd_scene format=3 uid="uid://dqb4a1igddv71"] + +[ext_resource type="Script" uid="uid://olr6663hny8n" path="res://bribe_button.gd" id="1_2abdb"] + +[node name="BribeButton" type="Button" unique_id=1084248382] +text = "< num > of < currency >" +script = ExtResource("1_2abdb") + +[connection signal="pressed" from="." to="." method="_on_pressed"] diff --git a/gui/currency_inspector_panel.gd b/gui/currency_inspector_panel.gd index b1a9d1e..0b554a7 100644 --- a/gui/currency_inspector_panel.gd +++ b/gui/currency_inspector_panel.gd @@ -23,10 +23,16 @@ func update(): %CurrencyDescription.text = currency.description for child in %ProductionsList.get_children(): child.queue_free() + %word.visible = currency.production.size() > 0 for production in currency.production: var display := preload("res://gui/production_display.tscn").instantiate() display.production = production %ProductionsList.add_child(display) + if currency.thumbnail != null: + %CurrrencyImage.visible = true + %CurrrencyImage.texture = currency.thumbnail + else: + %CurrrencyImage.visible = false func _on_close_button_pressed() -> void: visible = false diff --git a/gui/currency_inspector_panel.tscn b/gui/currency_inspector_panel.tscn index eff7f63..d437f63 100644 --- a/gui/currency_inspector_panel.tscn +++ b/gui/currency_inspector_panel.tscn @@ -1,14 +1,7 @@ [gd_scene format=3 uid="uid://75htlmk51oo"] [ext_resource type="Script" uid="uid://bkptc7j6c1r7p" path="res://gui/currency_inspector_panel.gd" id="1_tj5vo"] - -[sub_resource type="Gradient" id="Gradient_jd7cj"] - -[sub_resource type="GradientTexture2D" id="GradientTexture2D_y6nab"] -gradient = SubResource("Gradient_jd7cj") - -[sub_resource type="CanvasTexture" id="CanvasTexture_4sc8i"] -diffuse_texture = SubResource("GradientTexture2D_y6nab") +[ext_resource type="Texture2D" uid="uid://bplvus0ytk2f8" path="res://thumbnails/beer.png" id="2_p4bd1"] [node name="CurrencyInspectorPanel" type="Control" unique_id=169191981] custom_minimum_size = Vector2(0, 100) @@ -39,19 +32,27 @@ grow_horizontal = 2 unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 +theme_override_font_sizes/font_size = 25 text = "< Selected Currency >" -[node name="CurrrencyImage" type="TextureRect" parent="VBoxContainer" unique_id=1066520786] -unique_name_in_owner = true +[node name="CenterContainer" type="CenterContainer" parent="VBoxContainer" unique_id=1252469629] layout_mode = 2 -texture = SubResource("CanvasTexture_4sc8i") + +[node name="CurrrencyImage" type="TextureRect" parent="VBoxContainer/CenterContainer" unique_id=1066520786] +unique_name_in_owner = true +custom_minimum_size = Vector2(250, 250) +custom_maximum_size = Vector2(250, 250) +layout_mode = 2 +texture = ExtResource("2_p4bd1") [node name="CurrencyDescription" type="Label" parent="VBoxContainer" unique_id=543173020] unique_name_in_owner = true layout_mode = 2 -text = "< Description of currency >" +text = "< Description of currency >< Description of currency >< Description of currency >< Description of currency >< Description of currency >< Description of currency >< Description of currency >< Description of currency >< Description of currency >< Description of currency >< Description of currency >" +autowrap_mode = 3 [node name="word" type="Label" parent="VBoxContainer" unique_id=835011658] +unique_name_in_owner = true layout_mode = 2 text = "Production:" diff --git a/member_inspector_panel.gd b/member_inspector_panel.gd index 3e91e2d..e0dd381 100644 --- a/member_inspector_panel.gd +++ b/member_inspector_panel.gd @@ -19,6 +19,23 @@ func member_left(): member = null visible = false +func clear_bribes(): + for child in %BribesList.get_children(): + child.queue_free() + +func bribe_success(): + member.allegiance = preload("res://allegiance/good.tres") + member.sync() + update() + +func load_bribes(): + for p in member.currency.wants: + var btn := preload("res://gui/bribe_button.tscn").instantiate() + btn.bribe = p + btn.bribe_succees.connect(bribe_success) + %BribesList.add_child(btn) + + func currency_inspect(_c: Currency): visible = false @@ -29,4 +46,9 @@ func update(): %CurrencyMemberSprite.currency = member.currency %CurrencyMemberSprite.allegiance = member.allegiance %CurrencyMemberSprite.sync() + clear_bribes() + %Bribes.visible = false + if member.allegiance != preload("res://allegiance/good.tres"): + load_bribes() + %Bribes.visible = true diff --git a/member_inspector_panel.tscn b/member_inspector_panel.tscn index ebf1bbb..0722179 100644 --- a/member_inspector_panel.tscn +++ b/member_inspector_panel.tscn @@ -32,4 +32,10 @@ custom_maximum_size = Vector2(75, 75) layout_mode = 2 [node name="Bribes" type="Label" parent="VBoxContainer" parent_id_path=PackedInt32Array(362599487) index="9" unique_id=807570934] +unique_name_in_owner = true +layout_mode = 2 +text = "Bribe with" + +[node name="BribesList" type="VBoxContainer" parent="VBoxContainer" parent_id_path=PackedInt32Array(362599487) index="10" unique_id=476203914] +unique_name_in_owner = true layout_mode = 2 diff --git a/project.godot b/project.godot index dfdea1a..7b90190 100644 --- a/project.godot +++ b/project.godot @@ -125,3 +125,4 @@ dialogic_default_action={ [rendering] rendering_device/driver.windows="d3d12" +renderer/rendering_method="gl_compatibility"