blob: a0ad2ee5d30cef7fa0df5380533c018860a0af0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# Hurry Curry! - a game about cooking
# Copyright 2024 metamuffin
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
extends Menu
@onready var quit_button = $side/margin/options/quit
@onready var connect_uri = $side/margin/options/connect/uri
@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():
super()
if OS.has_feature("web"):
quit_button.hide()
server.hide()
connect_uri.text = Global.get_profile("last_server_url")
func menu_anim_cover(covered):
$side.visible = not covered
func _on_quit_pressed():
quit()
func _on_credits_pressed():
submenu("res://menu/credits.tscn", true)
func _on_connect_pressed():
var url = connect_uri.text
Global.set_profile("last_server_url", url)
connect_to(url)
func _on_quick_connect_pressed():
if OS.has_feature("JavaScript"):
connect_to(JavaScriptBridge.eval("""
window.location.protocol.endsWith("s:")
? `wss://${window.location.host}/`
: `ws://${window.location.hostname}:27032/`
"""))
else:
connect_to("wss://hurrycurry.metamuffin.org/")
func connect_to(url):
print("Connecting to %s" % url)
Global.server_url = url
replace_menu("res://menu/game.tscn")
func _on_change_character_pressed():
replace_menu("res://menu/character.tscn")
func _on_settings_pressed():
submenu("res://menu/settings.tscn", true)
func _on_server_pressed():
match Server.state:
Server.State.RUNNING: Server.stop()
Server.State.STOPPED: Server.start()
Server.State.FAILED: Server.start()
func _on_server_connect_pressed():
connect_to("ws://127.0.0.1:27032/")
func _process(_delta):
server_control.disabled = false
server_connect.visible = Server.state == Server.State.RUNNING
server_control.modulate = Color.WHITE
match Server.state:
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.")
|