diff --git a/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs index a0fa5d633b..53b3a8438b 100644 --- a/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs @@ -55,6 +55,7 @@ namespace OpenRA.Mods.Common.Widgets // Note: LinterHotkeyNames assumes that these are disabled by default public readonly string HotkeyPrefix = null; public readonly int HotkeyCount = 0; + public readonly HotkeyReference SelectProductionBuildingHotkey = new HotkeyReference(); public readonly string ClockAnimation = "clock"; public readonly string ClockSequence = "idle"; @@ -367,6 +368,9 @@ namespace OpenRA.Mods.Common.Widgets if (e.Event == KeyInputEvent.Up || CurrentQueue == null) return false; + if (SelectProductionBuildingHotkey.IsActivatedBy(e)) + return SelectProductionBuilding(); + var batchModifiers = e.Modifiers.HasModifier(Modifiers.Shift) ? Modifiers.Shift : Modifiers.None; // HACK: enable production if the shift key is pressed @@ -375,6 +379,28 @@ namespace OpenRA.Mods.Common.Widgets return toBuild != null ? HandleEvent(toBuild, MouseButton.Left, batchModifiers) : false; } + bool SelectProductionBuilding() + { + var viewport = worldRenderer.Viewport; + var selection = World.Selection; + + if (CurrentQueue == null) + return true; + + var facility = CurrentQueue.MostLikelyProducer().Actor; + + if (facility == null) + return true; + + if (selection.Actors.Count() == 1 && selection.Contains(facility)) + viewport.Center(selection.Actors); + else + selection.Combine(World, new[] { facility }, false, true); + + Game.Sound.PlayNotification(World.Map.Rules, null, "Sounds", ClickSound, null); + return true; + } + public void RefreshIcons() { icons = new Dictionary(); diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 6722809660..b1cd5ace32 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -1838,6 +1838,7 @@ Container@PLAYER_WIDGETS: HoldText: On Hold HotkeyPrefix: Production HotkeyCount: 24 + SelectProductionBuildingHotkey: SelectProductionBuilding ProductionTabs@PRODUCTION_TABS: Logic: AddFactionSuffixLogic, ProductionTabsLogic PaletteWidget: PRODUCTION_PALETTE diff --git a/mods/common/hotkeys/production-common.yaml b/mods/common/hotkeys/production-common.yaml index 222c4b61aa..a882811689 100644 --- a/mods/common/hotkeys/production-common.yaml +++ b/mods/common/hotkeys/production-common.yaml @@ -2,6 +2,10 @@ CycleProductionBuildings: TAB Description: Next facility Types: Production, Player, Spectator +SelectProductionBuilding: + Description: Current facility + Types: Production, Player + Production01: F1 Description: Slot 01 Types: ProductionSlot, Player diff --git a/mods/d2k/chrome/ingame-player.yaml b/mods/d2k/chrome/ingame-player.yaml index 17223ebbca..057d12b63e 100644 --- a/mods/d2k/chrome/ingame-player.yaml +++ b/mods/d2k/chrome/ingame-player.yaml @@ -492,6 +492,7 @@ Container@PLAYER_WIDGETS: MaximumRows: 6 HotkeyPrefix: Production HotkeyCount: 24 + SelectProductionBuildingHotkey: SelectProductionBuilding ClickSound: TabClick Container@PRODUCTION_TYPES: X: 6 diff --git a/mods/ra/chrome/ingame-player.yaml b/mods/ra/chrome/ingame-player.yaml index 09d731a78c..07eae71346 100644 --- a/mods/ra/chrome/ingame-player.yaml +++ b/mods/ra/chrome/ingame-player.yaml @@ -448,6 +448,7 @@ Container@PLAYER_WIDGETS: IconSpriteOffset: -1, -1 HotkeyPrefix: Production HotkeyCount: 24 + SelectProductionBuildingHotkey: SelectProductionBuilding Container@PALETTE_FOREGROUND: Children: Image@ROW_TEMPLATE: diff --git a/mods/ts/chrome/ingame-player.yaml b/mods/ts/chrome/ingame-player.yaml index f346ba963d..9a080345fd 100644 --- a/mods/ts/chrome/ingame-player.yaml +++ b/mods/ts/chrome/ingame-player.yaml @@ -491,6 +491,7 @@ Container@PLAYER_WIDGETS: MaximumRows: 6 HotkeyPrefix: Production HotkeyCount: 24 + SelectProductionBuildingHotkey: SelectProductionBuilding Container@PRODUCTION_TYPES: X: 0 Y: 0 - 32