Center the vertical alignment of lobby options if less than the panel height.

This also enables an extra row to be shown before triggering the scroll bar.
This commit is contained in:
Paul Chote
2017-12-09 21:47:31 +00:00
committed by reaperrr
parent 3f67feab0e
commit 3ad6a87920
3 changed files with 14 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly Widget optionsContainer;
readonly Widget checkboxRowTemplate;
readonly Widget dropdownRowTemplate;
readonly int yMargin;
readonly Func<MapPreview> getMap;
readonly OrderManager orderManager;
@@ -40,6 +41,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
panel = (ScrollPanelWidget)widget;
optionsContainer = widget.Get("LOBBY_OPTIONS");
yMargin = optionsContainer.Bounds.Y;
optionsContainer.IsVisible = () => validOptions;
checkboxRowTemplate = optionsContainer.Get("CHECKBOX_ROW_TEMPLATE");
dropdownRowTemplate = optionsContainer.Get("DROPDOWN_ROW_TEMPLATE");
@@ -173,7 +175,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
}
panel.ContentHeight = optionsContainer.Bounds.Y + optionsContainer.Bounds.Height;
panel.ContentHeight = yMargin + optionsContainer.Bounds.Height;
optionsContainer.Bounds.Y = yMargin;
if (panel.ContentHeight < panel.Bounds.Height)
optionsContainer.Bounds.Y += (panel.Bounds.Height - panel.ContentHeight) / 2;
panel.ScrollToTop();
}
}
}