From 1f3f489328a343bc9bcbc7c85eb8685a8ba579b4 Mon Sep 17 00:00:00 2001 From: Ivaylo Draganov Date: Mon, 19 Jul 2021 14:20:06 +0300 Subject: [PATCH] Show map preview tooltip only if needed --- .../Widgets/Logic/Lobby/MapPreviewLogic.cs | 13 +++++++++++-- .../Widgets/Logic/ServerCreationLogic.cs | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs index 96a2ab7335..ab919d5952 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs @@ -209,9 +209,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic { titleLabel.IsVisible = () => getMap().Map != MapCache.UnknownMap; var font = Game.Renderer.Fonts[titleLabel.Font]; - var title = new CachedTransform(m => WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font)); + var title = new CachedTransform(m => + { + var truncated = WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font); + + if (m.Title != truncated) + titleLabel.GetTooltipText = () => m.Title; + else + titleLabel.GetTooltipText = null; + + return truncated; + }); titleLabel.GetText = () => title.Update(getMap().Map); - titleLabel.GetTooltipText = () => getMap().Map.Title; } var typeLabel = parent.GetOrNull("MAP_TYPE"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs index e453d9053f..172fa5028d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs @@ -61,9 +61,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (titleLabel != null) { var font = Game.Renderer.Fonts[titleLabel.Font]; - var title = new CachedTransform(m => WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font)); + var title = new CachedTransform(m => + { + var truncated = WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font); + + if (m.Title != truncated) + titleLabel.GetTooltipText = () => m.Title; + else + titleLabel.GetTooltipText = null; + + return truncated; + }); titleLabel.GetText = () => title.Update(preview); - titleLabel.GetTooltipText = () => preview.Title; } var typeLabel = panel.GetOrNull("MAP_TYPE");