From bbe58f764cf346031a24c19de49f1a3bc2806b49 Mon Sep 17 00:00:00 2001 From: Jiiniasu Date: Mon, 27 Nov 2017 19:26:11 +0100 Subject: [PATCH] Fix: Error when profiles < amount of tiles --- VocaluxeLib/Menu/CNameSelection.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/VocaluxeLib/Menu/CNameSelection.cs b/VocaluxeLib/Menu/CNameSelection.cs index 74c4abc2..cdae1dd6 100644 --- a/VocaluxeLib/Menu/CNameSelection.cs +++ b/VocaluxeLib/Menu/CNameSelection.cs @@ -299,7 +299,7 @@ namespace VocaluxeLib.Menu public void UpdateList(int offset) { - offset = offset.Clamp(0, (int)Math.Ceiling((decimal)(_VisibleProfiles.Count - _Tiles.Count) / _Theme.Tiles.NumW)); + offset = offset.Clamp(0, _GetMaxOffset()); for (int i = 0; i < _Tiles.Count; i++) { @@ -457,6 +457,16 @@ namespace VocaluxeLib.Menu } } + private int _GetMaxOffset() + { + int maxOffset = (int)Math.Ceiling((decimal)(_VisibleProfiles.Count - _Tiles.Count) / _Theme.Tiles.NumW); + if (maxOffset < 0) + { + return 0; + } + return maxOffset; + } + public object GetTheme() { return _Theme;