Skip to content

Commit 5086756

Browse files
committed
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.
1 parent c9c5517 commit 5086756

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class LobbyOptionsLogic : ChromeLogic
2424
readonly Widget optionsContainer;
2525
readonly Widget checkboxRowTemplate;
2626
readonly Widget dropdownRowTemplate;
27+
readonly int yMargin;
2728

2829
readonly Func<MapPreview> getMap;
2930
readonly OrderManager orderManager;
@@ -40,6 +41,7 @@ internal LobbyOptionsLogic(Widget widget, OrderManager orderManager, Func<MapPre
4041

4142
panel = (ScrollPanelWidget)widget;
4243
optionsContainer = widget.Get("LOBBY_OPTIONS");
44+
yMargin = optionsContainer.Bounds.Y;
4345
optionsContainer.IsVisible = () => validOptions;
4446
checkboxRowTemplate = optionsContainer.Get("CHECKBOX_ROW_TEMPLATE");
4547
dropdownRowTemplate = optionsContainer.Get("DROPDOWN_ROW_TEMPLATE");
@@ -173,7 +175,12 @@ void RebuildOptions()
173175
}
174176
}
175177

176-
panel.ContentHeight = optionsContainer.Bounds.Y + optionsContainer.Bounds.Height;
178+
panel.ContentHeight = yMargin + optionsContainer.Bounds.Height;
179+
optionsContainer.Bounds.Y = yMargin;
180+
if (panel.ContentHeight < panel.Bounds.Height)
181+
optionsContainer.Bounds.Y += (panel.Bounds.Height - panel.ContentHeight) / 2;
182+
183+
panel.ScrollToTop();
177184
}
178185
}
179186
}

mods/cnc/chrome/lobby-options.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ Container@LOBBY_OPTIONS_BIN:
1616
Children:
1717
Container@LOBBY_OPTIONS:
1818
X: 18
19-
Y: 30
19+
Y: 9
2020
Width: PARENT_RIGHT - 24 - 18
21-
Height: PARENT_BOTTOM - 75
2221
Children:
2322
Container@CHECKBOX_ROW_TEMPLATE:
24-
Height: 35
23+
Height: 34
2524
Children:
2625
Checkbox@A:
2726
Width: 175
@@ -44,7 +43,7 @@ Container@LOBBY_OPTIONS_BIN:
4443
Visible: False
4544
TooltipContainer: TOOLTIP_CONTAINER
4645
Container@DROPDOWN_ROW_TEMPLATE:
47-
Height: 35
46+
Height: 34
4847
Width: PARENT_RIGHT
4948
Children:
5049
Label@A_DESC:

mods/common/chrome/lobby-options.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ Container@LOBBY_OPTIONS_BIN:
1616
Children:
1717
Container@LOBBY_OPTIONS:
1818
X: 18
19-
Y: 30
19+
Y: 9
2020
Width: PARENT_RIGHT - 18 - 24
21-
Height: PARENT_BOTTOM - 75
2221
Children:
2322
Container@CHECKBOX_ROW_TEMPLATE:
24-
Height: 35
23+
Height: 34
2524
Children:
2625
Checkbox@A:
2726
Width: 175
@@ -41,7 +40,7 @@ Container@LOBBY_OPTIONS_BIN:
4140
Visible: False
4241
TooltipContainer: TOOLTIP_CONTAINER
4342
Container@DROPDOWN_ROW_TEMPLATE:
44-
Height: 35
43+
Height: 34
4544
Width: PARENT_RIGHT
4645
Children:
4746
Label@A_DESC:

0 commit comments

Comments
 (0)