-
Notifications
You must be signed in to change notification settings - Fork 1
/
MenuManager.gd
288 lines (261 loc) · 8.37 KB
/
MenuManager.gd
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
class_name MenuManager extends Node
@export var savefile : SaveFileManager
@export var cursor : CursorManager
@export var animator_intro : AnimationPlayer
@export var speaker_music : AudioStreamPlayer2D
@export var speaker_start : AudioStreamPlayer2D
@export var buttons : Array[ButtonClass]
@export var buttons_options : Array[ButtonClass]
@export var screens : Array[Control]
@export var parent_main : Control
@export var parent_creds : Control
@export var parent_suboptions : Control
@export var parent_audiovideo : Control
@export var parent_language : Control
@export var parent_controller : Control
@export var parent_rebinding : Control
@export var title : Node3D
@export var waterfalls : Array[AnimationPlayer]
@export var optionmanager : OptionsManager
@export var controller : ControllerManager
@export var mouseblocker : Control
@export var anim_creds : AnimationPlayer
@export var version : Label
var viewing_intro : bool
func _ready():
Show("main")
buttons[0].connect("is_pressed", Start)
buttons[1].connect("is_pressed", SubOptions)
buttons[2].connect("is_pressed", Credits)
buttons[3].connect("is_pressed", Exit)
buttons[4].connect("is_pressed", ReturnToLastScreen)
buttons[5].connect("is_pressed", ReturnToLastScreen)
buttons[6].connect("is_pressed", ReturnToLastScreen)
buttons[7].connect("is_pressed", Options_AudioVideo)
buttons[8].connect("is_pressed", Options_Language)
buttons[9].connect("is_pressed", Options_Controller)
buttons[10].connect("is_pressed", ReturnToLastScreen)
buttons[11].connect("is_pressed", ReturnToLastScreen)
buttons[16].connect("is_pressed", RebindControls)
buttons[17].connect("is_pressed", ReturnToLastScreen)
buttons[18].connect("is_pressed", ResetControls)
buttons[19].connect("is_pressed", DiscordLink)
buttons[22].connect("is_pressed", StartMultiplayer)
buttons_options[0].connect("is_pressed", IncreaseVol)
buttons_options[1].connect("is_pressed", DecreaseVol)
buttons_options[2].connect("is_pressed", SetFull)
buttons_options[3].connect("is_pressed", SetWindowed)
buttons_options[4].connect("is_pressed", ControllerEnable)
buttons_options[5].connect("is_pressed", ControllerDisable)
buttons_options[6].connect("is_pressed", ToggleColorblind)
buttons_options[7].connect("is_pressed", ToggleMusic)
buttons_options[8].connect("is_pressed", ToggleGreyscaleDeath)
version.text = GlobalVariables.currentVersion
Intro()
func _process(delta):
T()
func CheckCommandLine():
var arguments = OS.get_cmdline_args()
for argument in arguments:
if (arguments.size() > 0):
#if (GlobalSteam.LOBBY_INVITE_ARG):
# join_lobby(int(argument))
pass
if argument == "+connect_lobby":
GlobalSteam.LOBBY_INVITE_ARG = true
var failsafed = true
var fs2 = false
func _input(event):
if (event.is_action_pressed("ui_cancel") && failsafed):
if (currentScreen != "main"): ReturnToLastScreen()
if (event.is_action_pressed("exit game") && failsafed):
if (currentScreen != "main"): ReturnToLastScreen()
if (event.is_action_pressed("exit game") && !fs2 && viewing_intro):
SkipIntro()
fs2 = true
func Intro():
cursor.SetCursor(false, false)
if GlobalVariables.lobby_id_found_in_command_line != 0 && !GlobalVariables.command_line_checked:
print("lobby id found in command line. dont run the menu intro")
return
viewing_intro = true
speaker_music.play()
animator_intro.play("splash screen")
c = true
func SkipIntro():
c = false
animator_intro.stop()
animator_intro.play("skip intro")
FinishIntro()
func FinishIntro():
viewing_intro = false
mouseblocker.visible = false
cursor.SetCursor(true, false)
controller.settingFilter = true
controller.SetMainControllerState(controller.controller_currently_enabled)
if (cursor.controller_active): firstFocus_main.grab_focus()
controller.previousFocus = firstFocus_main
assigningFocus = true
var t = 0
var c = false
var fs = false
func T():
if c: t+= get_process_delta_time()
if t > 9 && !fs:
FinishIntro()
fs = true
func Buttons(state : bool):
if (!state):
for i in buttons:
i.isActive = false
i.SetFilter("ignore")
else:
for i in buttons:
i.isActive = true
i.SetFilter("stop")
@export var firstFocus_main : Control
@export var firstFocus_subOptions : Control
@export var firstFocus_credits : Control
@export var firstFocus_audioVideo : Control
@export var firstFocus_language : Control
@export var firstFocus_controller : Control
@export var firstFocus_rebinding : Control
var assigningFocus = false
var lastScreen = "main"
var currentScreen = "main"
func Show(what : String):
lastScreen = currentScreen
currentScreen = what
var focus
title.visible = false
for screen in screens: screen.visible = false
if (what == "main" or what == "sub options"): title.visible = true
match(what):
"main":
parent_main.visible = true
focus = firstFocus_main
"sub options":
parent_suboptions.visible = true
focus = firstFocus_subOptions
"credits":
parent_creds.visible = true
focus = firstFocus_credits
anim_creds.play("RESET")
anim_creds.play("show credits")
"audio video":
parent_audiovideo.visible = true
focus = firstFocus_audioVideo
"language":
parent_language.visible = true
focus = firstFocus_language
"controller":
parent_controller.visible = true
focus = firstFocus_controller
"rebind controls":
parent_rebinding.visible = true
focus = firstFocus_rebinding
if (assigningFocus):
if (cursor.controller_active): focus.grab_focus()
controller.previousFocus = focus
func ReturnToLastScreen():
print("return to last screen")
if currentScreen == "credits": anim_creds.play("RESET")
if (currentScreen) == "sub options": lastScreen = "main"
if (currentScreen) == "rebind controls": lastScreen = "sub options"
if (currentScreen == "audio video" or currentScreen == "language" or currentScreen == "controller" or currentScreen == "rebind controls"): optionmanager.SaveSettings()
Show(lastScreen)
ResetButtons()
func ResetButtons():
#for b in buttons:
# b.ui.modulate.a = 1
cursor.SetCursorImage("point")
func Start():
Buttons(false)
ResetButtons()
for screen in screens: screen.visible = false
title.visible = false
controller.previousFocus = null
speaker_music.stop()
animator_intro.play("snap")
for w in waterfalls: w.pause()
speaker_start.play()
cursor.SetCursor(false, false)
savefile.ClearSave()
await get_tree().create_timer(4, false).timeout
print("changing scene to: main")
get_tree().change_scene_to_file("res://scenes/main.tscn")
func StartMultiplayer():
if !GlobalSteam.ONLINE:
GlobalVariables.message_to_forward = tr("MP_UI LOBBY NO CONNECTION")
GlobalVariables.returning_to_main_menu_on_popup_close = true
GlobalVariables.running_short_intro_in_lobby_scene = true
Buttons(false)
ResetButtons()
for screen in screens: screen.visible = false
title.visible = false
controller.previousFocus = null
speaker_music.stop()
animator_intro.play("snap")
for w in waterfalls: w.pause()
speaker_start.play()
cursor.SetCursor(false, false)
savefile.ClearSave()
await get_tree().create_timer(4, false).timeout
print("changing scene to: lobby")
get_tree().change_scene_to_file("res://multiplayer/scenes/mp_lobby.tscn")
func Credits():
Show("credits")
ResetButtons()
func Exit():
Buttons(false)
ResetButtons()
speaker_music.stop()
animator_intro.play("snap2")
cursor.SetCursor(false, false)
await get_tree().create_timer(.5, false).timeout
get_tree().quit()
func DisableMenu():
Buttons(false)
ResetButtons()
speaker_music.stop()
animator_intro.play("snap2")
cursor.SetCursor(false, false)
func ResetControls():
optionmanager.ResetControls()
ResetButtons()
func ToggleMusic():
optionmanager.AdjustSettings_music()
func ToggleColorblind():
optionmanager.ToggleColorblind()
func ToggleGreyscaleDeath():
optionmanager.ToggleGreyscaleDeath()
func DiscordLink():
OS.shell_open(GlobalVariables.discord_link)
func RebindControls():
Show("rebind controls")
ResetButtons()
func SubOptions():
Show("sub options")
ResetButtons()
func Options_AudioVideo():
Show("audio video")
ResetButtons()
func Options_Language():
Show("language")
ResetButtons()
func Options_Controller():
Show("controller")
ResetButtons()
pass
func IncreaseVol():
optionmanager.Adjust("increase")
func DecreaseVol():
optionmanager.Adjust("decrease")
func SetWindowed():
optionmanager.Adjust("windowed")
func SetFull():
optionmanager.Adjust("fullscreen")
func ControllerEnable():
optionmanager.Adjust("controller enable")
func ControllerDisable():
optionmanager.Adjust("controller disable")