diff options
Diffstat (limited to 'client/menu')
-rw-r--r-- | client/menu/play.gd | 58 | ||||
-rw-r--r-- | client/menu/play.tscn | 17 |
2 files changed, 63 insertions, 12 deletions
diff --git a/client/menu/play.gd b/client/menu/play.gd index 50e8a633..894ea4bc 100644 --- a/client/menu/play.gd +++ b/client/menu/play.gd @@ -26,6 +26,8 @@ var url_regex: RegEx = RegEx.new() @onready var server = $side/margin/options/second/server @onready var server_control = $side/margin/options/second/server/control @onready var server_connect = $side/margin/options/second/server/connect +@onready var editor_control = $side/margin/options/second/editor/control +@onready var editor_connect = $side/margin/options/second/editor/connect func _ready(): url_regex.compile("^(?:(ws|wss)://)?([^:]+)(?::([0-9]+))?$") @@ -127,40 +129,74 @@ func connect_to(url: String): print("Connecting to %s" % url) get_parent().replace_menu("res://menu/game.tscn", url) -func _on_server_pressed(): +func _on_server_control_pressed(): match Server.state: - Server.State.RUNNING: Server.stop() - Server.State.STOPPED: Server.start() - Server.State.FAILED: Server.start() + Service.State.RUNNING: Server.stop() + Service.State.STOPPED: Server.start() + Service.State.FAILED: Server.start() + +func _on_editor_control_pressed(): + match Editor.state: + Service.State.RUNNING: Editor.stop() + Service.State.STOPPED: Editor.start(); Server.start() + Service.State.FAILED: Editor.start() func _on_server_connect_pressed(): connect_to("ws://127.0.0.1:27032/") +func _on_editor_connect_pressed(): + connect_to("ws://127.0.0.1:27035/") + func _process(_delta): server_control.disabled = false - server_connect.visible = Server.state == Server.State.RUNNING + server_connect.visible = Server.state == Service.State.RUNNING server_control.modulate = Color.WHITE match Server.state: - Server.State.RUNNING: + Service.State.RUNNING: server_control.text = tr("c.menu.play.server_stop") server_control.modulate = Color.AQUAMARINE - Server.State.TESTING: + Service.State.TESTING: server_control.text = tr("c.menu.play.server_testing") server_control.disabled = true - Server.State.STARTING: + Service.State.STARTING: server_control.text = tr("c.menu.play.server_starting") server_control.disabled = true - Server.State.STOPPED: + Service.State.STOPPED: server_control.text = tr("c.menu.play.server_start") - Server.State.FAILED: + Service.State.FAILED: server_control.text = tr("c.menu.play.server_failed") server_control.modulate = Color(1, 0.4, 0.5) server_control.tooltip_text = tr("c.menu.play.server_failed_tooltip") - Server.State.UNAVAILABLE: + Service.State.UNAVAILABLE: server_control.text = tr("c.menu.play.server_unavailable") server_control.disabled = true server_control.tooltip_text = tr("c.menu.play.server_binary_not_found") + editor_control.disabled = false + editor_connect.visible = Editor.state == Service.State.RUNNING + editor_control.modulate = Color.WHITE + match Editor.state: + Service.State.RUNNING: + editor_control.text = tr("c.menu.play.editor_stop") + editor_control.modulate = Color.AQUAMARINE + Service.State.TESTING: + editor_control.text = tr("c.menu.play.editor_testing") + editor_control.disabled = true + Service.State.STARTING: + editor_control.text = tr("c.menu.play.editor_starting") + editor_control.disabled = true + Service.State.STOPPED: + editor_control.text = tr("c.menu.play.editor_start") + Service.State.FAILED: + editor_control.text = tr("c.menu.play.editor_failed") + editor_control.modulate = Color(1, 0.4, 0.5) + editor_control.tooltip_text = tr("c.menu.play.server_failed_tooltip") + Service.State.UNAVAILABLE: + editor_control.text = tr("c.menu.play.editor_unavailable") + editor_control.disabled = true + editor_control.tooltip_text = tr("c.menu.play.server_binary_not_found") + + func _on_uri_text_changed(new_text): connect_uri.modulate = Color.WHITE if url_regex.search(new_text) else Color.RED diff --git a/client/menu/play.tscn b/client/menu/play.tscn index 43a3414f..47b45d69 100644 --- a/client/menu/play.tscn +++ b/client/menu/play.tscn @@ -113,6 +113,19 @@ alignment = 0 layout_mode = 2 text = "c.menu.play.connect" +[node name="editor" type="HBoxContainer" parent="side/margin/options/second"] +layout_mode = 2 + +[node name="control" type="Button" parent="side/margin/options/second/editor"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "c.menu.play.editor" +alignment = 0 + +[node name="connect" type="Button" parent="side/margin/options/second/editor"] +layout_mode = 2 +text = "c.menu.play.connect" + [node name="spacer2" type="Control" parent="side/margin/options/second"] custom_minimum_size = Vector2(0, 10) layout_mode = 2 @@ -127,6 +140,8 @@ layout_mode = 2 [connection signal="text_changed" from="side/margin/options/second/connect/uri" to="." method="_on_uri_text_changed"] [connection signal="pressed" from="side/margin/options/second/connect/connect" to="." method="_on_connect_pressed"] -[connection signal="pressed" from="side/margin/options/second/server/control" to="." method="_on_server_pressed"] +[connection signal="pressed" from="side/margin/options/second/server/control" to="." method="_on_server_control_pressed"] [connection signal="pressed" from="side/margin/options/second/server/connect" to="." method="_on_server_connect_pressed"] +[connection signal="pressed" from="side/margin/options/second/editor/control" to="." method="_on_editor_control_pressed"] +[connection signal="pressed" from="side/margin/options/second/editor/connect" to="." method="_on_editor_connect_pressed"] [connection signal="pressed" from="side/margin/options/second/back" to="." method="_on_back_pressed"] |