Make trait PowerTooltip

This commit is contained in:
DnAp
2015-12-28 23:26:50 +03:00
parent 43b2957331
commit c4b925ffc3
5 changed files with 58 additions and 0 deletions

View File

@@ -293,6 +293,7 @@
<Compile Include="Traits\Burns.cs" />
<Compile Include="Traits\C4Demolition.cs" />
<Compile Include="Traits\Health.cs" />
<Compile Include="Traits\PowerTooltip.cs" />
<Compile Include="Traits\VeteranProductionIconOverlay.cs" />
<Compile Include="Traits\Capturable.cs" />
<Compile Include="Traits\CaptureNotification.cs" />

View 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>();
}
}
}

View File

@@ -1092,6 +1092,7 @@ CTDAM:
Dimensions: 2, 5
Power:
Amount: 200
PowerTooltip:
Armor:
Type: heavy
Health:

View File

@@ -30,6 +30,7 @@ GAPOWR:
Amount: 100
InfiltrateForPowerOutage:
AffectedByPowerOutage:
PowerTooltip:
Targetable:
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
ScalePowerWithHealth:

View File

@@ -31,6 +31,7 @@ NAPOWR:
Targetable:
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
ScalePowerWithHealth:
PowerTooltip:
DisabledOverlay:
SelectionDecorations:
VisualBounds: 88, 80, 2, -12
@@ -69,6 +70,7 @@ NAAPWR:
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
ScalePowerWithHealth:
DisabledOverlay:
PowerTooltip:
SelectionDecorations:
VisualBounds: 100, 74, 0, -12