1 | extends Control
|
---|
2 |
|
---|
3 | var start_menu
|
---|
4 | var level_select_menu
|
---|
5 | var options_menu
|
---|
6 | var keybind_menu
|
---|
7 | onready var keybind_button_container = get_node("Keybinds_Menu/Keybind_Container")
|
---|
8 | var keybinds
|
---|
9 |
|
---|
10 | export (String, FILE) var testing_area_scene
|
---|
11 |
|
---|
12 |
|
---|
13 | func _ready():
|
---|
14 | start_menu = $Start_Menu
|
---|
15 | level_select_menu = $Level_Select_Menu
|
---|
16 | options_menu = $Options_Menu
|
---|
17 | keybind_menu = $Keybind_Menu
|
---|
18 |
|
---|
19 | # Connect all of the start menu buttons
|
---|
20 | $Start_Menu/Button_Start.connect("pressed", self, "start_menu_button_pressed", ["start"])
|
---|
21 | $Start_Menu/Button_Open_Godot.connect("pressed", self, "start_menu_button_pressed", ["open_godot"])
|
---|
22 | $Start_Menu/Button_Options.connect("pressed", self, "start_menu_button_pressed", ["options"])
|
---|
23 | $Start_Menu/Button_Quit.connect("pressed", self, "start_menu_button_pressed", ["quit"])
|
---|
24 |
|
---|
25 | # Connect all of the options menu buttons
|
---|
26 | $Options_Menu/Button_Back.connect("pressed", self, "options_menu_button_pressed", ["back"])
|
---|
27 | $Options_Menu/Button_Fullscreen.connect("pressed", self, "options_menu_button_pressed", ["fullscreen"])
|
---|
28 | $Options_Menu/Check_Button_VSync.connect("pressed", self, "options_menu_button_pressed", ["vsync"])
|
---|
29 | $Options_Menu/Check_Button_Debug.connect("pressed", self, "options_menu_button_pressed", ["debug"])
|
---|
30 | $Options_Menu/Button_Keybind.connect("pressed", self, "keybind_menu_button_pressed", ["keybind"])
|
---|
31 |
|
---|
32 | # Connect all the Keybind menu buttoms
|
---|
33 | # $Keybind_Menu/Button_Move_Forward.connect("pressed", self, "keybind_menu_button_pressed", ["back"])
|
---|
34 |
|
---|
35 | # Some times when returning to the title screen the mouse is still captured even though it shouldn't be.
|
---|
36 | # To prevent this from breaking the game, we just set it here too
|
---|
37 | Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
---|
38 |
|
---|
39 | # Get the globals singleton
|
---|
40 | var globals = get_node("/root/Globals")
|
---|
41 | # Get the mouse and joypad sensitivity
|
---|
42 | $Options_Menu/HSlider_Mouse_Sensitivity.value = globals.mouse_sensitivity
|
---|
43 | # $Options_Menu/HSlider_Joypad_Sensitivity.value = globals.joypad_sensitivity
|
---|
44 |
|
---|
45 | func start_menu_button_pressed(button_name):
|
---|
46 | if button_name == "start":
|
---|
47 | get_node("/root/Globals").load_new_scene(testing_area_scene)
|
---|
48 | # level_select_menu.visible = true
|
---|
49 | # start_menu.visible = false
|
---|
50 | elif button_name == "open_godot":
|
---|
51 | OS.shell_open("https://gauss.extollit.com/revenant/project/")
|
---|
52 | elif button_name == "options":
|
---|
53 | options_menu.visible = true
|
---|
54 | start_menu.visible = false
|
---|
55 | elif button_name == "quit":
|
---|
56 | get_tree().quit()
|
---|
57 |
|
---|
58 | func options_menu_button_pressed(button_name):
|
---|
59 | if button_name == "back":
|
---|
60 | start_menu.visible = true
|
---|
61 | options_menu.visible = false
|
---|
62 | keybind_menu.visible = false
|
---|
63 | elif button_name == "fullscreen":
|
---|
64 | OS.window_fullscreen = !OS.window_fullscreen
|
---|
65 | elif button_name == "keybind":
|
---|
66 | keybind_menu.visible = true
|
---|
67 | elif button_name == "vsync":
|
---|
68 | OS.vsync_enabled = $Options_Menu/Check_Button_VSync.pressed
|
---|
69 | elif button_name == "debug":
|
---|
70 | get_node("/root/Globals").set_debug_display($Options_Menu/Check_Button_Debug.pressed)
|
---|
71 |
|
---|
72 | func keybind_menu_button_pressed(button_name):
|
---|
73 | if button_name == "back":
|
---|
74 | start_menu.visible = true
|
---|
75 | options_menu.visible = false
|
---|
76 | elif button_name == "fullscreen":
|
---|
77 | OS.window_fullscreen = !OS.window_fullscreen
|
---|
78 | elif button_name == "vsync":
|
---|
79 | OS.vsync_enabled = $Options_Menu/Check_Button_VSync.pressed
|
---|
80 | elif button_name == "debug":
|
---|
81 | get_node("/root/Globals").set_debug_display($Options_Menu/Check_Button_Debug.pressed)
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 | func set_mouse_and_joypad_sensitivity():
|
---|
86 | # Get the globals singleton
|
---|
87 | var globals = get_node("/root/Globals")
|
---|
88 | # Set the mouse and joypad sensitivity
|
---|
89 | globals.mouse_sensitivity = $Options_Menu/HSlider_Mouse_Sensitivity.value
|
---|