Add hotkey for removing actors from control groups
* Add `RemoveFromControlGroup` hotkey * Add `RemoveFromControlGroup` method to `OpenRA.Game.Selection`
This commit is contained in:
committed by
Oliver Brakmann
parent
99987db5d9
commit
7695714f66
@@ -187,6 +187,13 @@ namespace OpenRA
|
|||||||
controlGroups[group].Add(a);
|
controlGroups[group].Add(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RemoveFromControlGroup(Actor a)
|
||||||
|
{
|
||||||
|
var group = GetControlGroupForActor(a);
|
||||||
|
if (group.HasValue)
|
||||||
|
controlGroups[group.Value].Remove(a);
|
||||||
|
}
|
||||||
|
|
||||||
public int? GetControlGroupForActor(Actor a)
|
public int? GetControlGroupForActor(Actor a)
|
||||||
{
|
{
|
||||||
return controlGroups.Where(g => g.Value.Contains(a))
|
return controlGroups.Where(g => g.Value.Contains(a))
|
||||||
|
|||||||
@@ -892,6 +892,7 @@
|
|||||||
<Compile Include="Widgets\Logic\Ingame\Hotkeys\TogglePlayerStanceColorHotkeyLogic.cs" />
|
<Compile Include="Widgets\Logic\Ingame\Hotkeys\TogglePlayerStanceColorHotkeyLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\Ingame\Hotkeys\PauseHotkeyLogic.cs" />
|
<Compile Include="Widgets\Logic\Ingame\Hotkeys\PauseHotkeyLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\Ingame\Hotkeys\CycleStatusBarsHotkeyLogic.cs" />
|
<Compile Include="Widgets\Logic\Ingame\Hotkeys\CycleStatusBarsHotkeyLogic.cs" />
|
||||||
|
<Compile Include="Widgets\Logic\Ingame\Hotkeys\RemoveFromControlGroupHotkeyLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\Lobby\LobbyOptionsLogic.cs" />
|
<Compile Include="Widgets\Logic\Lobby\LobbyOptionsLogic.cs" />
|
||||||
<Compile Include="Traits\World\LobbyPrerequisiteCheckbox.cs" />
|
<Compile Include="Traits\World\LobbyPrerequisiteCheckbox.cs" />
|
||||||
<Compile Include="Widgets\Logic\DirectConnectLogic.cs" />
|
<Compile Include="Widgets\Logic\DirectConnectLogic.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2019 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, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.Mods.Common.Lint;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
||||||
|
{
|
||||||
|
[ChromeLogicArgsHotkeys("RemoveFromControlGroupKey")]
|
||||||
|
public class RemoveFromControlGroupHotkeyLogic : SingleHotkeyBaseLogic
|
||||||
|
{
|
||||||
|
readonly Selection selection;
|
||||||
|
readonly World world;
|
||||||
|
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
public RemoveFromControlGroupHotkeyLogic(Widget widget, ModData modData, World world, Dictionary<string, MiniYaml> logicArgs)
|
||||||
|
: base(widget, modData, "RemoveFromControlGroupKey", "WORLD_KEYHANDLER", logicArgs)
|
||||||
|
{
|
||||||
|
selection = world.Selection;
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHotkeyActivated(KeyInput e)
|
||||||
|
{
|
||||||
|
var selectedActors = selection.Actors
|
||||||
|
.Where(a => a.Owner == world.LocalPlayer && a.IsInWorld && !a.IsDead)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
foreach (var a in selectedActors)
|
||||||
|
selection.RemoveFromControlGroup(a);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,8 @@ Container@INGAME_ROOT:
|
|||||||
TakeScreenshotKey: TakeScreenshot
|
TakeScreenshotKey: TakeScreenshot
|
||||||
MuteAudioKey: ToggleMute
|
MuteAudioKey: ToggleMute
|
||||||
LogicKeyListener@WORLD_KEYHANDLER:
|
LogicKeyListener@WORLD_KEYHANDLER:
|
||||||
Logic: CycleBasesHotkeyLogic, CycleProductionActorsHotkeyLogic, JumpToLastEventHotkeyLogic, JumpToSelectedActorsHotkeyLogic, TogglePixelDoubleHotkeyLogic, TogglePlayerStanceColorHotkeyLogic, CycleStatusBarsHotkeyLogic, PauseHotkeyLogic
|
Logic: CycleBasesHotkeyLogic, CycleProductionActorsHotkeyLogic, JumpToLastEventHotkeyLogic, JumpToSelectedActorsHotkeyLogic, TogglePixelDoubleHotkeyLogic, TogglePlayerStanceColorHotkeyLogic, CycleStatusBarsHotkeyLogic, PauseHotkeyLogic, RemoveFromControlGroupHotkeyLogic
|
||||||
|
RemoveFromControlGroupKey: RemoveFromControlGroup
|
||||||
CycleBasesKey: CycleBase
|
CycleBasesKey: CycleBase
|
||||||
CycleProductionActorsKey: CycleProductionBuildings
|
CycleProductionActorsKey: CycleProductionBuildings
|
||||||
JumpToLastEventKey: ToLastEvent
|
JumpToLastEventKey: ToLastEvent
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ Container@INGAME_ROOT:
|
|||||||
TakeScreenshotKey: TakeScreenshot
|
TakeScreenshotKey: TakeScreenshot
|
||||||
MuteAudioKey: ToggleMute
|
MuteAudioKey: ToggleMute
|
||||||
LogicKeyListener@WORLD_KEYHANDLER:
|
LogicKeyListener@WORLD_KEYHANDLER:
|
||||||
Logic: CycleBasesHotkeyLogic, CycleProductionActorsHotkeyLogic, JumpToLastEventHotkeyLogic, JumpToSelectedActorsHotkeyLogic, TogglePixelDoubleHotkeyLogic, TogglePlayerStanceColorHotkeyLogic, CycleStatusBarsHotkeyLogic, PauseHotkeyLogic
|
Logic: CycleBasesHotkeyLogic, CycleProductionActorsHotkeyLogic, JumpToLastEventHotkeyLogic, JumpToSelectedActorsHotkeyLogic, TogglePixelDoubleHotkeyLogic, TogglePlayerStanceColorHotkeyLogic, CycleStatusBarsHotkeyLogic, PauseHotkeyLogic, RemoveFromControlGroupHotkeyLogic
|
||||||
|
RemoveFromControlGroupKey: RemoveFromControlGroup
|
||||||
CycleBasesKey: CycleBase
|
CycleBasesKey: CycleBase
|
||||||
CycleProductionActorsKey: CycleProductionBuildings
|
CycleProductionActorsKey: CycleProductionBuildings
|
||||||
JumpToLastEventKey: ToLastEvent
|
JumpToLastEventKey: ToLastEvent
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ SelectUnitsByType: W
|
|||||||
Description: Select units by type
|
Description: Select units by type
|
||||||
Types: World
|
Types: World
|
||||||
|
|
||||||
|
RemoveFromControlGroup:
|
||||||
|
Description: Remove from control group
|
||||||
|
Types: World
|
||||||
|
|
||||||
Pause: PAUSE
|
Pause: PAUSE
|
||||||
Description: Pause / Unpause
|
Description: Pause / Unpause
|
||||||
Types: World
|
Types: World
|
||||||
|
|||||||
Reference in New Issue
Block a user