Truncate long map name / author in map chooser.
This commit is contained in:
@@ -235,7 +235,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
item.IsVisible = () => item.RenderBounds.IntersectsWith(scrollpanels[tab].RenderBounds);
|
item.IsVisible = () => item.RenderBounds.IntersectsWith(scrollpanels[tab].RenderBounds);
|
||||||
|
|
||||||
var titleLabel = item.Get<LabelWidget>("TITLE");
|
var titleLabel = item.Get<LabelWidget>("TITLE");
|
||||||
titleLabel.GetText = () => preview.Title;
|
if (titleLabel != null)
|
||||||
|
{
|
||||||
|
var font = Game.Renderer.Fonts[titleLabel.Font];
|
||||||
|
var title = WidgetUtils.TruncateText(preview.Title, titleLabel.Bounds.Width, font);
|
||||||
|
titleLabel.GetText = () => title;
|
||||||
|
}
|
||||||
|
|
||||||
var previewWidget = item.Get<MapPreviewWidget>("PREVIEW");
|
var previewWidget = item.Get<MapPreviewWidget>("PREVIEW");
|
||||||
previewWidget.Preview = () => preview;
|
previewWidget.Preview = () => preview;
|
||||||
@@ -246,7 +251,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var authorWidget = item.GetOrNull<LabelWidget>("AUTHOR");
|
var authorWidget = item.GetOrNull<LabelWidget>("AUTHOR");
|
||||||
if (authorWidget != null)
|
if (authorWidget != null)
|
||||||
authorWidget.GetText = () => "Created by {0}".F(preview.Author);
|
{
|
||||||
|
var font = Game.Renderer.Fonts[authorWidget.Font];
|
||||||
|
var author = WidgetUtils.TruncateText("Created by {0}".F(preview.Author), authorWidget.Bounds.Width, font);
|
||||||
|
authorWidget.GetText = () => author;
|
||||||
|
}
|
||||||
|
|
||||||
var sizeWidget = item.GetOrNull<LabelWidget>("SIZE");
|
var sizeWidget = item.GetOrNull<LabelWidget>("SIZE");
|
||||||
if (sizeWidget != null)
|
if (sizeWidget != null)
|
||||||
|
|||||||
@@ -89,25 +89,25 @@ Container@MAPCHOOSER_PANEL:
|
|||||||
IgnoreMouseOver: true
|
IgnoreMouseOver: true
|
||||||
IgnoreMouseInput: true
|
IgnoreMouseInput: true
|
||||||
Label@TITLE:
|
Label@TITLE:
|
||||||
X: 2
|
X: 4
|
||||||
Y: PARENT_BOTTOM-48
|
Y: PARENT_BOTTOM-48
|
||||||
Width: PARENT_RIGHT-4
|
Width: PARENT_RIGHT-8
|
||||||
Align: Center
|
Align: Center
|
||||||
Label@DETAILS:
|
Label@DETAILS:
|
||||||
Width: PARENT_RIGHT-4
|
Width: PARENT_RIGHT-8
|
||||||
X: 2
|
X: 4
|
||||||
Y: PARENT_BOTTOM-34
|
Y: PARENT_BOTTOM-34
|
||||||
Align: Center
|
Align: Center
|
||||||
Font: Tiny
|
Font: Tiny
|
||||||
Label@AUTHOR:
|
Label@AUTHOR:
|
||||||
Width: PARENT_RIGHT-4
|
Width: PARENT_RIGHT-8
|
||||||
X: 2
|
X: 4
|
||||||
Y: PARENT_BOTTOM-22
|
Y: PARENT_BOTTOM-22
|
||||||
Align: Center
|
Align: Center
|
||||||
Font: Tiny
|
Font: Tiny
|
||||||
Label@SIZE:
|
Label@SIZE:
|
||||||
Width: PARENT_RIGHT-4
|
Width: PARENT_RIGHT-8
|
||||||
X: 2
|
X: 4
|
||||||
Y: PARENT_BOTTOM-10
|
Y: PARENT_BOTTOM-10
|
||||||
Align: Center
|
Align: Center
|
||||||
Font: Tiny
|
Font: Tiny
|
||||||
|
|||||||
@@ -60,25 +60,25 @@ Background@MAPCHOOSER_PANEL:
|
|||||||
IgnoreMouseOver: true
|
IgnoreMouseOver: true
|
||||||
IgnoreMouseInput: true
|
IgnoreMouseInput: true
|
||||||
Label@TITLE:
|
Label@TITLE:
|
||||||
X: 2
|
X: 4
|
||||||
Y: PARENT_BOTTOM-53
|
Y: PARENT_BOTTOM-53
|
||||||
Width: PARENT_RIGHT-4
|
Width: PARENT_RIGHT-8
|
||||||
Align: Center
|
Align: Center
|
||||||
Label@DETAILS:
|
Label@DETAILS:
|
||||||
Width: PARENT_RIGHT-4
|
Width: PARENT_RIGHT-8
|
||||||
X: 2
|
X: 4
|
||||||
Y: PARENT_BOTTOM-37
|
Y: PARENT_BOTTOM-37
|
||||||
Align: Center
|
Align: Center
|
||||||
Font: Tiny
|
Font: Tiny
|
||||||
Label@AUTHOR:
|
Label@AUTHOR:
|
||||||
Width: PARENT_RIGHT-4
|
Width: PARENT_RIGHT-8
|
||||||
X: 2
|
X: 4
|
||||||
Y: PARENT_BOTTOM-25
|
Y: PARENT_BOTTOM-25
|
||||||
Align: Center
|
Align: Center
|
||||||
Font: Tiny
|
Font: Tiny
|
||||||
Label@SIZE:
|
Label@SIZE:
|
||||||
Width: PARENT_RIGHT-4
|
Width: PARENT_RIGHT-8
|
||||||
X: 2
|
X: 4
|
||||||
Y: PARENT_BOTTOM-13
|
Y: PARENT_BOTTOM-13
|
||||||
Align: Center
|
Align: Center
|
||||||
Font: Tiny
|
Font: Tiny
|
||||||
|
|||||||
Reference in New Issue
Block a user