diff --git a/Autoloads/GameSettings.cs b/Autoloads/GameSettings.cs index dca3356..9c5516a 100644 --- a/Autoloads/GameSettings.cs +++ b/Autoloads/GameSettings.cs @@ -8,7 +8,9 @@ namespace CMSGame { } public record class VideoSettings : GameSettings - { } + { + public bool UseFullScreen = false; + } public record class AudioSettings : GameSettings { diff --git a/Components/Settings/AudioSettingsMenu.cs b/Components/Settings/AudioSettingsMenu.cs index 661f292..e7eae2b 100644 --- a/Components/Settings/AudioSettingsMenu.cs +++ b/Components/Settings/AudioSettingsMenu.cs @@ -1,6 +1,6 @@ namespace CMSGame { - public partial class AudioSettingsMenu : VBoxContainer + public partial class AudioSettingsMenu : Control { public GameSettingsNode? Settings; diff --git a/Components/Settings/BattleSettingsMenu.cs b/Components/Settings/BattleSettingsMenu.cs index 9158357..d0a2355 100644 --- a/Components/Settings/BattleSettingsMenu.cs +++ b/Components/Settings/BattleSettingsMenu.cs @@ -1,10 +1,9 @@ namespace CMSGame { - public partial class BattleSettingsMenu : VBoxContainer - { - public override void _Ready() - { - } - } + public partial class BattleSettingsMenu : Control + { + public override void _Ready() + { + } + } } - diff --git a/Components/Settings/DeveloperOptionsMenu.cs b/Components/Settings/DeveloperOptionsMenu.cs index b8aefb3..5338d59 100644 --- a/Components/Settings/DeveloperOptionsMenu.cs +++ b/Components/Settings/DeveloperOptionsMenu.cs @@ -1,6 +1,6 @@ namespace CMSGame { - public partial class DeveloperOptionsMenu : VBoxContainer + public partial class DeveloperOptionsMenu : Control { public override void _Ready() { diff --git a/Components/Settings/SettingsMenu.cs b/Components/Settings/SettingsMenu.cs index 2421f55..1e03f50 100644 --- a/Components/Settings/SettingsMenu.cs +++ b/Components/Settings/SettingsMenu.cs @@ -2,11 +2,28 @@ namespace CMSGame { public partial class SettingsMenu : TabContainer { + private bool _inDevelopment => OS.HasFeature("debug") || OS.HasFeature("editor"); + public GameSettingsNode? Settings; + public Control? BattleSettingsMenu; + + public Control? VideoSettingsMenu; + + public Control? AudioSettingsMenu; + + public Control? DeveloperOptionsMenu; + public override void _Ready() { this.GetAutoloadNode(ref Settings, nameof(GameSettingsNode)); + + this.GetUniqueNode(ref BattleSettingsMenu, nameof(BattleSettingsMenu)); + this.GetUniqueNode(ref VideoSettingsMenu, nameof(VideoSettingsMenu)); + this.GetUniqueNode(ref AudioSettingsMenu, nameof(AudioSettingsMenu)); + this.GetUniqueNode(ref DeveloperOptionsMenu, nameof(DeveloperOptionsMenu)); + + DeveloperOptionsMenu!.Visible = _inDevelopment; } } } diff --git a/Components/Settings/SettingsMenu.tscn b/Components/Settings/SettingsMenu.tscn index 9ba9005..a659f03 100644 --- a/Components/Settings/SettingsMenu.tscn +++ b/Components/Settings/SettingsMenu.tscn @@ -14,18 +14,46 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_av57b") -[node name="BattleSettingsMenu" type="VBoxContainer" parent="."] +[node name="BattleSettingsMenu" type="Control" parent="."] unique_name_in_owner = true +visible = false layout_mode = 2 script = ExtResource("2_xtjo5") -[node name="VideoSettingsMenu" type="VBoxContainer" parent="."] +[node name="GridContainer" type="GridContainer" parent="BattleSettingsMenu"] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +columns = 2 + +[node name="Label" type="Label" parent="BattleSettingsMenu/GridContainer"] +layout_mode = 2 +text = "跳过非玩家回合" + +[node name="SkipNonPlayerTurnCheckButton" type="CheckButton" parent="BattleSettingsMenu/GridContainer"] +unique_name_in_owner = true +layout_mode = 2 + +[node name="VideoSettingsMenu" type="Control" parent="."] unique_name_in_owner = true -visible = false layout_mode = 2 script = ExtResource("3_68iki") -[node name="AudioSettingsMenu" type="VBoxContainer" parent="."] +[node name="GridContainer" type="GridContainer" parent="VideoSettingsMenu"] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +columns = 2 + +[node name="Label" type="Label" parent="VideoSettingsMenu/GridContainer"] +layout_mode = 2 +text = "全屏" + +[node name="FullScreenCheckButton" type="CheckButton" parent="VideoSettingsMenu/GridContainer"] +unique_name_in_owner = true +layout_mode = 2 + +[node name="AudioSettingsMenu" type="Control" parent="."] unique_name_in_owner = true visible = false layout_mode = 2 @@ -69,13 +97,25 @@ max_value = 1.0 step = 0.01 value = 0.8 -[node name="DeveloperOptionsMenu" type="VBoxContainer" parent="."] +[node name="DeveloperOptionsMenu" type="Control" parent="."] +unique_name_in_owner = true visible = false layout_mode = 2 script = ExtResource("2_dgytf") -[node name="OpenUserDataDirButton" type="Button" parent="DeveloperOptionsMenu"] +[node name="VBoxContainer" type="VBoxContainer" parent="DeveloperOptionsMenu"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -68.0 +offset_right = 68.0 +offset_bottom = 31.0 +grow_horizontal = 2 +size_flags_horizontal = 4 + +[node name="OpenUserDataDirButton" type="Button" parent="DeveloperOptionsMenu/VBoxContainer"] layout_mode = 2 text = "打开用户数据目录" -[connection signal="pressed" from="DeveloperOptionsMenu/OpenUserDataDirButton" to="DeveloperOptionsMenu" method="On_OpenUserDataDirButton_Pressed"] +[connection signal="pressed" from="DeveloperOptionsMenu/VBoxContainer/OpenUserDataDirButton" to="DeveloperOptionsMenu" method="On_OpenUserDataDirButton_Pressed"] diff --git a/Components/Settings/VideoSettingsMenu.cs b/Components/Settings/VideoSettingsMenu.cs index 9bbee34..8ff5219 100644 --- a/Components/Settings/VideoSettingsMenu.cs +++ b/Components/Settings/VideoSettingsMenu.cs @@ -1,10 +1,33 @@ namespace CMSGame { - public partial class VideoSettingsMenu : VBoxContainer - { - public override void _Ready() - { - } - } -} + public partial class VideoSettingsMenu : Control + { + public VideoSettings? Settings; + + public CheckButton? FullScreenCheckButton; + + public override void _Ready() + { + Settings = this.GetAutoloadNode(nameof(GameSettingsNode)).VideoSettings; + + this.GetUniqueNode(ref FullScreenCheckButton, nameof(FullScreenCheckButton)); + FullScreenCheckButton!.SetPressedNoSignal(Settings.UseFullScreen); + + FullScreenCheckButton.Toggled += FullScreenCheckButton_Toggled; ; + } + + private void FullScreenCheckButton_Toggled(bool buttonPressed) + { + Settings!.UseFullScreen = buttonPressed; + if (buttonPressed) + { + DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen); + } + else + { + DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed); + } + } + } +}