Add tooltips to overflowing labels

This commit is contained in:
Ivaylo Draganov
2019-05-25 22:21:06 +03:00
committed by abcdefg30
parent 1fee50be2e
commit fde215360c
23 changed files with 91 additions and 30 deletions

View File

@@ -594,12 +594,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var canJoin = game.IsJoinable;
var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => SelectServer(game), () => onJoin(game));
var title = item.GetOrNull<LabelWidget>("TITLE");
var title = item.GetOrNull<LabelWithTooltipWidget>("TITLE");
if (title != null)
{
var font = Game.Renderer.Fonts[title.Font];
var label = WidgetUtils.TruncateText(game.Name, title.Bounds.Width, font);
title.GetText = () => label;
WidgetUtils.TruncateLabelToTooltip(title, game.Name);
title.GetColor = () => canJoin ? title.TextColor : incompatibleGameColor;
}