diff options
Diffstat (limited to 'client/menu')
-rw-r--r-- | client/menu/main_menu.gd | 38 | ||||
-rw-r--r-- | client/menu/main_menu.tscn | 13 |
2 files changed, 41 insertions, 10 deletions
diff --git a/client/menu/main_menu.gd b/client/menu/main_menu.gd index 168eda7e..c96d6c13 100644 --- a/client/menu/main_menu.gd +++ b/client/menu/main_menu.gd @@ -20,11 +20,14 @@ extends Control @onready var quit_button = $side/margin/options/quit @onready var connect_uri = $side/margin/options/connect/uri -@onready var server_button = $side/margin/options/server +@onready var server = $side/margin/options/server +@onready var server_control = $side/margin/options/server/control +@onready var server_connect = $side/margin/options/server/connect func _ready(): if OS.has_feature("web"): quit_button.hide() + server.hide() connect_uri.text = Global.profile["last_server_url"] func _on_quit_pressed(): @@ -64,13 +67,32 @@ func _on_server_pressed(): match Server.state: Server.State.RUNNING: Server.stop() Server.State.STOPPED: Server.start() + Server.State.FAILED: Server.start() func _process(_delta): - server_button.disabled = Server.state != Server.State.RUNNING and Server.state != Server.State.STOPPED - server_button.modulate = Color.AQUAMARINE if Server.state == Server.State.RUNNING else Color.WHITE + server_control.disabled = false + server_connect.visible = Server.state == Server.State.RUNNING + server_control.modulate = Color.WHITE match Server.state: - Server.State.RUNNING: server_button.text = tr("Stop Server") - Server.State.TESTING: server_button.text = tr("Server (Testing)") - Server.State.STARTING: server_button.text = tr("Server is starting...") - Server.State.STOPPED: server_button.text = tr("Start Server") - Server.State.UNAVAILABLE: server_button.text = tr("Server (Unavailable)"); server_button.tooltip_text = tr("Server binary was not found. Please install the server seperately.") + Server.State.RUNNING: + server_control.text = tr("Stop Server") + server_control.modulate = Color.AQUAMARINE + Server.State.TESTING: + server_control.text = tr("Server (Testing)") + server_control.disabled = true + Server.State.STARTING: + server_control.text = tr("Server is starting...") + server_control.disabled = true + Server.State.STOPPED: + server_control.text = tr("Start Server") + Server.State.FAILED: + server_control.text = tr("Server (Failed)") + server_control.modulate = Color(1,0.4,0.5) + server_control.tooltip_text = tr("The server crashed or exited in some way or another.\nGodot's APIs are so bad however, that we really can't know why that happend.\nYou should try starting the server from the command-line.") + Server.State.UNAVAILABLE: + server_control.text = tr("Server (Unavailable)") + server_control.disabled = true + server_control.tooltip_text = tr("Server binary was not found. Please install the server seperately.") + +func _on_server_connect_pressed(): + connect_to("ws://127.0.0.1:27032/") diff --git a/client/menu/main_menu.tscn b/client/menu/main_menu.tscn index 32a55276..03f9cf46 100644 --- a/client/menu/main_menu.tscn +++ b/client/menu/main_menu.tscn @@ -81,11 +81,19 @@ layout_mode = 2 text = "Settings" alignment = 0 -[node name="server" type="Button" parent="side/margin/options"] +[node name="server" type="HBoxContainer" parent="side/margin/options"] layout_mode = 2 + +[node name="control" type="Button" parent="side/margin/options/server"] +layout_mode = 2 +size_flags_horizontal = 3 text = "Server" alignment = 0 +[node name="connect" type="Button" parent="side/margin/options/server"] +layout_mode = 2 +text = "Connect" + [node name="credits" type="Button" parent="side/margin/options"] layout_mode = 2 text = "Credits" @@ -100,6 +108,7 @@ alignment = 0 [connection signal="pressed" from="side/margin/options/connect/connect" to="." method="_on_connect_pressed"] [connection signal="pressed" from="side/margin/options/change_character" to="." method="_on_change_character_pressed"] [connection signal="pressed" from="side/margin/options/settings" to="." method="_on_settings_pressed"] -[connection signal="pressed" from="side/margin/options/server" to="." method="_on_server_pressed"] +[connection signal="pressed" from="side/margin/options/server/control" to="." method="_on_server_pressed"] +[connection signal="pressed" from="side/margin/options/server/connect" to="." method="_on_server_connect_pressed"] [connection signal="pressed" from="side/margin/options/credits" to="." method="_on_credits_pressed"] [connection signal="pressed" from="side/margin/options/quit" to="." method="_on_quit_pressed"] |