From 19aa07d019de0650f175a7bf872c33fce507c14f Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 7 Nov 2015 17:38:47 +0000 Subject: [PATCH] Truncate long map name in replay browser. --- .../Widgets/Logic/ReplayBrowserLogic.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs index 821b28fc95..90962f3d5c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs @@ -71,9 +71,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic preview.SpawnOccupants = () => selectedSpawns; preview.Preview = () => selectedReplay != null ? selectedReplay.GameInfo.MapPreview : null; - var title = panel.GetOrNull("MAP_TITLE"); - if (title != null) - title.GetText = () => selectedReplay != null ? selectedReplay.GameInfo.MapPreview.Title : null; + var titleLabel = panel.GetOrNull("MAP_TITLE"); + if (titleLabel != null) + { + titleLabel.IsVisible = () => selectedReplay != null; + + var font = Game.Renderer.Fonts[titleLabel.Font]; + var title = new CachedTransform(m => WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font)); + titleLabel.GetText = () => title.Update(selectedReplay.GameInfo.MapPreview); + } var type = panel.GetOrNull("MAP_TYPE"); if (type != null)