Add tooltip descriptions to support powers
This commit is contained in:
@@ -25,10 +25,15 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
widget.IsVisible = () => palette.TooltipPower != null;
|
widget.IsVisible = () => palette.TooltipPower != null;
|
||||||
var nameLabel = widget.GetWidget<LabelWidget>("NAME");
|
var nameLabel = widget.GetWidget<LabelWidget>("NAME");
|
||||||
var timeLabel = widget.GetWidget<LabelWidget>("TIME");
|
var timeLabel = widget.GetWidget<LabelWidget>("TIME");
|
||||||
|
var descLabel = widget.GetWidget<LabelWidget>("DESC");
|
||||||
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
|
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
|
||||||
var timeFont = Game.Renderer.Fonts[timeLabel.Font];
|
var timeFont = Game.Renderer.Fonts[timeLabel.Font];
|
||||||
|
var descFont = Game.Renderer.Fonts[descLabel.Font];
|
||||||
var name = "";
|
var name = "";
|
||||||
var time = "";
|
var time = "";
|
||||||
|
var desc = "";
|
||||||
|
var baseHeight = widget.Bounds.Height;
|
||||||
|
var timeOffset = timeLabel.Bounds.X;
|
||||||
|
|
||||||
SupportPowerManager.SupportPowerInstance lastPower = null;
|
SupportPowerManager.SupportPowerInstance lastPower = null;
|
||||||
tooltipContainer.BeforeRender = () =>
|
tooltipContainer.BeforeRender = () =>
|
||||||
@@ -44,13 +49,19 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
name = sp.Info.Description;
|
name = sp.Info.Description;
|
||||||
widget.Bounds.Width = 2*nameLabel.Bounds.X
|
desc = sp.Info.LongDesc.Replace("\\n", "\n");
|
||||||
+ Math.Max(nameFont.Measure(name).X, timeFont.Measure(time).X);
|
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;
|
lastPower = sp;
|
||||||
};
|
};
|
||||||
|
|
||||||
nameLabel.GetText = () => name;
|
nameLabel.GetText = () => name;
|
||||||
timeLabel.GetText = () => time;
|
timeLabel.GetText = () => time;
|
||||||
|
descLabel.GetText = () => desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,21 +87,28 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
Y:39
|
Y:39
|
||||||
Height:23
|
Height:23
|
||||||
Font:Bold
|
Font:Bold
|
||||||
|
|
||||||
Background@SUPPORT_POWER_TOOLTIP:
|
Background@SUPPORT_POWER_TOOLTIP:
|
||||||
Id:SUPPORT_POWER_TOOLTIP
|
Id:SUPPORT_POWER_TOOLTIP
|
||||||
Logic:SupportPowerTooltipLogic
|
Logic:SupportPowerTooltipLogic
|
||||||
Background:panel-black
|
Background:panel-black
|
||||||
Width:200
|
Width:200
|
||||||
Height:45
|
Height:25
|
||||||
Children:
|
Children:
|
||||||
Label@NAME:
|
Label@NAME:
|
||||||
Id:NAME
|
Id:NAME
|
||||||
X:5
|
X:5
|
||||||
Height:23
|
Height:20
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Label@TIME:
|
Label@TIME:
|
||||||
Id:TIME
|
Id:TIME
|
||||||
|
X:20
|
||||||
|
Y:6
|
||||||
|
Font:TinyBold
|
||||||
|
VAlign:Top
|
||||||
|
Label@DESC:
|
||||||
|
Id:DESC
|
||||||
X:5
|
X:5
|
||||||
Y:19
|
Y:20
|
||||||
Height:23
|
Font:TinyBold
|
||||||
Font:Bold
|
VAlign:Top
|
||||||
@@ -331,8 +331,8 @@ HQ:
|
|||||||
AirstrikePower:
|
AirstrikePower:
|
||||||
Image: bombicnh
|
Image: bombicnh
|
||||||
ChargeTime: 240
|
ChargeTime: 240
|
||||||
Description: Airstrike
|
Description: Air Strike
|
||||||
LongDesc: Delivers a load of napalm on your target.
|
LongDesc: Deploy an aerial napalm strike.\nBurns buildings and infantry along a line.
|
||||||
EndChargeSound: airredy1.aud
|
EndChargeSound: airredy1.aud
|
||||||
SelectTargetSound: select1.aud
|
SelectTargetSound: select1.aud
|
||||||
UnitType: a10
|
UnitType: a10
|
||||||
@@ -459,7 +459,7 @@ EYE:
|
|||||||
Image: ionicnh
|
Image: ionicnh
|
||||||
ChargeTime: 180
|
ChargeTime: 180
|
||||||
Description: Ion Cannon
|
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
|
BeginChargeSound: ionchrg1.aud
|
||||||
EndChargeSound: ionredy1.aud
|
EndChargeSound: ionredy1.aud
|
||||||
LaunchSound: ion1.aud
|
LaunchSound: ion1.aud
|
||||||
@@ -492,8 +492,8 @@ TMPL:
|
|||||||
NukePower:
|
NukePower:
|
||||||
Image: atomicnh
|
Image: atomicnh
|
||||||
ChargeTime: 300
|
ChargeTime: 300
|
||||||
Description: Atom Bomb
|
Description: Nuclear Strike
|
||||||
LongDesc: Launches a nuclear missile at a target location.
|
LongDesc: Launch a tactical nuke.\nApplies heavy damage over a large area.
|
||||||
BeginChargeSound:
|
BeginChargeSound:
|
||||||
EndChargeSound: nukavail.aud
|
EndChargeSound: nukavail.aud
|
||||||
SelectTargetSound: select1.aud
|
SelectTargetSound: select1.aud
|
||||||
|
|||||||
Reference in New Issue
Block a user