From 7a1169744e8ed1bbdc616e1ec33ac1321d086fc6 Mon Sep 17 00:00:00 2001 From: Ivaylo Draganov Date: Wed, 23 Jun 2021 16:04:16 +0300 Subject: [PATCH] Add tooltips to map name and author in map chooser --- .../Widgets/Logic/MapChooserLogic.cs | 12 ++++------ mods/cnc/chrome/mapchooser.yaml | 22 ++++++++++++++----- mods/common/chrome/map-chooser.yaml | 22 ++++++++++++++----- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs index 8545ae0312..db18021e35 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs @@ -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("TITLE"); + var titleLabel = item.Get("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("PREVIEW"); @@ -276,12 +274,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic detailsWidget.GetText = () => details; } - var authorWidget = item.GetOrNull("AUTHOR"); + var authorWidget = item.GetOrNull("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("SIZE"); diff --git a/mods/cnc/chrome/mapchooser.yaml b/mods/cnc/chrome/mapchooser.yaml index 8da7d62305..e0446c102d 100644 --- a/mods/cnc/chrome/mapchooser.yaml +++ b/mods/cnc/chrome/mapchooser.yaml @@ -80,6 +80,7 @@ Container@MAPCHOOSER_PANEL: Height: 262 X: 1 Visible: false + EnableChildMouseOver: True Children: MapPreview@PREVIEW: X: (PARENT_RIGHT - WIDTH) / 2 @@ -88,27 +89,35 @@ Container@MAPCHOOSER_PANEL: Height: 204 IgnoreMouseOver: true IgnoreMouseInput: true - Label@TITLE: + LabelWithTooltip@TITLE: X: 4 - Y: PARENT_BOTTOM - 46 + Y: PARENT_BOTTOM - HEIGHT - 33 Width: PARENT_RIGHT - 8 + Height: 24 Align: Center + TooltipContainer: TOOLTIP_CONTAINER + TooltipTemplate: SIMPLE_TOOLTIP Label@DETAILS: Width: PARENT_RIGHT - 8 + Height: 12 X: 4 - Y: PARENT_BOTTOM - 32 + Y: PARENT_BOTTOM - HEIGHT - 26 Align: Center Font: Tiny - Label@AUTHOR: + LabelWithTooltip@AUTHOR: Width: PARENT_RIGHT - 8 + Height: 12 X: 4 - Y: PARENT_BOTTOM - 20 + Y: PARENT_BOTTOM - HEIGHT - 14 Align: Center Font: Tiny + TooltipContainer: TOOLTIP_CONTAINER + TooltipTemplate: SIMPLE_TOOLTIP Label@SIZE: Width: PARENT_RIGHT - 8 + Height: 12 X: 4 - Y: PARENT_BOTTOM - 8 + Y: PARENT_BOTTOM - HEIGHT - 2 Align: Center Font: Tiny Button@BUTTON_CANCEL: @@ -143,3 +152,4 @@ Container@MAPCHOOSER_PANEL: Width: 140 Height: 35 Text: Ok + TooltipContainer@TOOLTIP_CONTAINER: diff --git a/mods/common/chrome/map-chooser.yaml b/mods/common/chrome/map-chooser.yaml index 07f1f6f86a..44e709d4f1 100644 --- a/mods/common/chrome/map-chooser.yaml +++ b/mods/common/chrome/map-chooser.yaml @@ -51,6 +51,7 @@ Background@MAPCHOOSER_PANEL: Height: 266 X: 2 Visible: false + EnableChildMouseOver: True Children: MapPreview@PREVIEW: X: (PARENT_RIGHT - WIDTH) / 2 @@ -59,27 +60,35 @@ Background@MAPCHOOSER_PANEL: Height: 202 IgnoreMouseOver: true IgnoreMouseInput: true - Label@TITLE: + LabelWithTooltip@TITLE: X: 4 - Y: PARENT_BOTTOM - 52 + Y: PARENT_BOTTOM - HEIGHT - 39 Width: PARENT_RIGHT - 8 + Height: 24 Align: Center + TooltipContainer: TOOLTIP_CONTAINER + TooltipTemplate: SIMPLE_TOOLTIP Label@DETAILS: Width: PARENT_RIGHT - 8 + Height: 12 X: 4 - Y: PARENT_BOTTOM - 36 + Y: PARENT_BOTTOM - HEIGHT - 30 Align: Center Font: Tiny - Label@AUTHOR: + LabelWithTooltip@AUTHOR: Width: PARENT_RIGHT - 8 + Height: 12 X: 4 - Y: PARENT_BOTTOM - 24 + Y: PARENT_BOTTOM - HEIGHT - 18 Align: Center Font: Tiny + TooltipContainer: TOOLTIP_CONTAINER + TooltipTemplate: SIMPLE_TOOLTIP Label@SIZE: Width: PARENT_RIGHT - 8 + Height: 12 X: 4 - Y: PARENT_BOTTOM - 12 + Y: PARENT_BOTTOM - HEIGHT - 6 Align: Center Font: Tiny Label@FILTER_DESC: @@ -145,3 +154,4 @@ Background@MAPCHOOSER_PANEL: Text: Back Font: Bold Key: escape + TooltipContainer@TOOLTIP_CONTAINER: