Skip to content

Commit 0ddeadb

Browse files
committed
add primary and auxiliary hotkeys to devices and actors
1 parent f79d08c commit 0ddeadb

15 files changed

+377
-13
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5252

5353
- New `MOSprite` INI and Lua (R/W) integer property `ForcedHFlip` which forces a certain flippedness and disallows anything else from ever changing it without clearing the forced value first. 0 is forced not flipped, 1 forced flipped, and -1 is no force.
5454

55+
- New hotkey bindings.
56+
On Mouse+KB PC the defaults are: Weapon Primary Hotkey on V, Weapon Auxiliary Hotkey on H, Actor Primary Hotkey on X, Actor Auxiliary Hotkey on O.
57+
Added new `Controller` states `WEAPON_PRIMARY_HOTKEYSTART`, `WEAPON_AUXILIARY_HOTKEYSTART`, `ACTOR_PRIMARY_HOTKEYSTART`, `ACTOR_AUXILIARY_HOTKEYSTART`, `WEAPON_PRIMARY_HOTKEY`, `WEAPON_AUXILIARY_HOTKEY`, `ACTOR_PRIMARY_HOTKEY`, `ACTOR_AUXILIARY_HOTKEY`
58+
59+
- New hotkey system for `Actor` and `HeldDevice`.
60+
Pressing a certain new hotkey will mark it as activated on `Actor` and `HeldDevice`, letting scripts make use of the new bindings easily.
61+
`Enum` binding for `HeldDevice.HeldDeviceHotkeyType`: `PRIMARY = 0, AUXILIARY = 1, HELDDEVICEHOTKEYTYPECOUNT = 2`.
62+
`Enum` binding for `Actor.ActorHotkeyType`: `PRIMARY = 0, AUXILIARY = 1, ACTORHOTKEYTYPECOUNT = 2`.
63+
Both `Actor` and `HeldDevice` have the following functions:
64+
`HotkeyActionIsActivated(hotkeyType)` returns whether a certain hotkey action is being activated or not.
65+
`ActivateHotkeyAction(hotkeyType)` activates a certain hotkey action.
66+
`DeactivateHotkeyAction(hotkeyType)` deactivates a certain hotkey action.
67+
5568
- Allow lua scripts to use LuaJIT's BitOp module (see https://bitop.luajit.org/api.html)
5669

5770
</details>
@@ -61,7 +74,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6174
- Improved navigation, making running and fast walkpaths much more consistent.
6275

6376
- Increased fog-of-war resolution in all vanilla activities, and conquest, from 20x20 to 4x4.
64-
The Ronin Scrambler, the basic scanner, and `SceneMan:CastUnseenRay` have been changed to accomodate fog-of-war resolutions as fine as 1x1 and as course as 20x20.
77+
The Ronin Scrambler, the basic scanner, and `SceneMan:CastUnseenRay` have been changed to accomodate fog-of-war resolutions as fine as 1x1 and as coarse as 20x20.
6578
The fog-of-war revealing code is now multithreaded to increase performance.
6679

6780
- All vanilla scenario activities have had their settings polished, respecting settings which make sense and disabling settings which don't.

Data/Base.rte/GUIs/SettingsGUI.ini

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,6 +2552,96 @@ Anchor = Left, Top
25522552
ToolTip = None
25532553
Text = [InputKey]
25542554

2555+
[LabelInputName32]
2556+
ControlType = LABEL
2557+
Parent = CollectionBoxScrollingMappingBox
2558+
X = 215
2559+
Y = 380
2560+
Width = 110
2561+
Height = 20
2562+
Visible = True
2563+
Enabled = True
2564+
Name = LabelInputName32
2565+
Anchor = Left, Top
2566+
ToolTip = None
2567+
Text = InputName
2568+
HAlignment = right
2569+
VAlignment = middle
2570+
2571+
[ButtonInputKey32]
2572+
ControlType = BUTTON
2573+
Parent = CollectionBoxScrollingMappingBox
2574+
X = 330
2575+
Y = 380
2576+
Width = 95
2577+
Height = 20
2578+
Visible = True
2579+
Enabled = True
2580+
Name = ButtonInputKey32
2581+
Anchor = Left, Top
2582+
ToolTip = None
2583+
Text = [InputKey]
2584+
2585+
[LabelInputName33]
2586+
ControlType = LABEL
2587+
Parent = CollectionBoxScrollingMappingBox
2588+
X = 215
2589+
Y = 380
2590+
Width = 110
2591+
Height = 20
2592+
Visible = True
2593+
Enabled = True
2594+
Name = LabelInputName33
2595+
Anchor = Left, Top
2596+
ToolTip = None
2597+
Text = InputName
2598+
HAlignment = right
2599+
VAlignment = middle
2600+
2601+
[ButtonInputKey33]
2602+
ControlType = BUTTON
2603+
Parent = CollectionBoxScrollingMappingBox
2604+
X = 330
2605+
Y = 380
2606+
Width = 95
2607+
Height = 20
2608+
Visible = True
2609+
Enabled = True
2610+
Name = ButtonInputKey33
2611+
Anchor = Left, Top
2612+
ToolTip = None
2613+
Text = [InputKey]
2614+
2615+
[LabelInputName34]
2616+
ControlType = LABEL
2617+
Parent = CollectionBoxScrollingMappingBox
2618+
X = 215
2619+
Y = 380
2620+
Width = 110
2621+
Height = 20
2622+
Visible = True
2623+
Enabled = True
2624+
Name = LabelInputName34
2625+
Anchor = Left, Top
2626+
ToolTip = None
2627+
Text = InputName
2628+
HAlignment = right
2629+
VAlignment = middle
2630+
2631+
[ButtonInputKey34]
2632+
ControlType = BUTTON
2633+
Parent = CollectionBoxScrollingMappingBox
2634+
X = 330
2635+
Y = 380
2636+
Width = 95
2637+
Height = 20
2638+
Visible = True
2639+
Enabled = True
2640+
Name = ButtonInputKey34
2641+
Anchor = Left, Top
2642+
ToolTip = None
2643+
Text = [InputKey]
2644+
25552645
[CollectionBoxInputCapture]
25562646
ControlType = COLLECTIONBOX
25572647
Parent = root

Data/Base.rte/GUIs/SettingsPauseGUI.ini

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,6 +2553,96 @@ Anchor = Left, Top
25532553
ToolTip = None
25542554
Text = [InputKey]
25552555

2556+
[LabelInputName32]
2557+
ControlType = LABEL
2558+
Parent = CollectionBoxScrollingMappingBox
2559+
X = 215
2560+
Y = 380
2561+
Width = 110
2562+
Height = 20
2563+
Visible = True
2564+
Enabled = True
2565+
Name = LabelInputName32
2566+
Anchor = Left, Top
2567+
ToolTip = None
2568+
Text = InputName
2569+
HAlignment = right
2570+
VAlignment = middle
2571+
2572+
[ButtonInputKey32]
2573+
ControlType = BUTTON
2574+
Parent = CollectionBoxScrollingMappingBox
2575+
X = 330
2576+
Y = 380
2577+
Width = 95
2578+
Height = 20
2579+
Visible = True
2580+
Enabled = True
2581+
Name = ButtonInputKey32
2582+
Anchor = Left, Top
2583+
ToolTip = None
2584+
Text = [InputKey]
2585+
2586+
[LabelInputName33]
2587+
ControlType = LABEL
2588+
Parent = CollectionBoxScrollingMappingBox
2589+
X = 215
2590+
Y = 380
2591+
Width = 110
2592+
Height = 20
2593+
Visible = True
2594+
Enabled = True
2595+
Name = LabelInputName33
2596+
Anchor = Left, Top
2597+
ToolTip = None
2598+
Text = InputName
2599+
HAlignment = right
2600+
VAlignment = middle
2601+
2602+
[ButtonInputKey33]
2603+
ControlType = BUTTON
2604+
Parent = CollectionBoxScrollingMappingBox
2605+
X = 330
2606+
Y = 380
2607+
Width = 95
2608+
Height = 20
2609+
Visible = True
2610+
Enabled = True
2611+
Name = ButtonInputKey33
2612+
Anchor = Left, Top
2613+
ToolTip = None
2614+
Text = [InputKey]
2615+
2616+
[LabelInputName34]
2617+
ControlType = LABEL
2618+
Parent = CollectionBoxScrollingMappingBox
2619+
X = 215
2620+
Y = 380
2621+
Width = 110
2622+
Height = 20
2623+
Visible = True
2624+
Enabled = True
2625+
Name = LabelInputName34
2626+
Anchor = Left, Top
2627+
ToolTip = None
2628+
Text = InputName
2629+
HAlignment = right
2630+
VAlignment = middle
2631+
2632+
[ButtonInputKey34]
2633+
ControlType = BUTTON
2634+
Parent = CollectionBoxScrollingMappingBox
2635+
X = 330
2636+
Y = 380
2637+
Width = 95
2638+
Height = 20
2639+
Visible = True
2640+
Enabled = True
2641+
Name = ButtonInputKey34
2642+
Anchor = Left, Top
2643+
ToolTip = None
2644+
Text = [InputKey]
2645+
25562646
[CollectionBoxInputCapture]
25572647
ControlType = COLLECTIONBOX
25582648
Parent = root

Source/Entities/ACrab.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,11 @@ void ACrab::PreControllerUpdate() {
963963
} else {
964964
mountedDevice->Deactivate();
965965
}
966+
if (m_Controller.IsState(WEAPON_PRIMARY_HOTKEY)) {
967+
mountedDevice->ActivateHotkeyAction(HeldDeviceHotkeyType::PRIMARYHOTKEY);
968+
} else {
969+
mountedDevice->DeactivateHotkeyAction(HeldDeviceHotkeyType::PRIMARYHOTKEY);
970+
}
966971
}
967972
}
968973

Source/Entities/AHuman.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,17 @@ void AHuman::PreControllerUpdate() {
18241824
m_pFGArm->AddHandTarget("Adjusted Aim Angle", m_Pos + Vector(m_pFGArm->GetMaxLength() * GetFlipFactor(), -m_pFGArm->GetMaxLength() * 0.5F).RadRotate(adjustedAimAngle));
18251825
}
18261826
}
1827+
// Hotkey activations
1828+
if (m_Controller.IsState(WEAPON_PRIMARY_HOTKEY)) {
1829+
device->ActivateHotkeyAction(HeldDeviceHotkeyType::PRIMARYHOTKEY);
1830+
} else {
1831+
device->DeactivateHotkeyAction(HeldDeviceHotkeyType::PRIMARYHOTKEY);
1832+
}
1833+
if (m_Controller.IsState(WEAPON_AUXILIARY_HOTKEY)) {
1834+
device->ActivateHotkeyAction(HeldDeviceHotkeyType::AUXILIARYHOTKEY);
1835+
} else {
1836+
device->DeactivateHotkeyAction(HeldDeviceHotkeyType::AUXILIARYHOTKEY);
1837+
}
18271838
} else if (m_ArmsState == THROWING_RELEASE && m_ThrowTmr.GetElapsedSimTimeMS() > 100) {
18281839
if (m_pFGArm) {
18291840
m_pFGArm->SetHeldDevice(dynamic_cast<HeldDevice*>(SwapNextInventory()));
@@ -1873,6 +1884,17 @@ void AHuman::PreControllerUpdate() {
18731884
m_SharpAimProgress = 0;
18741885
device->SetSharpAim(m_SharpAimProgress);
18751886
}
1887+
// Hotkey activations
1888+
if (m_Controller.IsState(WEAPON_PRIMARY_HOTKEY)) {
1889+
device->ActivateHotkeyAction(HeldDeviceHotkeyType::PRIMARYHOTKEY);
1890+
} else {
1891+
device->DeactivateHotkeyAction(HeldDeviceHotkeyType::PRIMARYHOTKEY);
1892+
}
1893+
if (m_Controller.IsState(WEAPON_AUXILIARY_HOTKEY)) {
1894+
device->ActivateHotkeyAction(HeldDeviceHotkeyType::AUXILIARYHOTKEY);
1895+
} else {
1896+
device->DeactivateHotkeyAction(HeldDeviceHotkeyType::AUXILIARYHOTKEY);
1897+
}
18761898
} else {
18771899
m_CanActivateBGItem = false;
18781900
}

Source/Entities/Actor.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ void Actor::Clear() {
9999
m_Inventory.clear();
100100
m_MaxInventoryMass = -1.0F;
101101
m_pItemInReach = nullptr;
102+
m_HotkeyActivated.fill(false);
102103
m_HUDStack = 0;
103104
m_DeploymentID = 0;
104105
m_PassengerSlots = 1;
@@ -258,6 +259,7 @@ int Actor::Create(const Actor& reference) {
258259

259260
m_sIconsLoaded = true;
260261
}
262+
m_HotkeyActivated = reference.m_HotkeyActivated;
261263
m_DeploymentID = reference.m_DeploymentID;
262264
m_PassengerSlots = reference.m_PassengerSlots;
263265

@@ -1278,6 +1280,18 @@ void Actor::Update() {
12781280
g_FrameMan.FlashScreen(g_ActivityMan.GetActivity()->ScreenOfPlayer(brainOfPlayer), g_WhiteColor, 500);
12791281
}
12801282
}
1283+
1284+
if (m_Controller.IsState(ACTOR_PRIMARY_HOTKEY)) {
1285+
ActivateHotkeyAction(PRIMARYHOTKEY);
1286+
} else {
1287+
DeactivateHotkeyAction(PRIMARYHOTKEY);
1288+
}
1289+
1290+
if (m_Controller.IsState(ACTOR_AUXILIARY_HOTKEY)) {
1291+
ActivateHotkeyAction(AUXILIARYHOTKEY);
1292+
} else {
1293+
DeactivateHotkeyAction(AUXILIARYHOTKEY);
1294+
}
12811295
}
12821296

12831297
void RTE::Actor::CastSeeRays() {

Source/Entities/Actor.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ namespace RTE {
6868
AIMODE_COUNT
6969
};
7070

71+
enum ActorHotkeyType {
72+
PRIMARYHOTKEY = 0,
73+
AUXILIARYHOTKEY,
74+
ACTORHOTKEYTYPECOUNT
75+
};
76+
7177
// Concrete allocation and cloning definitions
7278
EntityAllocation(Actor);
7379
AddScriptFunctionNames(MOSRotating, "ThreadedUpdateAI", "UpdateAI", "OnControllerInputModeChange");
@@ -673,6 +679,19 @@ namespace RTE {
673679
/// Updates the full state of this object in one call. (PreControllerUpdate(), Controller::Update(), and Update())
674680
virtual void FullUpdate() override;
675681

682+
/// Activates one of this Actor's hotkey features.
683+
/// /// @param hotkeyType Which hotkey type to activate.
684+
void ActivateHotkeyAction(ActorHotkeyType hotkeyType) { m_HotkeyActivated[hotkeyType] = true; }
685+
686+
/// Deactivates one of this Actor's hotkey features.
687+
/// @param hotkeyType Which hotkey type to deactivate.
688+
void DeactivateHotkeyAction(ActorHotkeyType hotkeyType) { m_HotkeyActivated[hotkeyType] = false; }
689+
690+
/// Tells whether a hotkey action of the actor is currently being activated.
691+
/// @param hotkeyType Which hotkey type to check for activation.
692+
/// @return Whether hotkey is being activated.
693+
bool HotkeyActionIsActivated(ActorHotkeyType hotkeyType) const { return m_HotkeyActivated[hotkeyType]; }
694+
676695
/// Description: Sets deployment ID for this actor
677696
/// @param newID New deployment id.
678697
void SetDeploymentID(unsigned int newID) { m_DeploymentID = newID; }
@@ -947,6 +966,8 @@ namespace RTE {
947966
float m_MaxInventoryMass; //!< The mass limit for this Actor's inventory. -1 means there's no limit.
948967
// The device that can/will be picked up
949968
HeldDevice* m_pItemInReach;
969+
// An array that holds activation states for the various hotkey actions of this Actor.
970+
std::array<bool, ACTORHOTKEYTYPECOUNT> m_HotkeyActivated;
950971
// HUD positioning aid
951972
int m_HUDStack;
952973
// ID of deployment which spawned this actor

Source/Entities/HeldDevice.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ HeldDevice::~HeldDevice() {
2929
void HeldDevice::Clear() {
3030
m_HeldDeviceType = WEAPON;
3131
m_Activated = false;
32+
m_HotkeyActivated.fill(false);
3233
m_ActivationTimer.Reset();
34+
for (Timer timer : m_HotkeyActivationTimer) {
35+
timer.Reset();
36+
}
3337
m_OneHanded = false;
3438
m_DualWieldable = false;
3539
m_StanceOffset.Reset();
@@ -116,7 +120,9 @@ int HeldDevice::Create(const HeldDevice& reference) {
116120
m_HeldDeviceType = reference.m_HeldDeviceType;
117121

118122
m_Activated = reference.m_Activated;
123+
m_HotkeyActivated = reference.m_HotkeyActivated;
119124
m_ActivationTimer = reference.m_ActivationTimer;
125+
m_HotkeyActivationTimer = reference.m_HotkeyActivationTimer;
120126

121127
m_OneHanded = reference.m_OneHanded;
122128
m_DualWieldable = reference.m_DualWieldable;
@@ -283,6 +289,18 @@ void HeldDevice::Deactivate() {
283289
m_Activated = false;
284290
}
285291

292+
void HeldDevice::ActivateHotkeyAction(HeldDeviceHotkeyType hotkeyType) {
293+
if (!m_HotkeyActivated[hotkeyType]) {
294+
m_HotkeyActivationTimer[hotkeyType].Reset();
295+
}
296+
297+
m_HotkeyActivated[hotkeyType] = true;
298+
}
299+
300+
void HeldDevice::DeactivateHotkeyAction(HeldDeviceHotkeyType hotkeyType) {
301+
m_HotkeyActivated[hotkeyType] = false;
302+
}
303+
286304
bool HeldDevice::TransferJointImpulses(Vector& jointImpulses, float jointStiffnessValueToUse, float jointStrengthValueToUse, float gibImpulseLimitValueToUse) {
287305
MovableObject* parent = m_Parent;
288306
if (!parent) {

0 commit comments

Comments
 (0)