Add game tab to options menu, fix focus of GUI elements, add Delete option for save file

This commit is contained in:
2025-11-18 20:28:43 -08:00
parent 0afbf38bf9
commit f69e219643
14 changed files with 211 additions and 62 deletions

View File

@@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.4.1">
<Project Sdk="Godot.NET.Sdk/4.4.0">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>

View File

@@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.4.0">
<Project Sdk="Godot.NET.Sdk/4.4.1">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>

View File

@@ -82,6 +82,7 @@ public partial class App : Node, IApp
_loadedScene.Changed += OnGameLoaded;
OptionsMenu.OptionsMenuExited += OptionsMenu_OptionsMenuExited;
OptionsMenu.DeleteSaveData += DeleteSaveData;
AppRepo = _container.GetInstance<IAppRepo>();
AppLogic = _container.GetInstance<IAppLogic>();
@@ -94,6 +95,12 @@ public partial class App : Node, IApp
this.Provide();
}
private void DeleteSaveData()
{
var saveFileManager = _container.GetInstance<ISaveFileManager>();
saveFileManager.DeleteSaveData();
}
private async void OptionsMenu_OptionsMenuExited()
{
var saveFileManager = _container.GetInstance<ISaveFileManager>();

View File

@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://ddii3pi8x75xc"
path="res://.godot/imported/amb_beach.wav-e64adf8f733e6a108ae15edd5f0499ab.sample"
path="res://.godot/imported/amb_beach.wav-046e4f838e50e43a1aba1a754b92aad6.sample"
[deps]
source_file="res://src/audio/amb/amb_beach.wav"
dest_files=["res://.godot/imported/amb_beach.wav-e64adf8f733e6a108ae15edd5f0499ab.sample"]
source_file="res://src/audio/AMB/amb_beach.wav"
dest_files=["res://.godot/imported/amb_beach.wav-046e4f838e50e43a1aba1a754b92aad6.sample"]
[params]

View File

@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://ym4ur8a2qxhp"
path="res://.godot/imported/amb_perlin.wav-dea63667b2a56d37d48ba209f56f8900.sample"
path="res://.godot/imported/amb_perlin.wav-ba6da0d5591f392e4aca7d2f85c4dfc2.sample"
[deps]
source_file="res://src/audio/amb/amb_perlin.wav"
dest_files=["res://.godot/imported/amb_perlin.wav-dea63667b2a56d37d48ba209f56f8900.sample"]
source_file="res://src/audio/AMB/amb_perlin.wav"
dest_files=["res://.godot/imported/amb_perlin.wav-ba6da0d5591f392e4aca7d2f85c4dfc2.sample"]
[params]

View File

@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://b7wxddjx3qw5o"
path="res://.godot/imported/amb_white_noise.wav-c98b45aa94120bc0c660bf2d6af1c696.sample"
path="res://.godot/imported/amb_white_noise.wav-d316dd05afe429f6bcdda594285ad718.sample"
[deps]
source_file="res://src/audio/amb/amb_white_noise.wav"
dest_files=["res://.godot/imported/amb_white_noise.wav-c98b45aa94120bc0c660bf2d6af1c696.sample"]
source_file="res://src/audio/AMB/amb_white_noise.wav"
dest_files=["res://.godot/imported/amb_white_noise.wav-d316dd05afe429f6bcdda594285ad718.sample"]
[params]

View File

@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://bmiitw4fcs68e"
path="res://.godot/imported/amb_wind_loop_altar.wav-b9d60e3c3c10ec00833903539a7f3796.sample"
path="res://.godot/imported/amb_wind_loop_altar.wav-e766e3db29faa01ad6dbaa8cb18d7de6.sample"
[deps]
source_file="res://src/audio/amb/amb_wind_loop_altar.wav"
dest_files=["res://.godot/imported/amb_wind_loop_altar.wav-b9d60e3c3c10ec00833903539a7f3796.sample"]
source_file="res://src/audio/AMB/amb_wind_loop_altar.wav"
dest_files=["res://.godot/imported/amb_wind_loop_altar.wav-e766e3db29faa01ad6dbaa8cb18d7de6.sample"]
[params]

View File

@@ -4,12 +4,12 @@ importer="scene"
importer_version=1
type="PackedScene"
uid="uid://dh8ji8g36mmx5"
path="res://.godot/imported/a2-puer.glb-20bdcd533f2a6024a2fa1d9a726cae55.scn"
path="res://.godot/imported/A2-Puer.glb-3b11ccd8f9ba6f91fbb05537c52490b0.scn"
[deps]
source_file="res://src/map/dungeon/models/Area 2/Puer/a2-puer.glb"
dest_files=["res://.godot/imported/a2-puer.glb-20bdcd533f2a6024a2fa1d9a726cae55.scn"]
source_file="res://src/map/dungeon/models/Area 2/Puer/A2-Puer.glb"
dest_files=["res://.godot/imported/A2-Puer.glb-3b11ccd8f9ba6f91fbb05537c52490b0.scn"]
[params]

View File

@@ -28,7 +28,7 @@ theme_override_constants/margin_bottom = 25
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
theme_override_constants/separation = 3
theme_override_constants/separation = 20
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
@@ -39,7 +39,7 @@ unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/separation = 10
theme_override_constants/separation = 20
[node name="Header" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
layout_mode = 2
@@ -172,7 +172,7 @@ size_flags_horizontal = 3
[node name="MoveBackwardKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Backward"]
unique_name_in_owner = true
custom_minimum_size = Vector2(200, 0)
custom_minimum_size = Vector2(200, 35)
layout_mode = 2
script = ExtResource("2_fmxfy")
@@ -201,7 +201,7 @@ size_flags_horizontal = 3
[node name="StrafeLeftKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Left"]
unique_name_in_owner = true
custom_minimum_size = Vector2(200, 0)
custom_minimum_size = Vector2(200, 35)
layout_mode = 2
script = ExtResource("2_fmxfy")
@@ -230,7 +230,7 @@ size_flags_horizontal = 3
[node name="StrafeRightKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Right"]
unique_name_in_owner = true
custom_minimum_size = Vector2(200, 0)
custom_minimum_size = Vector2(200, 35)
layout_mode = 2
script = ExtResource("2_fmxfy")

View File

@@ -19,10 +19,16 @@ public partial class OptionsMenu : Control
[Node] public InputMapper Controller { get; set; }
[Node] public TabContainer TabContainer { get; set; }
[Node] public Label PressToGoBackLabel { get; set; }
[Node] public CheckBox SkipOpeningCSCheck { get; set; }
[Node] public Button DeleteSaveButton { get; set; }
[Node] public CanvasLayer CanvasLayer { get; set; }
[Node] public Control ConfirmDeletePopup { get; set; }
[Node] public Button YesDeleteButton { get; set; }
[Node] public Button NoDeleteButton { get; set; }
public OptionsData OptionsData;
private int _masterBusIndex;
@@ -32,6 +38,7 @@ public partial class OptionsMenu : Control
private readonly DisplayServer.WindowMode[] _windowModes = [DisplayServer.WindowMode.Windowed, DisplayServer.WindowMode.Maximized, DisplayServer.WindowMode.Fullscreen, DisplayServer.WindowMode.ExclusiveFullscreen];
[Signal] public delegate void OptionsMenuExitedEventHandler();
[Signal] public delegate void DeleteSaveDataEventHandler();
public void OnReady()
{
@@ -48,6 +55,11 @@ public partial class OptionsMenu : Control
SFXVolumeLevel = SFXVolumeSlider.Value,
ScreenResolution = ResolutionOptions.GetSelectedId()
};
DeleteSaveButton.Pressed += DeleteSaveButton_Pressed;
YesDeleteButton.Pressed += YesDeleteButton_Pressed;
NoDeleteButton.Pressed += NoDeleteButton_Pressed;
MasterVolumeSlider.ValueChanged += MasterVolumeSlider_Changed;
MusicVolumeSlider.ValueChanged += MusicVolumeSlider_Changed;
SFXVolumeSlider.ValueChanged += SFXVolumeSlider_Changed;
@@ -55,43 +67,51 @@ public partial class OptionsMenu : Control
ResolutionOptions.ItemSelected += ResolutionOptions_ItemSelected;
TabContainer.TabChanged += TabContainer_TabChanged;
TabContainer.TabSelected += TabContainer_TabChanged;
_masterBusIndex = AudioServer.GetBusIndex("Master");
_musicBusIndex = AudioServer.GetBusIndex("MUSIC");
_sfxBusIndex = AudioServer.GetBusIndex("SFX");
VisibilityChanged += OptionsMenu_VisibilityChanged;
}
InputHelper.JoypadInputChanged += (string action, InputEvent input) =>
{
if (GameInputs.Interact == action)
{
var interactInputs = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.Interact));
PressToGoBackLabel.Text = $"Press {interactInputs} to save and exit.";
}
};
private void NoDeleteButton_Pressed()
{
ReleaseFocus();
ConfirmDeletePopup.Hide();
DeleteSaveButton.GrabFocus();
}
InputHelper.KeyboardInputChanged += (string action, InputEvent input) =>
{
if (GameInputs.Interact == action)
{
var interactInputs = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.Interact));
PressToGoBackLabel.Text = $"Press {interactInputs} to save and exit.";
}
};
private void YesDeleteButton_Pressed()
{
EmitSignal(SignalName.DeleteSaveData);
ReleaseFocus();
ConfirmDeletePopup.Hide();
DeleteSaveButton.GrabFocus();
}
private void DeleteSaveButton_Pressed()
{
NoDeleteButton.GrabFocus();
ConfirmDeletePopup.Show();
}
private void TabContainer_TabChanged(long tab)
{
if (tab == 0)
MasterVolumeSlider.GrabFocus();
if (tab == 1)
Controller.MoveForwardKeyboard.GrabFocus();
if (tab == (int)TabOption.Game)
SkipOpeningCSCheck.CallDeferred(MethodName.GrabFocus);
if (tab == (int)TabOption.Audio)
MasterVolumeSlider.CallDeferred(MethodName.GrabFocus);
if (tab == (int)TabOption.Controls)
Controller.MoveForwardKeyboard.CallDeferred(MethodName.GrabFocus);
}
private void OptionsMenu_VisibilityChanged()
{
CanvasLayer.Visible = !CanvasLayer.Visible;
if (CanvasLayer.Visible)
TabContainer_TabChanged(TabContainer.CurrentTab);
}
public override void _Input(InputEvent @event)
@@ -99,22 +119,19 @@ public partial class OptionsMenu : Control
if (!Visible)
return;
var interactInputs = InputHelper.GetKeyboardOrJoypadInputsForAction(GameInputs.Interact);
if (interactInputs.Any(x => x.IsMatch(@event)))
if (Input.IsActionJustPressed(GameInputs.Interact))
{
AcceptEvent();
SaveAndExitMenu();
}
var leftTab = InputHelper.GetKeyboardOrJoypadInputsForAction(GameInputs.StrafeLeft);
if (leftTab.Any(x => x.IsMatch(@event)))
if (Input.IsActionJustPressed(GameInputs.StrafeLeft))
{
AcceptEvent();
TabContainer.CurrentTab = Mathf.Max(0, TabContainer.CurrentTab - 1);
}
var rightTab = InputHelper.GetKeyboardOrJoypadInputsForAction(GameInputs.StrafeRight);
if (rightTab.Any(x => x.IsMatch(@event)))
if (Input.IsActionJustPressed(GameInputs.StrafeRight))
{
AcceptEvent();
TabContainer.CurrentTab = Mathf.Min(TabContainer.GetTabCount() - 1, TabContainer.CurrentTab + 1);
@@ -156,4 +173,11 @@ public partial class OptionsMenu : Control
OptionsData.SFXVolumeLevel = valueChanged;
AudioServer.SetBusVolumeDb(_sfxBusIndex, Mathf.LinearToDb((float)valueChanged));
}
}
public enum TabOption
{
Game,
Audio,
Controls
}

View File

@@ -1,8 +1,16 @@
[gd_scene load_steps=7 format=3 uid="uid://drkl3btdy6uxj"]
[gd_scene load_steps=11 format=3 uid="uid://drkl3btdy6uxj"]
[ext_resource type="Script" uid="uid://cjxmdvhixcj6e" path="res://src/options/OptionsMenu.cs" id="1_jli36"]
[ext_resource type="Shortcut" uid="uid://dumkrjur22k2a" path="res://src/ui/ButtonShortcut.tres" id="2_1egkf"]
[ext_resource type="LabelSettings" uid="uid://cuuo43x72xcsc" path="res://src/ui/label_settings/MainTextBold.tres" id="2_o7aaw"]
[ext_resource type="PackedScene" uid="uid://dk5esf6mm6kte" path="res://src/options/InputMapper.tscn" id="2_utd4g"]
[ext_resource type="FontFile" uid="uid://cm8j5vcdop5x0" path="res://src/ui/fonts/Mrs-Eaves-OT-Roman_31443.ttf" id="3_ohii5"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ohii5"]
bg_color = Color(0.215902, 0.215902, 0.215902, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_o7aaw"]
bg_color = Color(0.215686, 0.215686, 0.215686, 1)
[sub_resource type="StyleBoxLine" id="StyleBoxLine_jli36"]
@@ -41,18 +49,123 @@ custom_minimum_size = Vector2(1280, 960)
layout_mode = 2
current_tab = 0
[node name="Audio" type="MarginContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer"]
[node name="Game" type="PanelContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer"]
layout_mode = 2
focus_next = NodePath("../Audio")
focus_previous = NodePath(".")
metadata/_tab_index = 0
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game"]
layout_mode = 2
theme_override_constants/margin_left = 100
theme_override_constants/margin_top = 100
theme_override_constants/margin_right = 0
theme_override_constants/margin_bottom = 0
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/MarginContainer"]
layout_mode = 2
theme_override_constants/separation = 20
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="SkipOpeningCSCheck" type="CheckBox" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/MarginContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 35)
layout_mode = 2
text = "Skip opening cutscene"
[node name="HBoxContainer2" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="DeleteSaveButton" type="Button" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/MarginContainer/VBoxContainer/HBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(200, 35)
layout_mode = 2
theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1)
text = "Delete Save Data"
[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game"]
layout_mode = 2
[node name="ConfirmDeletePopup" type="ColorRect" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/CenterContainer"]
unique_name_in_owner = true
visible = false
custom_minimum_size = Vector2(750, 250)
layout_mode = 2
color = Color(0.137255, 0.121569, 0.12549, 1)
[node name="PanelContainer" type="PanelContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/CenterContainer/ConfirmDeletePopup"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/CenterContainer/ConfirmDeletePopup/PanelContainer"]
layout_mode = 2
text = "Deleting save data will permanently reset progress.
Continue?"
label_settings = ExtResource("2_o7aaw")
horizontal_alignment = 1
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/CenterContainer/ConfirmDeletePopup"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -330.0
offset_top = -50.0
grow_horizontal = 0
grow_vertical = 0
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 25
theme_override_constants/margin_bottom = 15
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/CenterContainer/ConfirmDeletePopup/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/separation = 20
[node name="NoDeleteButton" type="Button" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/CenterContainer/ConfirmDeletePopup/MarginContainer/HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 35)
layout_mode = 2
theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1)
theme_override_fonts/font = ExtResource("3_ohii5")
theme_override_styles/normal = SubResource("StyleBoxFlat_ohii5")
text = "Cancel"
[node name="YesDeleteButton" type="Button" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Game/CenterContainer/ConfirmDeletePopup/MarginContainer/HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 35)
layout_mode = 2
theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1)
theme_override_fonts/font = ExtResource("3_ohii5")
theme_override_styles/normal = SubResource("StyleBoxFlat_o7aaw")
text = "Confirm"
[node name="Audio" type="MarginContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer"]
visible = false
layout_mode = 2
focus_next = NodePath("../Controller")
focus_previous = NodePath("../Game")
theme_override_constants/margin_left = 100
theme_override_constants/margin_top = 100
theme_override_constants/margin_right = 100
theme_override_constants/margin_bottom = 100
metadata/_tab_index = 0
metadata/_tab_index = 1
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio"]
layout_mode = 2
size_flags_horizontal = 0
mouse_filter = 0
theme_override_constants/separation = 20
[node name="MasterVolume" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer"]
layout_mode = 2
@@ -72,7 +185,7 @@ theme_override_styles/slider = SubResource("StyleBoxLine_jli36")
theme_override_styles/grabber_area = SubResource("StyleBoxFlat_utd4g")
theme_override_styles/grabber_area_highlight = SubResource("StyleBoxFlat_1egkf")
max_value = 1.0
step = 0.001
step = 0.1
value = 1.0
[node name="MusicVolume" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer"]
@@ -93,7 +206,7 @@ theme_override_styles/slider = SubResource("StyleBoxLine_jli36")
theme_override_styles/grabber_area = SubResource("StyleBoxFlat_utd4g")
theme_override_styles/grabber_area_highlight = SubResource("StyleBoxFlat_1egkf")
max_value = 1.0
step = 0.001
step = 0.1
value = 1.0
[node name="SFXVolume" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer"]
@@ -114,7 +227,7 @@ theme_override_styles/slider = SubResource("StyleBoxLine_jli36")
theme_override_styles/grabber_area = SubResource("StyleBoxFlat_utd4g")
theme_override_styles/grabber_area_highlight = SubResource("StyleBoxFlat_1egkf")
max_value = 1.0
step = 0.001
step = 0.1
value = 1.0
[node name="Resolution" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer"]
@@ -141,9 +254,6 @@ size_flags_vertical = 10
unique_name_in_owner = true
visible = false
layout_mode = 2
metadata/_tab_index = 1
[node name="PressToGoBackLabel" type="Label" parent="CanvasLayer/CenterContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Press "
focus_next = NodePath(".")
focus_previous = NodePath("../Audio")
metadata/_tab_index = 2

View File

@@ -4,5 +4,5 @@
[resource]
font = ExtResource("1_fbwht")
font_size = 32
font_size = 22
font_color = Color(0.737255, 0.705882, 0.690196, 1)