diff --git a/GSS2.UI.Core/SectionPanel.cs b/GSS2.UI.Core/SectionPanel.cs index 363d82c..f1b5089 100644 --- a/GSS2.UI.Core/SectionPanel.cs +++ b/GSS2.UI.Core/SectionPanel.cs @@ -25,6 +25,8 @@ public class SectionPanel : Panel return value; if (sectionPanel.Cyclic) return value; + if (sectionPanel.Children.Count() == 0) + return 0; return Math.Clamp(value, 0, sectionPanel.Children.Count() - 1); }); public int CurrentIndex @@ -119,6 +121,14 @@ public class SectionPanel : Panel foreach (var control in controls) panel.Children.Add(control); + + if (_initialized) + { + _childIndeces.Clear(); + foreach (var (i, child) in Children.Enumerate()) + _childIndeces.Add(child, i); + _initialized = true; + } } panel.InvalidateArrange(); });