diff options
author | metamuffin <metamuffin@disroot.org> | 2024-12-26 13:43:03 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-12-26 13:43:03 +0100 |
commit | e73d6273e969f9720b9ce730c3c5825126ae892b (patch) | |
tree | 386c13a5a582e9593605dcef9b6dab7cf6b15620 /client/menu/play.gd | |
parent | 01811610b169a0572417c1493ea606353fd1a327 (diff) | |
download | hurrycurry-e73d6273e969f9720b9ce730c3c5825126ae892b.tar hurrycurry-e73d6273e969f9720b9ce730c3c5825126ae892b.tar.bz2 hurrycurry-e73d6273e969f9720b9ce730c3c5825126ae892b.tar.zst |
generalize services and add editor to play menu
Diffstat (limited to 'client/menu/play.gd')
-rw-r--r-- | client/menu/play.gd | 58 |
1 files changed, 47 insertions, 11 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 |