.
This commit is contained in:
parent
2294aac186
commit
39972761ea
9 changed files with 82 additions and 12 deletions
15
bribe_button.gd
Normal file
15
bribe_button.gd
Normal file
|
|
@ -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()
|
||||
1
bribe_button.gd.uid
Normal file
1
bribe_button.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://olr6663hny8n
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
9
gui/bribe_button.tscn
Normal file
9
gui/bribe_button.tscn
Normal file
|
|
@ -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"]
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:"
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -125,3 +125,4 @@ dialogic_default_action={
|
|||
[rendering]
|
||||
|
||||
rendering_device/driver.windows="d3d12"
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue