Reduce the size of battlefield news when messages are short
(cherry picked from commit 2a1eeae7ca55e814a8a648b7306648d6585a26c3)
This commit is contained in:
@@ -43,6 +43,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
protected MenuType menuType = MenuType.Main;
|
||||
readonly Widget rootMenu;
|
||||
readonly ScrollPanelWidget newsPanel;
|
||||
readonly int maxNewsHeight;
|
||||
readonly Widget newsTemplate;
|
||||
readonly LabelWidget newsStatus;
|
||||
readonly ModData modData;
|
||||
@@ -230,6 +231,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
newsPanel = Ui.LoadWidget<ScrollPanelWidget>("NEWS_PANEL", null, new WidgetArgs());
|
||||
newsTemplate = newsPanel.Get("NEWS_ITEM_TEMPLATE");
|
||||
newsPanel.RemoveChild(newsTemplate);
|
||||
maxNewsHeight = newsPanel.Bounds.Height;
|
||||
|
||||
newsStatus = newsPanel.Get<LabelWidget>("NEWS_STATUS");
|
||||
SetNewsStatus(FluentProvider.GetMessage(LoadingNews));
|
||||
@@ -416,10 +418,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
newsPanel.RemoveChildren();
|
||||
SetNewsStatus("");
|
||||
|
||||
foreach (var i in newsItems)
|
||||
foreach (var item in newsItems)
|
||||
{
|
||||
var item = i;
|
||||
|
||||
var newsItem = newsTemplate.Clone();
|
||||
|
||||
var titleLabel = newsItem.Get<LabelWidget>("TITLE");
|
||||
@@ -441,6 +441,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
newsPanel.AddChild(newsItem);
|
||||
newsPanel.Layout.AdjustChildren();
|
||||
newsPanel.Bounds.Height = Math.Min(newsPanel.ContentHeight, maxNewsHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -284,29 +284,27 @@ ScrollPanel@NEWS_PANEL:
|
||||
Width: 400
|
||||
Height: 265
|
||||
Background: panel-black
|
||||
TopBottomSpacing: 5
|
||||
TopBottomSpacing: 10
|
||||
ItemSpacing: 5
|
||||
Children:
|
||||
Container@NEWS_ITEM_TEMPLATE:
|
||||
X: 10
|
||||
Y: 5
|
||||
Width: PARENT_WIDTH - 40
|
||||
Height: 45
|
||||
Height: 40
|
||||
Children:
|
||||
Label@TITLE:
|
||||
Y: 1
|
||||
Width: PARENT_WIDTH
|
||||
Height: 25
|
||||
Height: 20
|
||||
Align: Center
|
||||
Font: Bold
|
||||
Label@AUTHOR_DATETIME:
|
||||
Y: 26
|
||||
Y: 21
|
||||
Width: PARENT_WIDTH
|
||||
Height: 15
|
||||
Align: Center
|
||||
Font: TinyBold
|
||||
Label@CONTENT:
|
||||
Y: 46
|
||||
Y: 40
|
||||
Width: PARENT_WIDTH
|
||||
Label@NEWS_STATUS:
|
||||
X: 80
|
||||
|
||||
@@ -152,32 +152,30 @@ ScrollPanel@SPECTATOR_LABEL_DROPDOWN_TEMPLATE:
|
||||
ScrollPanel@NEWS_PANEL:
|
||||
Width: 400
|
||||
Height: 265
|
||||
TopBottomSpacing: 5
|
||||
TopBottomSpacing: 15
|
||||
ItemSpacing: 5
|
||||
Children:
|
||||
Container@NEWS_ITEM_TEMPLATE:
|
||||
X: 10
|
||||
Y: 5
|
||||
Width: PARENT_WIDTH - 40
|
||||
Height: 45
|
||||
Height: 40
|
||||
Children:
|
||||
Label@TITLE:
|
||||
Width: PARENT_WIDTH
|
||||
Height: 25
|
||||
Height: 15
|
||||
Align: Center
|
||||
Font: Bold
|
||||
Label@AUTHOR_DATETIME:
|
||||
Y: 25
|
||||
Y: 20
|
||||
Width: PARENT_WIDTH
|
||||
Height: 15
|
||||
Align: Center
|
||||
Font: TinyBold
|
||||
Label@CONTENT:
|
||||
Y: 45
|
||||
Y: 40
|
||||
Width: PARENT_WIDTH
|
||||
Label@NEWS_STATUS:
|
||||
X: 80
|
||||
Y: 0
|
||||
Width: PARENT_WIDTH - 80 - 80 - 24
|
||||
Height: PARENT_HEIGHT
|
||||
Align: Center
|
||||
|
||||
@@ -116,32 +116,30 @@ ScrollPanel@SPECTATOR_DROPDOWN_TEMPLATE:
|
||||
ScrollPanel@NEWS_PANEL:
|
||||
Width: 400
|
||||
Height: 265
|
||||
TopBottomSpacing: 5
|
||||
TopBottomSpacing: 15
|
||||
ItemSpacing: 5
|
||||
Children:
|
||||
Container@NEWS_ITEM_TEMPLATE:
|
||||
X: 10
|
||||
Y: 5
|
||||
Width: PARENT_WIDTH - 40
|
||||
Height: 45
|
||||
Height: 40
|
||||
Children:
|
||||
Label@TITLE:
|
||||
Width: PARENT_WIDTH
|
||||
Height: 25
|
||||
Height: 15
|
||||
Align: Center
|
||||
Font: Bold
|
||||
Label@AUTHOR_DATETIME:
|
||||
Y: 25
|
||||
Y: 20
|
||||
Width: PARENT_WIDTH
|
||||
Height: 15
|
||||
Align: Center
|
||||
Font: TinyBold
|
||||
Label@CONTENT:
|
||||
Y: 45
|
||||
Y: 40
|
||||
Width: PARENT_WIDTH
|
||||
Label@NEWS_STATUS:
|
||||
X: 80
|
||||
Y: 0
|
||||
Width: PARENT_WIDTH - 80 - 80 - 24
|
||||
Height: PARENT_HEIGHT
|
||||
Align: Center
|
||||
|
||||
@@ -116,32 +116,30 @@ ScrollPanel@SPECTATOR_DROPDOWN_TEMPLATE:
|
||||
ScrollPanel@NEWS_PANEL:
|
||||
Width: 400
|
||||
Height: 265
|
||||
TopBottomSpacing: 5
|
||||
TopBottomSpacing: 15
|
||||
ItemSpacing: 5
|
||||
Children:
|
||||
Container@NEWS_ITEM_TEMPLATE:
|
||||
X: 10
|
||||
Y: 6
|
||||
Width: PARENT_WIDTH - 40
|
||||
Height: 45
|
||||
Height: 40
|
||||
Children:
|
||||
Label@TITLE:
|
||||
Width: PARENT_WIDTH
|
||||
Height: 25
|
||||
Height: 15
|
||||
Align: Center
|
||||
Font: Bold
|
||||
Label@AUTHOR_DATETIME:
|
||||
Y: 25
|
||||
Y: 20
|
||||
Width: PARENT_WIDTH
|
||||
Height: 15
|
||||
Align: Center
|
||||
Font: TinyBold
|
||||
Label@CONTENT:
|
||||
Y: 45
|
||||
Y: 40
|
||||
Width: PARENT_WIDTH
|
||||
Label@NEWS_STATUS:
|
||||
X: 80
|
||||
Y: 1
|
||||
Width: PARENT_WIDTH - 80 - 80 - 24
|
||||
Height: PARENT_HEIGHT
|
||||
Align: Center
|
||||
|
||||
Reference in New Issue
Block a user