Fries
425bf2ad27
i added more to the main menu, as it has a settings menu now, that stores its files with json. i also changed the font to atkinson hyperlegible and made a BaseMenu class that takes care of the screen scaling for menus. i also refactored the project folder structure to make it more organized.
52 lines
1.1 KiB
C#
52 lines
1.1 KiB
C#
using Godot;
|
|
|
|
namespace Pong.Scripts.Managers.UI.Menus;
|
|
|
|
public partial class Settings : BaseMenu
|
|
{
|
|
private SettingsManager _settings;
|
|
private SpinBox _scale;
|
|
private Button _saveButton;
|
|
|
|
private bool _scaleModified;
|
|
|
|
protected override void EnterTree()
|
|
{
|
|
GetNodes();
|
|
|
|
_scale.Value = _settings.SettingsData.Scale;
|
|
}
|
|
|
|
private void OnBackButtonPressed()
|
|
{
|
|
GetTree().ChangeSceneToFile("res://Scenes/UI/Menus/MainMenu.tscn");
|
|
}
|
|
|
|
private void GetNodes()
|
|
{
|
|
_settings = GetNode<SettingsManager>("/root/SettingsManager");
|
|
_scale = GetNode<SpinBox>("ScrollContainer/InternalMainContainer/ScaleContainer/Scale");
|
|
_saveButton = GetNode<Button>("SaveButton");
|
|
|
|
_scale.ValueChanged += ScaleChanged;
|
|
}
|
|
|
|
private void ScaleChanged(double value)
|
|
{
|
|
_scaleModified = !value.Equals(_settings.SettingsData.Scale);
|
|
CheckIfModified();
|
|
}
|
|
|
|
private bool CheckIfModified()
|
|
{
|
|
var isModified = _scaleModified;
|
|
_saveButton.Disabled = !isModified;
|
|
return isModified;
|
|
}
|
|
|
|
private async void OnSaveButtonPressed()
|
|
{
|
|
if (!await _settings.SaveSettings(_settings.SettingsData with { Scale = _scale.Value })) return;
|
|
_saveButton.Disabled = true;
|
|
}
|
|
}
|