Add tooltips to map name and author in map chooser

This commit is contained in:
Ivaylo Draganov
2021-06-23 16:04:16 +03:00
committed by abcdefg30
parent 453d59ae16
commit 7a1169744e
3 changed files with 36 additions and 20 deletions

View File

@@ -253,12 +253,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
() => selectedUid = preview.Uid, dblClick);
item.IsVisible = () => item.RenderBounds.IntersectsWith(scrollpanels[tab].RenderBounds);
var titleLabel = item.Get<LabelWidget>("TITLE");
var titleLabel = item.Get<LabelWithTooltipWidget>("TITLE");
if (titleLabel != null)
{
var font = Game.Renderer.Fonts[titleLabel.Font];
var title = WidgetUtils.TruncateText(preview.Title, titleLabel.Bounds.Width, font);
titleLabel.GetText = () => title;
WidgetUtils.TruncateLabelToTooltip(titleLabel, preview.Title);
}
var previewWidget = item.Get<MapPreviewWidget>("PREVIEW");
@@ -276,12 +274,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
detailsWidget.GetText = () => details;
}
var authorWidget = item.GetOrNull<LabelWidget>("AUTHOR");
var authorWidget = item.GetOrNull<LabelWithTooltipWidget>("AUTHOR");
if (authorWidget != null)
{
var font = Game.Renderer.Fonts[authorWidget.Font];
var author = WidgetUtils.TruncateText($"Created by {preview.Author}", authorWidget.Bounds.Width, font);
authorWidget.GetText = () => author;
WidgetUtils.TruncateLabelToTooltip(authorWidget, $"Created by {preview.Author}");
}
var sizeWidget = item.GetOrNull<LabelWidget>("SIZE");