Added keyboard control to main menu. Reworked logic
This commit is contained in:
@@ -3,5 +3,9 @@ extends Node
|
||||
signal show_main_menu
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$%MainMenuButton.grab_focus()
|
||||
|
||||
|
||||
func _on_main_menu_button_pressed() -> void:
|
||||
show_main_menu.emit()
|
||||
|
||||
+9
-1
@@ -1,7 +1,13 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c3q3g2647qc27"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c3q3g2647qc27"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dclkpithyykju" path="res://menu/credits.gd" id="1_wp78b"]
|
||||
|
||||
[sub_resource type="InputEventAction" id="InputEventAction_wp78b"]
|
||||
action = &"ui_cancel"
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_nidem"]
|
||||
events = [SubResource("InputEventAction_wp78b")]
|
||||
|
||||
[node name="Credits" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
@@ -32,7 +38,9 @@ layout_mode = 2
|
||||
alignment = 2
|
||||
|
||||
[node name="MainMenuButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
shortcut = SubResource("Shortcut_nidem")
|
||||
text = "Main Menu"
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/MainMenuButton" to="." method="_on_main_menu_button_pressed"]
|
||||
|
||||
@@ -5,6 +5,28 @@ signal new_game
|
||||
signal quit_game
|
||||
signal show_options
|
||||
|
||||
func _ready() -> void:
|
||||
_init_focus()
|
||||
_setup_neighbors()
|
||||
|
||||
|
||||
func _init_focus() -> void:
|
||||
if $%ContinueButton.disabled:
|
||||
$%StartButton.grab_focus()
|
||||
else:
|
||||
$%ContinueButton.grab_focus()
|
||||
|
||||
|
||||
func _setup_neighbors() -> void:
|
||||
if $%ContinueButton.disabled:
|
||||
$%ContinueButton.focus_neighbor_top = ""
|
||||
$%StartButton.focus_neighbor_top = $%QuitButton.get_path()
|
||||
$%QuitButton.focus_neighbor_bottom = $%StartButton.get_path()
|
||||
else:
|
||||
$%ContinueButton.focus_neighbor_top = $%QuitButton.get_path()
|
||||
$%StartButton.focus_neighbor_top = ""
|
||||
$%QuitButton.focus_neighbor_bottom = $%ContinueButton.get_path()
|
||||
|
||||
|
||||
func _on_continue_button_pressed() -> void:
|
||||
continue_game.emit()
|
||||
|
||||
@@ -15,19 +15,23 @@ offset_right = 179.0
|
||||
offset_bottom = 236.0
|
||||
|
||||
[node name="ContinueButton" type="Button" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Continue"
|
||||
|
||||
[node name="StartButton" type="Button" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Start"
|
||||
|
||||
[node name="OptionsButton" type="Button" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Options"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Quit"
|
||||
|
||||
|
||||
+14
-6
@@ -3,22 +3,30 @@ extends Node
|
||||
signal show_credits
|
||||
signal show_main_menu
|
||||
|
||||
@onready var fullscreen_check := $%FullscreenCheckButton
|
||||
@onready var window_factor := $%WindowFactorOptionButton
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_load_current_settings()
|
||||
_init_focus()
|
||||
_setup_neighbors()
|
||||
|
||||
|
||||
func _init_focus() -> void:
|
||||
$%FullscreenCheckButton.grab_focus()
|
||||
|
||||
|
||||
func _setup_neighbors() -> void:
|
||||
$%CreditsButton.focus_neighbor_left = $%BackButton.get_path()
|
||||
$%BackButton.focus_neighbor_right = $%CreditsButton.get_path()
|
||||
|
||||
|
||||
func _load_current_settings() -> void:
|
||||
fullscreen_check.button_pressed = SettingsManager.fullscreen()
|
||||
window_factor.selected = SettingsManager.window_factor()
|
||||
$%FullscreenCheckButton.button_pressed = SettingsManager.fullscreen()
|
||||
$%WindowFactorOptionButton.selected = SettingsManager.window_factor()
|
||||
_update_window_factor_disabled()
|
||||
|
||||
|
||||
func _update_window_factor_disabled() -> void:
|
||||
window_factor.disabled = SettingsManager.fullscreen()
|
||||
$%WindowFactorOptionButton.disabled = SettingsManager.fullscreen()
|
||||
|
||||
|
||||
func _on_fullscreen_check_button_toggled(toggled: bool) -> void:
|
||||
|
||||
+12
-1
@@ -1,7 +1,13 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://btr60idiit4y7"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://btr60idiit4y7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ceng1u112aqg0" path="res://menu/options.gd" id="1_61pji"]
|
||||
|
||||
[sub_resource type="InputEventAction" id="InputEventAction_61pji"]
|
||||
action = &"ui_cancel"
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_1tdpy"]
|
||||
events = [SubResource("InputEventAction_61pji")]
|
||||
|
||||
[node name="Options" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
@@ -20,6 +26,7 @@ layout_mode = 2
|
||||
columns = 2
|
||||
|
||||
[node name="FullscreenLabel" type="Label" parent="VBoxContainer/OptionsGridContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Fullscreen"
|
||||
|
||||
@@ -28,6 +35,7 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="WindowFactorLabel" type="Label" parent="VBoxContainer/OptionsGridContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Window Factor"
|
||||
|
||||
@@ -54,11 +62,14 @@ layout_mode = 2
|
||||
alignment = 2
|
||||
|
||||
[node name="CreditsButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Credits"
|
||||
|
||||
[node name="BackButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
shortcut = SubResource("Shortcut_1tdpy")
|
||||
text = "Back"
|
||||
|
||||
[connection signal="toggled" from="VBoxContainer/OptionsGridContainer/FullscreenCheckButton" to="." method="_on_fullscreen_check_button_toggled"]
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
class_name PauseMenu
|
||||
|
||||
extends Node
|
||||
|
||||
signal continue_game
|
||||
signal show_main_menu
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_init_focus()
|
||||
_setup_neighbors()
|
||||
|
||||
|
||||
func _init_focus() -> void:
|
||||
$%ContinueButton.grab_focus()
|
||||
|
||||
|
||||
func _setup_neighbors() -> void:
|
||||
$%ContinueButton.focus_neighbor_top = $%MainMenuButton.get_path()
|
||||
$%MainMenuButton.focus_neighbor_bottom = $%ContinueButton.get_path()
|
||||
|
||||
|
||||
func _on_continue_button_pressed() -> void:
|
||||
continue_game.emit()
|
||||
|
||||
|
||||
+13
-1
@@ -1,7 +1,16 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bclo2wl8ibrcg"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://bclo2wl8ibrcg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://npqs2m5g5bd6" path="res://menu/pause_menu.gd" id="1_inj1j"]
|
||||
|
||||
[sub_resource type="InputEventAction" id="InputEventAction_inj1j"]
|
||||
action = &"ui_cancel"
|
||||
|
||||
[sub_resource type="InputEventAction" id="InputEventAction_vy7sn"]
|
||||
action = &"pause"
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_lgp46"]
|
||||
events = [SubResource("InputEventAction_inj1j"), SubResource("InputEventAction_vy7sn")]
|
||||
|
||||
[node name="PauseMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
@@ -15,10 +24,13 @@ offset_right = 196.0
|
||||
offset_bottom = 166.0
|
||||
|
||||
[node name="ContinueButton" type="Button" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
shortcut = SubResource("Shortcut_lgp46")
|
||||
text = "Continue"
|
||||
|
||||
[node name="MainMenuButton" type="Button" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Main Menu"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user