Skip to content

Commit 90279b4

Browse files
committed
add a hook to re-update the window state AscensionGameDev#2563
1 parent 62d8fbc commit 90279b4

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

Intersect.Client.Core/Interface/Shared/SettingsWindow.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ public SettingsWindow(Base parent) : base(parent: parent, title: Strings.Setting
418418
_worldScale = new LabeledSlider(parent: _videoContainer, name: nameof(_worldScale))
419419
{
420420
Dock = Pos.Top,
421-
IsDisabled = !Options.IsLoaded,
422421
Font = _defaultFont,
423422
Label = Strings.Settings.WorldScale,
424423
Orientation = Orientation.LeftToRight,
@@ -556,6 +555,13 @@ protected override void EnsureInitialized()
556555
LoadJsonUi(stage: UI.Shared, resolution: Graphics.Renderer?.GetResolutionString());
557556
}
558557

558+
protected override void OnJsonReloaded()
559+
{
560+
base.OnJsonReloaded();
561+
562+
UpdateWorldScaleControls();
563+
}
564+
559565
public override bool IsBlockingInput => _keybindingEditBtn is not null;
560566

561567
private BottomBarItems CreateBottomBar(Base parent)

Intersect.Client.Framework/Gwen/Control/Base.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,12 @@ public object? UserData
759759
public bool IsDisabled
760760
{
761761
get => (_inheritParentEnablementProperties && Parent != default) ? Parent.IsDisabled : _disabled;
762-
set => SetAndDoIfChanged(ref _disabled, value, Invalidate);
762+
set => SetAndDoIfChanged(ref _disabled, value, OnDisabledChanged);
763+
}
764+
765+
protected virtual void OnDisabledChanged(bool oldValue, bool newValue)
766+
{
767+
Invalidate();
763768
}
764769

765770
/// <summary>
@@ -1293,6 +1298,7 @@ public void LoadJsonUi(GameContentManager.UI stage, string? resolution = default
12931298
{
12941299
LoadJson(obj, true);
12951300
ProcessAlignments();
1301+
OnJsonReloaded();
12961302
}
12971303
}
12981304
catch (Exception exception)
@@ -1309,6 +1315,11 @@ public void LoadJsonUi(GameContentManager.UI stage, string? resolution = default
13091315
});
13101316
}
13111317

1318+
protected virtual void OnJsonReloaded()
1319+
{
1320+
1321+
}
1322+
13121323
public virtual void LoadJson(JToken token, bool isRoot = default)
13131324
{
13141325
if (token is not JObject obj)
@@ -4549,6 +4560,4 @@ protected bool SetAndDoIfChanged(
45494560
valueChangeHandler(oldValue, value);
45504561
return true;
45514562
}
4552-
}
4553-
4554-
public delegate void ValueChangeHandler<TValue>(TValue oldValue, TValue newValue);
4563+
}

Intersect.Client.Framework/Gwen/Control/LabeledSlider.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ public string? ValueFormatString
272272
/// </summary>
273273
public event GwenEventHandler<ValueChangedEventArgs<double>>? ValueChanged;
274274

275+
protected override void OnDisabledChanged(bool oldValue, bool newValue)
276+
{
277+
base.OnDisabledChanged(oldValue, newValue);
278+
}
279+
275280
protected override void Layout(Skin.Base skin)
276281
{
277282
if (_recomputeValueMinimumSize)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace Intersect.Client.Framework.Gwen.Control;
2+
3+
public delegate void ValueChangeHandler<TValue>(TValue oldValue, TValue newValue);

0 commit comments

Comments
 (0)