summaryrefslogtreecommitdiff
path: root/client/menu/ingame.gd
blob: 6f1e40fe149332e283d8fe0a4df2733311882c80 (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
# Hurry Curry! - a game about cooking
# Copyright 2024 metamuffin
# Copyright 2024 tpart
#
# 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 anim = $AnimationPlayer
@onready var options = $Side/Margin/Options
@onready var game: Game = $"../Game"
@onready var lobby_button: Button = $Side/Margin/Options/Lobby
@onready var leave_button: Button = $Side/Margin/Options/Leave

var opened
func _ready():
	opened = Time.get_ticks_msec()
	lobby_button.disabled = game.in_lobby
	game.joined.connect(_on_game_joined)
	game.left.connect(_on_game_left)
	update_button_text()
	super()

func anim_setup(): pass
func menu_anim_open():
	print("ingame open")
	game.player_set_input_enabled.emit(false)
	anim.play("activate")
	await anim.animation_finished
func menu_anim_exit():
	print("ingame exit")
	game.player_set_input_enabled.emit(true)
	anim.play_backwards("activate")
	await anim.animation_finished

func _on_resume_pressed():
	exit()

func _on_main_menu_pressed():
	parent_menu.replace_menu("res://menu/main.tscn")

func _on_settings_pressed():
	submenu("res://menu/settings.tscn", true)

func _on_reconnect_pressed():
	parent_menu.replace_menu("res://menu/game.tscn")

func _on_quit_pressed():
	quit()

func _on_lobby_pressed():
	game.mp.send_chat("/end")
	exit()

func _on_leave_pressed():
	if game.is_joined:
		game.mp.send_leave()
	elif not game.join_sent:
		leave_button.disabled = true
		game.join()

func _on_game_joined():
	leave_button.disabled = false
	update_button_text()

func _on_game_left():
	update_button_text()

func update_button_text():
	if game.is_joined:
		leave_button.text = tr("Leave Game")
	else:
		leave_button.text = tr("Join Game")