From c3e8a900dcec1c6a974fd3057b4dc80d8a40e595 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 25 Jan 2010 22:07:33 +1300 Subject: [PATCH] #44 fixed --- OpenRa.Game/Chrome.cs | 4 ++-- OpenRa.Game/Traits/SupportPower.cs | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 7111bd893f..e7b55d2ad7 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -932,10 +932,10 @@ namespace OpenRa shpRenderer.DrawSprite(ready.Image, drawPos + new float2((64 - ready.Image.size.X) / 2, 2), PaletteType.Chrome); - - AddButton(rect, HandleSupportPower( sp )); } + AddButton(rect, HandleSupportPower(sp)); + if (rect.Contains(lastMousePos.ToPoint())) { tooltipItem = sp; diff --git a/OpenRa.Game/Traits/SupportPower.cs b/OpenRa.Game/Traits/SupportPower.cs index 1ed738baed..41f4dcd12a 100644 --- a/OpenRa.Game/Traits/SupportPower.cs +++ b/OpenRa.Game/Traits/SupportPower.cs @@ -102,6 +102,21 @@ namespace OpenRa.Traits protected virtual void OnFinishCharging() { } protected virtual void OnActivate() { } - public void Activate() { OnActivate(); } // todo: some more hax + public void Activate() + { + if (!IsAvailable || !IsReady) + { + Sound.Play("briefing.aud"); + return; + } + + if (Info.RequiresPower && Owner.GetPowerState() != PowerState.Normal) + { + Sound.Play("nopowr1.aud"); + return; + } + + OnActivate(); + } } }