Truncate long map name in replay browser.

This commit is contained in:
Paul Chote
2015-11-07 17:38:47 +00:00
parent b689364a4d
commit 19aa07d019

View File

@@ -71,9 +71,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
preview.SpawnOccupants = () => selectedSpawns; preview.SpawnOccupants = () => selectedSpawns;
preview.Preview = () => selectedReplay != null ? selectedReplay.GameInfo.MapPreview : null; preview.Preview = () => selectedReplay != null ? selectedReplay.GameInfo.MapPreview : null;
var title = panel.GetOrNull<LabelWidget>("MAP_TITLE"); var titleLabel = panel.GetOrNull<LabelWidget>("MAP_TITLE");
if (title != null) if (titleLabel != null)
title.GetText = () => selectedReplay != null ? selectedReplay.GameInfo.MapPreview.Title : null; {
titleLabel.IsVisible = () => selectedReplay != null;
var font = Game.Renderer.Fonts[titleLabel.Font];
var title = new CachedTransform<MapPreview, string>(m => WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font));
titleLabel.GetText = () => title.Update(selectedReplay.GameInfo.MapPreview);
}
var type = panel.GetOrNull<LabelWidget>("MAP_TYPE"); var type = panel.GetOrNull<LabelWidget>("MAP_TYPE");
if (type != null) if (type != null)