diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 06b487b7e5..2ab7f4b10c 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -590,7 +590,6 @@ - diff --git a/OpenRA.Mods.Common/Widgets/Logic/FactionTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/FactionTooltipLogic.cs deleted file mode 100644 index 02ec0f36e8..0000000000 --- a/OpenRA.Mods.Common/Widgets/Logic/FactionTooltipLogic.cs +++ /dev/null @@ -1,53 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2017 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using System; -using System.Linq; -using OpenRA.Widgets; - -namespace OpenRA.Mods.Common.Widgets.Logic -{ - public class FactionTooltipLogic : ChromeLogic - { - [ObjectCreator.UseCtor] - public FactionTooltipLogic(Widget widget, ButtonWidget button) - { - var lines = button.GetTooltipText().Replace("\\n", "\n").Split('\n'); - - var header = widget.Get("HEADER"); - var headerLine = lines[0]; - var headerFont = Game.Renderer.Fonts[header.Font]; - var headerSize = headerFont.Measure(headerLine); - header.Bounds.Width += headerSize.X; - header.Bounds.Height += headerSize.Y; - header.GetText = () => headerLine; - - if (lines.Length > 1) - { - var description = widget.Get("DESCRIPTION"); - var descriptionLines = lines.Skip(1).ToArray(); - var descriptionFont = Game.Renderer.Fonts[description.Font]; - description.Bounds.Y += header.Bounds.Y + header.Bounds.Height; - description.Bounds.Width += descriptionLines.Select(l => descriptionFont.Measure(l).X).Max(); - description.Bounds.Height += descriptionFont.Measure(descriptionLines.First()).Y * descriptionLines.Length; - description.GetText = () => string.Join("\n", descriptionLines); - - widget.Bounds.Width = Math.Max(header.Bounds.X + header.Bounds.Width, description.Bounds.X + description.Bounds.Width); - widget.Bounds.Height = description.Bounds.Y + description.Bounds.Height; - } - else - { - widget.Bounds.Width = header.Bounds.X + header.Bounds.Width; - widget.Bounds.Height = header.Bounds.Y + header.Bounds.Height; - } - } - } -} \ No newline at end of file diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index 1d13b1c765..660c28141d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -118,7 +118,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic var flag = item.Get("FLAG"); flag.GetImageCollection = () => "flags"; flag.GetImageName = () => factionId; - item.GetTooltipText = () => faction.Description; + + var factionName = faction.Description.SubstringBefore("\\n", StringComparison.Ordinal); + var factionDescription = faction.Description.SubstringAfter("\\n", StringComparison.Ordinal); + item.GetTooltipText = () => factionName; + if (factionDescription != factionName) + item.GetTooltipDesc = () => factionDescription; + return item; }; @@ -408,8 +414,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic var dropdown = parent.Get("FACTION"); dropdown.IsDisabled = () => s.LockFaction || orderManager.LocalClient.IsReady; dropdown.OnMouseDown = _ => ShowFactionDropDown(dropdown, c, orderManager, factions); - var factionDescription = factions[c.Faction].Description; - dropdown.GetTooltipText = () => factionDescription; + + var factionName = factions[c.Faction].Description.SubstringBefore("\\n", StringComparison.Ordinal); + var factionDescription = factions[c.Faction].Description.SubstringAfter("\\n", StringComparison.Ordinal); + dropdown.GetTooltipText = () => factionName; + if (factionDescription != factionName) + dropdown.GetTooltipDesc = () => factionDescription; + SetupFactionWidget(dropdown, s, c, factions); } diff --git a/mods/cnc/chrome/dialogs.yaml b/mods/cnc/chrome/dialogs.yaml index e677084c08..ad88a45018 100644 --- a/mods/cnc/chrome/dialogs.yaml +++ b/mods/cnc/chrome/dialogs.yaml @@ -50,7 +50,6 @@ ScrollPanel@FACTION_DROPDOWN_TEMPLATE: Y: 0 Visible: false TooltipContainer: TOOLTIP_CONTAINER - TooltipTemplate: FACTION_DESCRIPTION_TOOLTIP Children: Image@FLAG: X: 4 diff --git a/mods/cnc/chrome/lobby-players.yaml b/mods/cnc/chrome/lobby-players.yaml index c2171c02f5..8a830baa8b 100644 --- a/mods/cnc/chrome/lobby-players.yaml +++ b/mods/cnc/chrome/lobby-players.yaml @@ -116,7 +116,6 @@ Container@LOBBY_PLAYER_BIN: Font: Regular IgnoreChildMouseOver: true TooltipContainer: TOOLTIP_CONTAINER - TooltipTemplate: FACTION_DESCRIPTION_TOOLTIP PanelRoot: FACTION_DROPDOWN_PANEL_ROOT # ensure that tooltips for the options are on top of the dropdown panel Children: Image@FACTIONFLAG: diff --git a/mods/cnc/chrome/tooltips.yaml b/mods/cnc/chrome/tooltips.yaml index eb77bdca1a..bf4c08aaa8 100644 --- a/mods/cnc/chrome/tooltips.yaml +++ b/mods/cnc/chrome/tooltips.yaml @@ -245,22 +245,3 @@ Background@INGAME_CLIENT_TOOLTIP: Height: 10 Font: TinyBold Align: Center - -Background@FACTION_DESCRIPTION_TOOLTIP: - Logic: FactionTooltipLogic - Background: panel-black - Children: - Label@HEADER: - X: 7 - Y: 6 - Width: 8 - Height: 12 - Font: Bold - VAlign: Top - Label@DESCRIPTION: - X: 14 - Y: 0 - Width: 15 - Height: 14 - Font: TinyBold - VAlign: Top diff --git a/mods/common/chrome/lobby-players.yaml b/mods/common/chrome/lobby-players.yaml index a4bb0d26bf..2b4db69cfc 100644 --- a/mods/common/chrome/lobby-players.yaml +++ b/mods/common/chrome/lobby-players.yaml @@ -112,7 +112,6 @@ Container@LOBBY_PLAYER_BIN: Height: 25 IgnoreChildMouseOver: true TooltipContainer: TOOLTIP_CONTAINER - TooltipTemplate: FACTION_DESCRIPTION_TOOLTIP PanelRoot: FACTION_DROPDOWN_PANEL_ROOT # ensure that tooltips for the options are on top of the dropdown panel Children: Image@FACTIONFLAG: @@ -412,7 +411,6 @@ ScrollPanel@FACTION_DROPDOWN_TEMPLATE: Y: 0 Visible: false TooltipContainer: TOOLTIP_CONTAINER - TooltipTemplate: FACTION_DESCRIPTION_TOOLTIP Children: Image@FLAG: X: 5 diff --git a/mods/common/chrome/tooltips.yaml b/mods/common/chrome/tooltips.yaml index ec84c43250..f36ee74561 100644 --- a/mods/common/chrome/tooltips.yaml +++ b/mods/common/chrome/tooltips.yaml @@ -254,22 +254,3 @@ Background@SUPPORT_POWER_TOOLTIP: Y: 22 Font: TinyBold VAlign: Top - -Background@FACTION_DESCRIPTION_TOOLTIP: - Logic: FactionTooltipLogic - Background: dialog4 - Children: - Label@HEADER: - X: 7 - Y: 6 - Width: 8 - Height: 12 - Font: Bold - VAlign: Top - Label@DESCRIPTION: - X: 14 - Y: 0 - Width: 15 - Height: 14 - Font: TinyBold - VAlign: Top diff --git a/mods/d2k/chrome/lobby-players.yaml b/mods/d2k/chrome/lobby-players.yaml index 6040c8e0fe..f87ba52521 100644 --- a/mods/d2k/chrome/lobby-players.yaml +++ b/mods/d2k/chrome/lobby-players.yaml @@ -112,7 +112,6 @@ Container@LOBBY_PLAYER_BIN: Height: 25 IgnoreChildMouseOver: true TooltipContainer: TOOLTIP_CONTAINER - TooltipTemplate: FACTION_DESCRIPTION_TOOLTIP PanelRoot: FACTION_DROPDOWN_PANEL_ROOT # ensure that tooltips for the options are on top of the dropdown panel Children: Image@FACTIONFLAG: @@ -412,7 +411,6 @@ ScrollPanel@FACTION_DROPDOWN_TEMPLATE: Y: 0 Visible: false TooltipContainer: TOOLTIP_CONTAINER - TooltipTemplate: FACTION_DESCRIPTION_TOOLTIP Children: Image@FLAG: X: 2 diff --git a/mods/d2k/chrome/tooltips.yaml b/mods/d2k/chrome/tooltips.yaml index 45d8d1dbe8..5777a33f4f 100644 --- a/mods/d2k/chrome/tooltips.yaml +++ b/mods/d2k/chrome/tooltips.yaml @@ -230,22 +230,3 @@ Background@SUPPORT_POWER_TOOLTIP: Y: 28 Font: TinyBold VAlign: Top - -Background@FACTION_DESCRIPTION_TOOLTIP: - Logic: FactionTooltipLogic - Background: dialog3 - Children: - Label@HEADER: - X: 7 - Y: 7 - Width: 8 - Height: 10 - Font: Bold - VAlign: Top - Label@DESCRIPTION: - X: 14 - Y: 0 - Width: 15 - Height: 14 - Font: TinyBold - VAlign: Top