Add tooltip descriptions to support powers

This commit is contained in:
Paul Chote
2011-07-07 02:18:38 +12:00
parent 5b2d2265e3
commit 32322b1658
3 changed files with 30 additions and 12 deletions

View File

@@ -25,10 +25,15 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
widget.IsVisible = () => palette.TooltipPower != null;
var nameLabel = widget.GetWidget<LabelWidget>("NAME");
var timeLabel = widget.GetWidget<LabelWidget>("TIME");
var descLabel = widget.GetWidget<LabelWidget>("DESC");
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
var timeFont = Game.Renderer.Fonts[timeLabel.Font];
var descFont = Game.Renderer.Fonts[descLabel.Font];
var name = "";
var time = "";
var desc = "";
var baseHeight = widget.Bounds.Height;
var timeOffset = timeLabel.Bounds.X;
SupportPowerManager.SupportPowerInstance lastPower = null;
tooltipContainer.BeforeRender = () =>
@@ -44,13 +49,19 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
return;
name = sp.Info.Description;
widget.Bounds.Width = 2*nameLabel.Bounds.X
+ Math.Max(nameFont.Measure(name).X, timeFont.Measure(time).X);
desc = sp.Info.LongDesc.Replace("\\n", "\n");
var timeWidth = timeFont.Measure(time).X;
var topWidth = nameFont.Measure(name).X + timeWidth + timeOffset;
var descSize = descFont.Measure(desc);
widget.Bounds.Width = 2*nameLabel.Bounds.X + Math.Max(topWidth, descSize.X);
widget.Bounds.Height = baseHeight + descSize.Y;
timeLabel.Bounds.X = widget.Bounds.Width - nameLabel.Bounds.X - timeWidth;
lastPower = sp;
};
nameLabel.GetText = () => name;
timeLabel.GetText = () => time;
descLabel.GetText = () => desc;
}
}
}

View File

@@ -87,21 +87,28 @@ Background@PRODUCTION_TOOLTIP:
Y:39
Height:23
Font:Bold
Background@SUPPORT_POWER_TOOLTIP:
Id:SUPPORT_POWER_TOOLTIP
Logic:SupportPowerTooltipLogic
Background:panel-black
Width:200
Height:45
Height:25
Children:
Label@NAME:
Id:NAME
X:5
Height:23
Height:20
Font:Bold
Label@TIME:
Id:TIME
X:20
Y:6
Font:TinyBold
VAlign:Top
Label@DESC:
Id:DESC
X:5
Y:19
Height:23
Font:Bold
Y:20
Font:TinyBold
VAlign:Top

View File

@@ -331,8 +331,8 @@ HQ:
AirstrikePower:
Image: bombicnh
ChargeTime: 240
Description: Airstrike
LongDesc: Delivers a load of napalm on your target.
Description: Air Strike
LongDesc: Deploy an aerial napalm strike.\nBurns buildings and infantry along a line.
EndChargeSound: airredy1.aud
SelectTargetSound: select1.aud
UnitType: a10
@@ -459,7 +459,7 @@ EYE:
Image: ionicnh
ChargeTime: 180
Description: Ion Cannon
LongDesc: Discharges the orbital Ion Cannon at your target.
LongDesc: Initiate an Ion Cannon strike.\nApplies instant damage to a small area.
BeginChargeSound: ionchrg1.aud
EndChargeSound: ionredy1.aud
LaunchSound: ion1.aud
@@ -492,8 +492,8 @@ TMPL:
NukePower:
Image: atomicnh
ChargeTime: 300
Description: Atom Bomb
LongDesc: Launches a nuclear missile at a target location.
Description: Nuclear Strike
LongDesc: Launch a tactical nuke.\nApplies heavy damage over a large area.
BeginChargeSound:
EndChargeSound: nukavail.aud
SelectTargetSound: select1.aud