From 17cf890dce7c80faf19aeef104732a9c055f67f1 Mon Sep 17 00:00:00 2001 From: Kanar Date: Mon, 27 Jan 2014 04:29:32 +0100 Subject: [PATCH] Enables "insufficient power"-speech in RA and C&C when powered-down supportpowerwidget is clicked --- OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs | 4 ++++ OpenRA.Mods.RA/SupportPowers/SupportPower.cs | 1 + OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs | 3 ++- OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs | 10 +++++++++- mods/cnc/notifications.yaml | 1 - mods/cnc/rules/structures.yaml | 3 +++ mods/d2k/notifications.yaml | 1 - mods/ra/notifications.yaml | 1 - mods/ra/rules/structures.yaml | 3 +++ mods/ts/notifications.yaml | 1 - 10 files changed, 22 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs index 3a970da1b9..8bfcaf7ccc 100755 --- a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs @@ -168,7 +168,11 @@ namespace OpenRA.Mods.Cnc.Widgets .Select(i => i.Value).FirstOrDefault(); if (clicked != null) + { + if (!clicked.Power.Active) + Sound.PlayToPlayer(spm.self.Owner, clicked.Power.Info.InsufficientPowerSound); spm.Target(clicked.Power.Info.OrderName); + } return true; } diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs index 3695eb44fc..da5deaae1d 100755 --- a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs @@ -24,6 +24,7 @@ namespace OpenRA.Mods.RA public readonly string BeginChargeSound = null; public readonly string EndChargeSound = null; public readonly string SelectTargetSound = null; + public readonly string InsufficientPowerSound = null; public readonly string LaunchSound = null; public readonly string IncomingSound = null; diff --git a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs index 50ad00bb9f..232fd41976 100755 --- a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs @@ -370,8 +370,9 @@ namespace OpenRA.Mods.RA.Widgets // Check if the item's build-limit has already been reached var queued = CurrentQueue.AllQueued().Count(a => a.Item == unit.Name); var inWorld = world.ActorsWithTrait().Count(a => a.Actor.Info.Name == unit.Name && a.Actor.Owner == world.LocalPlayer); + var buildLimit = unit.Traits.Get().BuildLimit; - if (!((unit.Traits.Get().BuildLimit != 0) && (inWorld + queued >= unit.Traits.Get().BuildLimit))) + if (!((buildLimit != 0) && (inWorld + queued >= buildLimit))) Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, world.LocalPlayer.Country.Race); else Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.BlockedAudio, world.LocalPlayer.Country.Race); diff --git a/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs b/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs index 13436ab4f6..888892082f 100755 --- a/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs +++ b/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs @@ -167,7 +167,15 @@ namespace OpenRA.Mods.RA.Widgets Action HandleSupportPower(string key, SupportPowerManager manager) { - return mi => { if (mi.Button == MouseButton.Left) manager.Target(key); }; + return mi => + { + if (mi.Button == MouseButton.Left) + { + if (!manager.Powers[key].Active) + Sound.PlayToPlayer(manager.self.Owner, manager.Powers[key].Info.InsufficientPowerSound); + manager.Target(key); + } + }; } } } \ No newline at end of file diff --git a/mods/cnc/notifications.yaml b/mods/cnc/notifications.yaml index 5d22b539fc..332fb91e32 100644 --- a/mods/cnc/notifications.yaml +++ b/mods/cnc/notifications.yaml @@ -9,7 +9,6 @@ Speech: PrimaryBuildingSelected: pribldg1 BuildingCannotPlaceAudio: deploy1 NewOptions: newopt1 - AbilityInsufficientPower: nopower1 Win: accom1 Lose: fail1 BaseAttack: baseatk1 diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 9260045946..cc94c520c9 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -379,6 +379,7 @@ HQ: LongDesc: Deploy an aerial napalm strike.\nBurns buildings and infantry along a line. EndChargeSound: airredy1.aud SelectTargetSound: select1.aud + InsufficientPowerSound: nopower1.aud IncomingSound: enemya.aud UnitType: a10 SupportPowerChargeBar: @@ -443,6 +444,7 @@ EYE: EndChargeSound: ionredy1.aud LaunchSound: ion1.aud SelectTargetSound: select1.aud + InsufficientPowerSound: nopower1.aud SupportPowerChargeBar: TMPL: @@ -477,6 +479,7 @@ TMPL: BeginChargeSound: EndChargeSound: nukavail.aud SelectTargetSound: select1.aud + InsufficientPowerSound: nopower1.aud LaunchSound: nuklnch1.aud IncomingSound: nuke1.aud MissileWeapon: atomic diff --git a/mods/d2k/notifications.yaml b/mods/d2k/notifications.yaml index d58344d04a..b5f75abadb 100644 --- a/mods/d2k/notifications.yaml +++ b/mods/d2k/notifications.yaml @@ -12,7 +12,6 @@ Speech: LowPower: POWER SilosNeeded: SILOS PrimaryBuildingSelected: PRMRY - AbilityInsufficientPower: NewOptions: NEWOP Win: MWIN Lose: MFAIL diff --git a/mods/ra/notifications.yaml b/mods/ra/notifications.yaml index ba56e3698c..e906c504a4 100644 --- a/mods/ra/notifications.yaml +++ b/mods/ra/notifications.yaml @@ -6,7 +6,6 @@ Speech: PrimaryBuildingSelected: pribldg1 BuildingCannotPlaceAudio: nodeply1 NewOptions: newopt1 - AbilityInsufficientPower: nopowr1 Win: misnwon1 Lose: misnlst1 BaseAttack: baseatk1 diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index e129be89a6..5825d961d1 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -31,6 +31,7 @@ MSLO: BeginChargeSound: aprep1.aud EndChargeSound: aready1.aud SelectTargetSound: slcttgt1.aud + InsufficientPowerSound: nopowr1.aud IncomingSound: alaunch1.aud LaunchSound: MissileWeapon: atomic @@ -220,6 +221,7 @@ IRON: LongDesc: Makes a group of units invulnerable\nfor 20 seconds. Duration: 20 SelectTargetSound: slcttgt1.aud + InsufficientPowerSound: nopowr1.aud BeginChargeSound: ironchg1.aud EndChargeSound: ironrdy1.aud SupportPowerChargeBar: @@ -257,6 +259,7 @@ PDOX: Description: Chronoshift LongDesc: Teleports a group of units across\nthe map for 20 seconds. SelectTargetSound: slcttgt1.aud + InsufficientPowerSound: nopowr1.aud BeginChargeSound: chrochr1.aud EndChargeSound: chrordy1.aud Duration: 20 diff --git a/mods/ts/notifications.yaml b/mods/ts/notifications.yaml index 25c3a034e9..8b0e113afd 100644 --- a/mods/ts/notifications.yaml +++ b/mods/ts/notifications.yaml @@ -6,7 +6,6 @@ Speech: PrimaryBuildingSelected: 00-i034 BuildingCannotPlaceAudio: 00-i016 NewOptions: 00-i032 - AbilityInsufficientPower: Win: 00-i284 Lose: 00-i286 BaseAttack: 00-i082