diff --git a/Lemon.gd b/Lemon.gd index 0e98ca3..3091a63 100644 --- a/Lemon.gd +++ b/Lemon.gd @@ -6,6 +6,9 @@ onready var ui = $UI export var websocket_url = "ws://127.0.0.1:8080" var _client = WebSocketClient.new() +func act(action): + _client.get_peer(1).put_packet(JSON.print({'type': 'action', 'action': action}).to_utf8()) + func _ready(): TranslationServer.set_locale("en") for text in get_tree().get_nodes_in_group("translate"): diff --git a/LemonGame.tscn b/LemonGame.tscn index c15093f..13901c5 100644 --- a/LemonGame.tscn +++ b/LemonGame.tscn @@ -139,6 +139,10 @@ size_flags_horizontal = 3 size_flags_vertical = 3 columns = 2 +[node name="Button" type="Button" parent="UI/HBox/Content/Game/VBox/HBox2/VBox/Action"] +margin_right = 12.0 +margin_bottom = 20.0 + [node name="Partner" type="TextureRect" parent="UI/HBox/Content/Game/VBox/HBox2"] margin_left = 434.0 margin_right = 584.0 diff --git a/UI/UI.gd b/UI/UI.gd index 20dde90..ff84096 100644 --- a/UI/UI.gd +++ b/UI/UI.gd @@ -16,6 +16,9 @@ func change_portrait(packet): func change_view(packet): view.texture = load("res://Res/Img/Scene/" + packet["loc"] + ".png") +func _on_action_decided(action_decided): + get_parent().act(action_decided) + # Modify Available Actions func consider_actions(packet): if packet['clear_box']: @@ -25,6 +28,7 @@ func consider_actions(packet): var b = Button.new() b.set_text(tr(a)) action.add_child(b) + b.connect("button_up", self, "_on_action_decided", [a]) # Modify Prose in Dialogue Box func write_prose(packet):