Merge pull request #9925 from atlimit8/MultiLineMapEditorTooltips

Multi-line map editor tooltips
This commit is contained in:
Oliver Brakmann
2015-11-10 21:06:57 +01:00
8 changed files with 69 additions and 8 deletions

View File

@@ -70,7 +70,8 @@ namespace OpenRA.Mods.Common.Traits
}
var tooltip = Info.TraitInfoOrDefault<TooltipInfo>();
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();

View File

@@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
item.IsVisible = () => true;
var tooltip = actor.TraitInfoOrDefault<TooltipInfo>();
item.GetTooltipText = () => tooltip == null ? actor.Name : tooltip.Name + " (" + actor.Name + ")";
item.GetTooltipText = () => (tooltip == null ? "\nType: " : tooltip.Name + "\nType: ") + actor.Name;
panel.AddChild(item);
}

View File

@@ -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;
}
};