support dialogue, actions

master
chimchooree 2 years ago
parent fc90cc9c30
commit dc9dbba11c

@ -6,6 +6,9 @@ onready var ui = $UI
export var websocket_url = "ws://127.0.0.1:8080" export var websocket_url = "ws://127.0.0.1:8080"
var _client = WebSocketClient.new() var _client = WebSocketClient.new()
func act(action):
_client.get_peer(1).put_packet(JSON.print({'type': 'action', 'action': action}).to_utf8())
func _ready(): func _ready():
TranslationServer.set_locale("en") TranslationServer.set_locale("en")
for text in get_tree().get_nodes_in_group("translate"): for text in get_tree().get_nodes_in_group("translate"):

@ -139,6 +139,10 @@ size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
columns = 2 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"] [node name="Partner" type="TextureRect" parent="UI/HBox/Content/Game/VBox/HBox2"]
margin_left = 434.0 margin_left = 434.0
margin_right = 584.0 margin_right = 584.0

@ -16,6 +16,9 @@ func change_portrait(packet):
func change_view(packet): func change_view(packet):
view.texture = load("res://Res/Img/Scene/" + packet["loc"] + ".png") view.texture = load("res://Res/Img/Scene/" + packet["loc"] + ".png")
func _on_action_decided(action_decided):
get_parent().act(action_decided)
# Modify Available Actions # Modify Available Actions
func consider_actions(packet): func consider_actions(packet):
if packet['clear_box']: if packet['clear_box']:
@ -25,6 +28,7 @@ func consider_actions(packet):
var b = Button.new() var b = Button.new()
b.set_text(tr(a)) b.set_text(tr(a))
action.add_child(b) action.add_child(b)
b.connect("button_up", self, "_on_action_decided", [a])
# Modify Prose in Dialogue Box # Modify Prose in Dialogue Box
func write_prose(packet): func write_prose(packet):

Loading…
Cancel
Save