Unstable 0.17.7.0

This commit is contained in:
Markus Isberg
2022-04-08 00:34:17 +09:00
parent 95764d1fa8
commit 164d72ae3a
82 changed files with 852 additions and 385 deletions
@@ -512,23 +512,36 @@ namespace Barotrauma
}
/// <summary>
/// Scrolls the list to the specific element, currently only works when smooth scrolling and PadBottom are enabled.
/// Scrolls the list to the specific element.
/// </summary>
/// <param name="component"></param>
public void ScrollToElement(GUIComponent component)
public void ScrollToElement(GUIComponent component, bool playSound = true)
{
SoundPlayer.PlayUISound(GUISoundType.Click);
if (playSound) { SoundPlayer.PlayUISound(GUISoundType.Click); }
List<GUIComponent> children = Content.Children.ToList();
int index = children.IndexOf(component);
if (index < 0) { return; }
void performScroll(GUIComponent c)
{
if (SmoothScroll && PadBottom)
{
scrollToElement = c;
}
else
{
float diff = isHorizontal ? c.Rect.X - Content.Rect.X : c.Rect.Y - Content.Rect.Y;
ScrollBar.BarScroll += diff / TotalSize;
}
}
if (!Content.Children.Contains(component) || !component.Visible)
{
scrollToElement = null;
performScroll(null);
}
else
{
scrollToElement = component;
performScroll(component);
}
}