Fries
604d79e654
i added a GameArea class which makes it easier to operate on in coordinates bounds with the GameCoordinate struct wrapper which does calculations for me. the GameArea class also has a normalization system which is how the ScalingManager can teleport items in bounds to relatively the same place when resized. it took quite a while to get the paddle to teleport. looks like im supposed to modify the position inside IntegrateForces instead of PhysicsProcess which is my mistake.
50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|