Fix Production Palette audio (Bug #1004).

This commit is contained in:
Paul Chote
2011-07-14 20:56:17 +12:00
parent 5fceaaec58
commit 725b0cda40
2 changed files with 38 additions and 28 deletions

View File

@@ -34,6 +34,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{ {
public readonly int Columns = 3; public readonly int Columns = 3;
public readonly string TabClick = null; public readonly string TabClick = null;
public readonly string DisabledTabClick = null;
public readonly string TooltipContainer; public readonly string TooltipContainer;
public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP"; public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP";
@@ -136,22 +137,34 @@ namespace OpenRA.Mods.Cnc.Widgets
if (mi.Button == MouseButton.Left) if (mi.Button == MouseButton.Left)
{ {
Sound.Play(TabClick);
// Pick up a completed building // Pick up a completed building
if (first != null && first.Done && actor.Traits.Contains<BuildingInfo>()) if (first != null && first.Done && actor.Traits.Contains<BuildingInfo>())
{
Sound.Play(TabClick);
world.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue.self, clicked.Name); world.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue.self, clicked.Name);
}
// Resume a paused item // Resume a paused item
else if (first != null && first.Paused) else if (first != null && first.Paused)
{
Sound.Play(TabClick);
world.IssueOrder(Order.PauseProduction(CurrentQueue.self, clicked.Name, false)); world.IssueOrder(Order.PauseProduction(CurrentQueue.self, clicked.Name, false));
}
// Queue a new item // Queue a new item
else StartProduction(world, clicked.Name); else if (CurrentQueue.BuildableItems().Any(a => a.Name == clicked.Name))
{
Sound.Play(TabClick);
Sound.Play(CurrentQueue.Info.QueuedAudio);
world.IssueOrder(Order.StartProduction(CurrentQueue.self, clicked.Name,
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
}
else
Sound.Play(DisabledTabClick);
} }
// Hold/Cancel an existing item // Hold/Cancel an existing item
else if (mi.Button == MouseButton.Right && first != null) else if (mi.Button == MouseButton.Right)
{
if (first != null)
{ {
Sound.Play(TabClick); Sound.Play(TabClick);
@@ -168,14 +181,10 @@ namespace OpenRA.Mods.Cnc.Widgets
world.IssueOrder(Order.PauseProduction(CurrentQueue.self, clicked.Name, true)); world.IssueOrder(Order.PauseProduction(CurrentQueue.self, clicked.Name, true));
} }
} }
return true; else
Sound.Play(DisabledTabClick);
} }
return true;
void StartProduction( World world, string item )
{
Sound.Play(CurrentQueue.Info.QueuedAudio);
world.IssueOrder(Order.StartProduction(CurrentQueue.self, item,
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
} }
public void RefreshIcons() public void RefreshIcons()

View File

@@ -337,6 +337,7 @@ Container@PLAYER_WIDGETS:
X:WINDOW_RIGHT - 204 X:WINDOW_RIGHT - 204
Y:287 Y:287
TabClick: button.aud TabClick: button.aud
DisabledTabClick:scold2.aud
TooltipContainer:TOOLTIP_CONTAINER TooltipContainer:TOOLTIP_CONTAINER
Background@FMVPLAYER: Background@FMVPLAYER:
Id:FMVPLAYER Id:FMVPLAYER