add new options screen to main menu and pause screen

This commit is contained in:
Haze Weathers 2024-02-27 20:57:14 -05:00
parent 9333d5a61f
commit 24f763d3f6
10 changed files with 94 additions and 7 deletions

View file

@ -44,3 +44,9 @@ func _on_HighScores_button_down() -> void:
Fade.fade_out(Options.transition_speed_secs)
yield(Fade, "fade_finished")
SceneManager.current_scene = load("res://menus/scoreboards.tscn").instance()
func _on_Options_button_down() -> void:
Fade.fade_out(Options.transition_speed_secs)
yield(Fade, "fade_finished")
SceneManager.current_scene = load("res://menus/options_menu.tscn").instance()

View file

@ -249,6 +249,8 @@ align = 1
[connection signal="focus_entered" from="Panel/FileSelect" to="MenuSounds" method="play_select_sound"]
[connection signal="focus_entered" from="Panel/MarathonMode" to="MenuSounds" method="play_select_sound"]
[connection signal="focus_entered" from="Panel/Augmentations" to="MenuSounds" method="play_select_sound"]
[connection signal="button_down" from="Panel/Options" to="." method="_on_Options_button_down"]
[connection signal="button_down" from="Panel/Options" to="MenuSounds" method="play_confirm_sound"]
[connection signal="focus_entered" from="Panel/Options" to="MenuSounds" method="play_select_sound"]
[connection signal="button_down" from="Panel/HighScores" to="." method="_on_HighScores_button_down"]
[connection signal="button_down" from="Panel/HighScores" to="MenuSounds" method="play_confirm_sound"]

14
menus/options_menu.gd Normal file
View file

@ -0,0 +1,14 @@
extends Control
func _ready() -> void:
Fade.fade_in(Options.transition_speed_secs)
yield(Fade, "fade_finished")
$OptionsScreen.focus()
func _on_OptionsScreen_exit() -> void:
Fade.fade_out(Options.transition_speed_secs)
yield(Fade, "fade_finished")
SceneManager.current_scene = load("res://menus/main_menu.tscn").instance()

29
menus/options_menu.tscn Normal file
View file

@ -0,0 +1,29 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://objects/hud/options_screen_scholar.tscn" type="PackedScene" id=1]
[ext_resource path="res://shaders/ska_plane.gdshader" type="Shader" id=2]
[ext_resource path="res://menus/options_menu.gd" type="Script" id=3]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 2 )
shader_param/color_1 = Color( 1, 0.709804, 0.984314, 1 )
shader_param/color_2 = Color( 1, 0.423529, 0.4, 1 )
shader_param/checker_size = Vector2( 12, 12 )
shader_param/pan_speed = Vector2( 0, 16 )
shader_param/cycle_speed = Vector2( 4, -4 )
shader_param/cycle_alternation = Vector2( 2, 0 )
shader_param/uv_transform = Transform2D( 1, 1, 0, 1, 0, 0 )
[node name="OptionsMenu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
[node name="ColorRect" type="ColorRect" parent="."]
material = SubResource( 1 )
anchor_right = 1.0
anchor_bottom = 1.0
[node name="OptionsScreen" parent="." instance=ExtResource( 1 )]
[connection signal="exit" from="OptionsScreen" to="." method="_on_OptionsScreen_exit"]

View file

@ -1,6 +1,13 @@
extends Control
signal exit
# if true, options screen can not exit
var can_exit: bool = true
onready var tabs: TabContainer = $"%Tabs"
onready var select_tab: HBoxContainer = $"%SelectTab"
# options nodes
@ -18,15 +25,22 @@ onready var sound_vol: HSlider = $"%SelectSoundVol"
onready var landing_sound: HBoxContainer = $"%SelectLandingSound"
func _ready() -> void:
get_scene_instance_load_placeholder()
_init_values()
yield(get_tree(), "idle_frame")
func focus() -> void:
select_tab.selection = 0
$"%SelectTab".grab_focus()
_on_tab_selected(0)
func _input(event: InputEvent) -> void:
func _unhandled_input(event: InputEvent) -> void:
Options.save_options()
if can_exit and event.is_action_pressed("ui_cancel"):
emit_signal("exit")
func _init_values() -> void:
@ -46,6 +60,7 @@ func _init_values() -> void:
sound_vol.value = Options.sound_volume * 100.0
landing_sound.selection = 1 if Options.landing_sound else 0
func _on_tab_selected(selection: int) -> void:
tabs.current_tab = selection
var tab = tabs.get_current_tab_control()

View file

@ -501,6 +501,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 8 )
action = "move_left"
options_screen = NodePath("../../../../../../../..")
[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Left"]
margin_left = 159.0
@ -510,6 +511,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 9 )
action = "move_left"
options_screen = NodePath("../../../../../../../..")
[node name="Right" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"]
margin_top = 30.0
@ -531,6 +533,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 8 )
action = "move_right"
options_screen = NodePath("../../../../../../../..")
[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Right"]
margin_left = 159.0
@ -540,6 +543,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 9 )
action = "move_right"
options_screen = NodePath("../../../../../../../..")
[node name="Up" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"]
margin_top = 44.0
@ -561,6 +565,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 8 )
action = "move_up"
options_screen = NodePath("../../../../../../../..")
[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Up"]
margin_left = 159.0
@ -570,6 +575,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 9 )
action = "move_up"
options_screen = NodePath("../../../../../../../..")
[node name="Down" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"]
margin_top = 58.0
@ -591,6 +597,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 8 )
action = "move_down"
options_screen = NodePath("../../../../../../../..")
[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Down"]
margin_left = 159.0
@ -600,6 +607,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 9 )
action = "move_down"
options_screen = NodePath("../../../../../../../..")
[node name="Jump" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"]
margin_top = 72.0
@ -621,6 +629,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 8 )
action = "jump"
options_screen = NodePath("../../../../../../../..")
[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Jump"]
margin_left = 159.0
@ -630,6 +639,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 9 )
action = "jump"
options_screen = NodePath("../../../../../../../..")
[node name="Attack" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"]
margin_top = 86.0
@ -651,6 +661,7 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 8 )
action = "shoot"
options_screen = NodePath("../../../../../../../..")
[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Attack"]
margin_left = 159.0
@ -660,12 +671,13 @@ size_flags_horizontal = 3
text = "-"
script = ExtResource( 9 )
action = "shoot"
options_screen = NodePath("../../../../../../../..")
[node name="DefaultControls" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer"]
[node name="DefaultControls" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"]
margin_left = 81.0
margin_top = 68.0
margin_top = 32.0
margin_right = 137.0
margin_bottom = 78.0
margin_bottom = 42.0
size_flags_horizontal = 4
text = "defaults"

View file

@ -58,6 +58,7 @@ func _on_Restart_pressed():
func _on_Settings_pressed():
$LoreContainer.visible = false
options_screen.visible = true
can_switch_lore = false
options_screen.focus()

View file

@ -6,7 +6,7 @@
[ext_resource path="res://objects/hud/pause_screen.gd" type="Script" id=4]
[ext_resource path="res://ui/2ndpuberty_no_dropshadow.tres" type="Theme" id=5]
[ext_resource path="res://ui/2ndpuberty_outline.tres" type="Material" id=6]
[ext_resource path="res://objects/hud/options_screen.tscn" type="PackedScene" id=7]
[ext_resource path="res://objects/hud/options_screen_scholar.tscn" type="PackedScene" id=7]
[ext_resource path="res://ui/border.png" type="Texture" id=8]
[ext_resource path="res://objects/hud/menu_sounds.tscn" type="PackedScene" id=9]

View file

@ -5,6 +5,7 @@ const BLINK_SPEED: int = 150
export var action: String
export var options_screen: NodePath
var listen := false
@ -36,6 +37,7 @@ func _on_pressed() -> void:
listen = true
disabled = true
text = ""
get_node(options_screen).can_exit = false
get_tree().create_timer(2.0, true).connect("timeout", self, "_on_timeout")
@ -43,6 +45,7 @@ func _on_timeout() -> void:
listen = false
disabled = false
_update_text()
get_node(options_screen).set_deferred("can_exit", true)
func _gui_input(event: InputEvent) -> void:
@ -50,6 +53,7 @@ func _gui_input(event: InputEvent) -> void:
if event is InputEventJoypadButton and event.pressed:
Controls.set_button(action, event.button_index)
listen = false
get_node(options_screen).set_deferred("can_exit", true)
set_deferred("disabled", false)
_update_text()
accept_event()

View file

@ -5,6 +5,7 @@ const BLINK_SPEED: int = 150
export var action: String
export var options_screen: NodePath
var listen := false
@ -36,6 +37,7 @@ func _on_pressed() -> void:
listen = true
disabled = true
text = ""
get_node(options_screen).can_exit = false
get_tree().create_timer(2.0, true).connect("timeout", self, "_on_timeout")
@ -43,6 +45,7 @@ func _on_timeout() -> void:
listen = false
disabled = false
_update_text()
get_node(options_screen).set_deferred("can_exit", true)
func _gui_input(event: InputEvent) -> void:
@ -50,6 +53,7 @@ func _gui_input(event: InputEvent) -> void:
if event is InputEventKey and event.pressed:
Controls.set_key(action, event.physical_scancode)
listen = false
get_node(options_screen).set_deferred("can_exit", true)
set_deferred("disabled", false)
_update_text()
accept_event()