Skip to content

Commit da5481c

Browse files
authored
Fixes out of bounds exception on world scale slider (#2757)
1 parent 1459a02 commit da5481c

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -829,29 +829,28 @@ protected override void OnVisibilityChanged(object? sender, VisibilityChangedEve
829829

830830
private void UpdateWorldScaleControls()
831831
{
832-
var worldScaleNotches = new double[] { 1, 2, 4 }.Select(n => n * Graphics.MinimumWorldScale).ToList();
833-
while (worldScaleNotches.Last() < Graphics.MaximumWorldScale)
832+
if (!Options.IsLoaded)
834833
{
835-
worldScaleNotches.Add(worldScaleNotches.Last() * 2);
834+
_worldScale.IsHidden = true;
835+
return;
836836
}
837837

838-
if (Options.IsLoaded)
839-
{
840-
_worldScale.IsDisabled = false;
841-
_worldScale.SetToolTipText(null);
838+
_worldScale.IsHidden = false;
839+
_worldScale.IsDisabled = false;
840+
_worldScale.SetToolTipText(null);
842841

843-
Globals.Database.WorldZoom = (float)MathHelper.Clamp(
844-
Globals.Database.WorldZoom,
845-
worldScaleNotches.Min(),
846-
worldScaleNotches.Max()
847-
);
848-
}
849-
else
842+
var worldScaleNotches = new double[] { 1, 2, 4 }.Select(n => n * Graphics.MinimumWorldScale).ToList();
843+
while (worldScaleNotches.Last() < Graphics.MaximumWorldScale)
850844
{
851-
_worldScale.SetToolTipText(Strings.Settings.WorldScaleTooltip);
852-
_worldScale.IsDisabled = true;
845+
worldScaleNotches.Add(worldScaleNotches.Last() * 2);
853846
}
854847

848+
Globals.Database.WorldZoom = (float)MathHelper.Clamp(
849+
Globals.Database.WorldZoom,
850+
worldScaleNotches.Min(),
851+
worldScaleNotches.Max()
852+
);
853+
855854
_worldScale.SetRange(worldScaleNotches.Min(), worldScaleNotches.Max());
856855
_worldScale.Notches = worldScaleNotches.ToArray();
857856
_worldScale.Value = Globals.Database.WorldZoom;
@@ -1175,7 +1174,10 @@ private void SettingsApplyBtn_Clicked(Base sender, MouseButtonState arguments)
11751174

11761175
// Video Settings.
11771176
Globals.Database.EnableScrollingWorldZoom = _enableScrollingWorldZoomCheckbox.IsChecked;
1178-
Globals.Database.WorldZoom = (float)_worldScale.Value;
1177+
if (!_worldScale.IsHidden)
1178+
{
1179+
Globals.Database.WorldZoom = (float)_worldScale.Value;
1180+
}
11791181

11801182
var resolutionItem = _resolutionList.SelectedItem;
11811183
var targetResolution = resolutionItem?.UserData as int? ?? -1;

0 commit comments

Comments
 (0)