From cbc8d1c5ec48af677a9ef457280a8ec13b9883bb Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Sat, 7 Nov 2015 14:34:47 -0600 Subject: [PATCH 1/3] Multiline support for SimpleTooltipLogic --- .../Widgets/Logic/SimpleTooltipLogic.cs | 15 ++++++++++++--- mods/cnc/chrome/tooltips.yaml | 2 +- mods/d2k/chrome/tooltips.yaml | 2 +- mods/ra/chrome/tooltips.yaml | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/SimpleTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SimpleTooltipLogic.cs index de350cb159..1054cf6c3d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SimpleTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SimpleTooltipLogic.cs @@ -22,17 +22,26 @@ namespace OpenRA.Mods.Common.Widgets.Logic var font = Game.Renderer.Fonts[label.Font]; var cachedWidth = 0; + var cachedHeight = 0; + var horizontalPadding = label.Bounds.Width - widget.Bounds.Width; + if (horizontalPadding <= 0) + horizontalPadding = 2 * label.Bounds.X; + var vertcalPadding = widget.Bounds.Height - label.Bounds.Height; + if (vertcalPadding <= 0) + vertcalPadding = 2 * label.Bounds.Y; var labelText = ""; tooltipContainer.BeforeRender = () => { labelText = getText(); var textDim = font.Measure(labelText); - if (textDim.X != cachedWidth) + if (textDim.X != cachedWidth || textDim.Y != cachedHeight) { label.Bounds.Width = textDim.X; - widget.Bounds.Width = 2 * label.Bounds.X + textDim.X; + widget.Bounds.Width = horizontalPadding + textDim.X; label.Bounds.Height = textDim.Y; - widget.Bounds.Height = 4 * label.Bounds.Y + textDim.Y; + widget.Bounds.Height = vertcalPadding + textDim.Y; + cachedWidth = textDim.X; + cachedHeight = textDim.Y; } }; diff --git a/mods/cnc/chrome/tooltips.yaml b/mods/cnc/chrome/tooltips.yaml index 97a440feb5..4edecb9033 100644 --- a/mods/cnc/chrome/tooltips.yaml +++ b/mods/cnc/chrome/tooltips.yaml @@ -1,7 +1,7 @@ Background@SIMPLE_TOOLTIP: Logic: SimpleTooltipLogic Background: panel-black - Height: 25 + Height: 27 Children: Label@LABEL: X: 5 diff --git a/mods/d2k/chrome/tooltips.yaml b/mods/d2k/chrome/tooltips.yaml index 7a664d7289..5d3843c90a 100644 --- a/mods/d2k/chrome/tooltips.yaml +++ b/mods/d2k/chrome/tooltips.yaml @@ -1,7 +1,7 @@ Background@SIMPLE_TOOLTIP: Logic: SimpleTooltipLogic Background: dialog3 - Height: 31 + Height: 34 Children: Label@LABEL: X: 5 diff --git a/mods/ra/chrome/tooltips.yaml b/mods/ra/chrome/tooltips.yaml index d7b2f375e1..455a225bbe 100644 --- a/mods/ra/chrome/tooltips.yaml +++ b/mods/ra/chrome/tooltips.yaml @@ -1,7 +1,7 @@ Background@SIMPLE_TOOLTIP: Logic: SimpleTooltipLogic Background: dialog4 - Height: 29 + Height: 32 Children: Label@LABEL: X: 7 From 4c2488f9b1e66146abc5dd0ce034cfc58eec2a99 Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Sat, 7 Nov 2015 14:37:50 -0600 Subject: [PATCH 2/3] Made editor actor preview tooltip easier to read --- OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs b/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs index 9255bb1e27..9c75a1b77d 100644 --- a/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs +++ b/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs @@ -70,7 +70,8 @@ namespace OpenRA.Mods.Common.Traits } var tooltip = Info.TraitInfoOrDefault(); - Tooltip = tooltip == null ? ID + ": " + Info.Name : ID + ": " + tooltip.Name + " (" + Info.Name + ")" + "\n" + owner.Name + " (" + owner.Faction + ")"; + Tooltip = (tooltip == null ? " < " + Info.Name + " >" : tooltip.Name) + "\n" + owner.Name + " (" + owner.Faction + ")" + + "\nID: " + ID + "\nType: " + Info.Name; GeneratePreviews(); From 9c0d83d0d975382b1b3b0ee9caf8acecb06cf621 Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Fri, 6 Nov 2015 03:39:24 -0600 Subject: [PATCH 3/3] Make ActorSelector tooltips better match actor tooltips in map editor --- .../Widgets/Logic/Editor/ActorSelectorLogic.cs | 2 +- mods/cnc/chrome/editor.yaml | 1 + mods/cnc/chrome/tooltips.yaml | 15 +++++++++++++++ mods/d2k/chrome/tooltips.yaml | 17 +++++++++++++++++ mods/ra/chrome/editor.yaml | 1 + mods/ra/chrome/tooltips.yaml | 17 +++++++++++++++++ 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs index 86f36e6d07..266f7464b3 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs @@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic item.IsVisible = () => true; var tooltip = actor.TraitInfoOrDefault(); - item.GetTooltipText = () => tooltip == null ? actor.Name : tooltip.Name + " (" + actor.Name + ")"; + item.GetTooltipText = () => (tooltip == null ? "\nType: " : tooltip.Name + "\nType: ") + actor.Name; panel.AddChild(item); } diff --git a/mods/cnc/chrome/editor.yaml b/mods/cnc/chrome/editor.yaml index f05ab8c091..f1ea147ec7 100644 --- a/mods/cnc/chrome/editor.yaml +++ b/mods/cnc/chrome/editor.yaml @@ -329,6 +329,7 @@ Container@EDITOR_WORLD_ROOT: Visible: false Width: PARENT_RIGHT - 35 TooltipContainer: TOOLTIP_CONTAINER + TooltipTemplate: TWO_LINE_TOOLTIP IgnoreChildMouseOver: true Children: ActorPreview@ACTOR_PREVIEW: diff --git a/mods/cnc/chrome/tooltips.yaml b/mods/cnc/chrome/tooltips.yaml index 4edecb9033..8d4d470f6a 100644 --- a/mods/cnc/chrome/tooltips.yaml +++ b/mods/cnc/chrome/tooltips.yaml @@ -8,6 +8,21 @@ Background@SIMPLE_TOOLTIP: Height: 23 Font: Bold +Background@TWO_LINE_TOOLTIP: + Logic: ButtonTooltipLogic + Background: panel-black + Height: 48 + Children: + Label@LABEL: + X: 5 + Height: 46 + Font: Bold + Label@HOTKEY: + Visible: false + TextColor: FFFF00 + Height: 23 + Font: Bold + Background@BUTTON_TOOLTIP: Logic: ButtonTooltipLogic Background: panel-black diff --git a/mods/d2k/chrome/tooltips.yaml b/mods/d2k/chrome/tooltips.yaml index 5d3843c90a..1417d3b3af 100644 --- a/mods/d2k/chrome/tooltips.yaml +++ b/mods/d2k/chrome/tooltips.yaml @@ -9,6 +9,23 @@ Background@SIMPLE_TOOLTIP: Height: 23 Font: Bold +Background@TWO_LINE_TOOLTIP: + Logic: ButtonTooltipLogic + Background: dialog3 + Height: 54 + Children: + Label@LABEL: + X: 5 + Y: 3 + Height: 46 + Font: Bold + Label@HOTKEY: + Visible: false + Y: 3 + Height: 23 + TextColor: FFFF00 + Font: Bold + Background@BUTTON_TOOLTIP: Logic: ButtonTooltipLogic Background: dialog3 diff --git a/mods/ra/chrome/editor.yaml b/mods/ra/chrome/editor.yaml index 27ba3622ba..d3a06af92f 100644 --- a/mods/ra/chrome/editor.yaml +++ b/mods/ra/chrome/editor.yaml @@ -307,6 +307,7 @@ Container@EDITOR_WORLD_ROOT: Visible: false Width: PARENT_RIGHT - 35 TooltipContainer: TOOLTIP_CONTAINER + TooltipTemplate: TWO_LINE_TOOLTIP IgnoreChildMouseOver: true Children: ActorPreview@ACTOR_PREVIEW: diff --git a/mods/ra/chrome/tooltips.yaml b/mods/ra/chrome/tooltips.yaml index 455a225bbe..ba039de479 100644 --- a/mods/ra/chrome/tooltips.yaml +++ b/mods/ra/chrome/tooltips.yaml @@ -9,6 +9,23 @@ Background@SIMPLE_TOOLTIP: Height: 23 Font: Bold +Background@TWO_LINE_TOOLTIP: + Logic: ButtonTooltipLogic + Background: dialog4 + Height: 52 + Children: + Label@LABEL: + X: 7 + Y: 2 + Height: 46 + Font: Bold + Label@HOTKEY: + Visible: false + Y: 2 + Height: 23 + TextColor: FFFF00 + Font: Bold + Background@BUTTON_TOOLTIP: Logic: ButtonTooltipLogic Background: dialog4