Added final features for this release. Now only polishing (if needed) remains.
Features: Sacrifice-Node, Maintain-Node, Options for screen type, lightcolor and soundvolume, tied in sound effects, game pause when menu is open, visibly open up gate when opening it.
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
using Godot;
|
||||
|
||||
public partial class OptionsMenu : PanelContainer
|
||||
{
|
||||
private readonly Vector2 panelSize = new Vector2(420, 260);
|
||||
|
||||
[Export] private OptionButton screenMode;
|
||||
[Export] private HSlider soundVolume;
|
||||
[Export] private ColorPickerButton lightColor;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CenterPanel();
|
||||
SetupScreenModes();
|
||||
screenMode.Select(GameData.screenMode);
|
||||
soundVolume.Value = GameData.soundVolume * 100f;
|
||||
lightColor.Color = GameData.lightColor;
|
||||
ApplyScreenMode(GameData.screenMode);
|
||||
SoundManager.SetMasterVolume(GameData.soundVolume);
|
||||
}
|
||||
|
||||
private void SetupScreenModes()
|
||||
{
|
||||
screenMode.Clear();
|
||||
screenMode.AddItem("Fullscreen");
|
||||
screenMode.AddItem("Windowed");
|
||||
screenMode.AddItem("Windowed Fullscreen");
|
||||
screenMode.Select(2);
|
||||
}
|
||||
|
||||
public void OnScreenModeSelected(int index)
|
||||
{
|
||||
GameData.screenMode = index;
|
||||
ApplyScreenMode(index);
|
||||
}
|
||||
|
||||
private void ApplyScreenMode(int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
|
||||
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, false);
|
||||
break;
|
||||
case 1:
|
||||
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed);
|
||||
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, false);
|
||||
break;
|
||||
case 2:
|
||||
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
|
||||
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSoundVolumeChanged(double value)
|
||||
{
|
||||
GameData.soundVolume = (float)value / 100f;
|
||||
SoundManager.SetMasterVolume(GameData.soundVolume);
|
||||
}
|
||||
|
||||
public void OnLightColorChanged(Color color)
|
||||
{
|
||||
GameData.lightColor = color;
|
||||
LightHandler.RedrawLights(color);
|
||||
}
|
||||
|
||||
public void CloseOptions()
|
||||
{
|
||||
Hide();
|
||||
GameData.isPaused = false;
|
||||
}
|
||||
|
||||
private void CenterPanel()
|
||||
{
|
||||
CustomMinimumSize = panelSize;
|
||||
SetAnchorsPreset(LayoutPreset.Center);
|
||||
OffsetLeft = -panelSize.X / 2f;
|
||||
OffsetTop = -panelSize.Y / 2f;
|
||||
OffsetRight = panelSize.X / 2f;
|
||||
OffsetBottom = panelSize.Y / 2f;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user