Make trait PowerTooltip
This commit is contained in:
@@ -293,6 +293,7 @@
|
|||||||
<Compile Include="Traits\Burns.cs" />
|
<Compile Include="Traits\Burns.cs" />
|
||||||
<Compile Include="Traits\C4Demolition.cs" />
|
<Compile Include="Traits\C4Demolition.cs" />
|
||||||
<Compile Include="Traits\Health.cs" />
|
<Compile Include="Traits\Health.cs" />
|
||||||
|
<Compile Include="Traits\PowerTooltip.cs" />
|
||||||
<Compile Include="Traits\VeteranProductionIconOverlay.cs" />
|
<Compile Include="Traits\VeteranProductionIconOverlay.cs" />
|
||||||
<Compile Include="Traits\Capturable.cs" />
|
<Compile Include="Traits\Capturable.cs" />
|
||||||
<Compile Include="Traits\CaptureNotification.cs" />
|
<Compile Include="Traits\CaptureNotification.cs" />
|
||||||
|
|||||||
53
OpenRA.Mods.Common/Traits/PowerTooltip.cs
Normal file
53
OpenRA.Mods.Common/Traits/PowerTooltip.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
{
|
||||||
|
[Desc("Shown power info on the build palette widget.")]
|
||||||
|
public class PowerTooltipInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public object Create(ActorInitializer init) { return new PowerTooltip(init.Self); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PowerTooltip : IProvideTooltipInfo, INotifyOwnerChanged
|
||||||
|
{
|
||||||
|
readonly Actor self;
|
||||||
|
PowerManager powerManager;
|
||||||
|
DeveloperMode developerMode;
|
||||||
|
|
||||||
|
public PowerTooltip(Actor self)
|
||||||
|
{
|
||||||
|
this.self = self;
|
||||||
|
powerManager = self.Owner.PlayerActor.Trait<PowerManager>();
|
||||||
|
developerMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsTooltipVisible(Player forPlayer)
|
||||||
|
{
|
||||||
|
return forPlayer == self.Owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TooltipText
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Power Usage: {0}{1}".F(powerManager.PowerDrained, developerMode.UnlimitedPower ? "" : "/" + powerManager.PowerProvided);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
|
{
|
||||||
|
powerManager = newOwner.PlayerActor.Trait<PowerManager>();
|
||||||
|
developerMode = newOwner.PlayerActor.Trait<DeveloperMode>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1092,6 +1092,7 @@ CTDAM:
|
|||||||
Dimensions: 2, 5
|
Dimensions: 2, 5
|
||||||
Power:
|
Power:
|
||||||
Amount: 200
|
Amount: 200
|
||||||
|
PowerTooltip:
|
||||||
Armor:
|
Armor:
|
||||||
Type: heavy
|
Type: heavy
|
||||||
Health:
|
Health:
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ GAPOWR:
|
|||||||
Amount: 100
|
Amount: 100
|
||||||
InfiltrateForPowerOutage:
|
InfiltrateForPowerOutage:
|
||||||
AffectedByPowerOutage:
|
AffectedByPowerOutage:
|
||||||
|
PowerTooltip:
|
||||||
Targetable:
|
Targetable:
|
||||||
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
|
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
|
||||||
ScalePowerWithHealth:
|
ScalePowerWithHealth:
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ NAPOWR:
|
|||||||
Targetable:
|
Targetable:
|
||||||
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
|
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
|
||||||
ScalePowerWithHealth:
|
ScalePowerWithHealth:
|
||||||
|
PowerTooltip:
|
||||||
DisabledOverlay:
|
DisabledOverlay:
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
VisualBounds: 88, 80, 2, -12
|
VisualBounds: 88, 80, 2, -12
|
||||||
@@ -69,6 +70,7 @@ NAAPWR:
|
|||||||
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
|
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
|
||||||
ScalePowerWithHealth:
|
ScalePowerWithHealth:
|
||||||
DisabledOverlay:
|
DisabledOverlay:
|
||||||
|
PowerTooltip:
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
VisualBounds: 100, 74, 0, -12
|
VisualBounds: 100, 74, 0, -12
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user