Skip to content

Commit 7478bb7

Browse files
committed
Merge branch 'development' into walkpath-auto-crouch
2 parents b3d1f2b + 631c038 commit 7478bb7

File tree

6 files changed

+41
-4
lines changed

6 files changed

+41
-4
lines changed

Activities/GameActivity.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,18 @@ bool GameActivity::IsBuyGUIVisible(int which) const {
396396

397397
}
398398

399+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
400+
401+
bool GameActivity::LockControlledActor(Players player, bool lock, Controller::InputMode lockToMode) {
402+
if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) {
403+
bool prevLock = m_LuaLockActor[player];
404+
m_LuaLockActor[player] = lock;
405+
m_LuaLockActorMode[player] = lockToMode;
406+
return true;
407+
}
408+
return false;
409+
}
410+
399411
//////////////////////////////////////////////////////////////////////////////////////////
400412
// Virtual method: SwitchToActor
401413
//////////////////////////////////////////////////////////////////////////////////////////
@@ -1424,7 +1436,7 @@ void GameActivity::Update()
14241436
m_ViewState[player] = ViewState::Normal;
14251437
}
14261438
// Switch to next actor if the player wants to. Don't do it while the buy menu is open
1427-
else if (m_PlayerController[player].IsState(ACTOR_NEXT) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible())
1439+
else if (m_PlayerController[player].IsState(ACTOR_NEXT) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && !m_LuaLockActor[player])
14281440
{
14291441
if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) {
14301442
m_ControlledActor[player]->GetPieMenu()->SetEnabled(false);
@@ -1444,7 +1456,7 @@ void GameActivity::Update()
14441456
g_FrameMan.ClearScreenText(ScreenOfPlayer(player));
14451457
}
14461458
// Go into manual actor select mode if either actor switch buttons are held for a duration
1447-
else if (m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && (m_PlayerController[player].IsState(ACTOR_NEXT_PREP) || m_PlayerController[player].IsState(ACTOR_PREV_PREP)))
1459+
else if (m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && !m_LuaLockActor[player] && (m_PlayerController[player].IsState(ACTOR_NEXT_PREP) || m_PlayerController[player].IsState(ACTOR_PREV_PREP)))
14481460
{
14491461
if (m_ActorSelectTimer[player].IsPastRealMS(250))
14501462
{
@@ -1967,7 +1979,7 @@ void GameActivity::Update()
19671979
}
19681980

19691981
// Trap the mouse if we're in gameplay and not in menus
1970-
g_UInputMan.TrapMousePos(!m_pBuyGUI[player]->IsEnabled() && !m_InventoryMenuGUI[player]->IsEnabledAndNotCarousel(), player);
1982+
g_UInputMan.TrapMousePos(!m_pBuyGUI[player]->IsEnabled() && !m_InventoryMenuGUI[player]->IsEnabledAndNotCarousel() && !m_LuaLockActor[player], player);
19711983

19721984
// Start LZ picking mode if a purchase was made
19731985
if (m_pBuyGUI[player]->PurchaseMade())
@@ -2015,6 +2027,8 @@ void GameActivity::Update()
20152027
m_ControlledActor[player]->GetController()->SetInputMode(Controller::CIM_AI);
20162028
} else if (m_InventoryMenuGUI[player]->IsEnabledAndNotCarousel()) {
20172029
m_ControlledActor[player]->GetController()->SetInputMode(Controller::CIM_DISABLED);
2030+
} else if (m_LuaLockActor[player]) {
2031+
m_ControlledActor[player]->GetController()->SetInputMode(m_LuaLockActorMode[player]);
20182032
} else {
20192033
m_ControlledActor[player]->GetController()->SetInputMode(Controller::CIM_PLAYER);
20202034
}

Activities/GameActivity.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ class GameActivity : public Activity {
252252

253253
SceneEditorGUI * GetEditorGUI(unsigned int which = 0) const { return m_pEditorGUI[which]; }
254254

255+
/// <summary>
256+
/// Locks a player controlled actor to a specific controller mode.
257+
/// Locking the actor will disable player input, including switching actors.
258+
/// </summary>
259+
/// <param name="player">Which player to lock the actor for.</param>
260+
/// <param name="lock">Whether to lock or unlock the actor. (Default: true)</param>
261+
/// <param name="lockToMode">Which controller mode to lock the actor to. (Default: `CIM_AI`)</param>
262+
/// <returns>Whether the (un)lock was performed.</returns>
263+
bool LockControlledActor(Players player, bool lock = true, Controller::InputMode lockToMode = Controller::InputMode::CIM_AI);
255264

256265
//////////////////////////////////////////////////////////////////////////////////////////
257266
// Virtual method: SwitchToActor
@@ -1035,6 +1044,8 @@ class GameActivity : public Activity {
10351044
BuyMenuGUI *m_pBuyGUI[Players::MaxPlayerCount];
10361045
// The in-game scene editor GUI for each player
10371046
SceneEditorGUI *m_pEditorGUI[Players::MaxPlayerCount];
1047+
bool m_LuaLockActor[Players::MaxPlayerCount]; //!< Whether or not to lock input for each player while lua has control.
1048+
Controller::InputMode m_LuaLockActorMode[Players::MaxPlayerCount]; //!< The input mode to lock to while lua has control.
10381049
// The in-game important message banners for each player
10391050
GUIBanner *m_pBannerRed[Players::MaxPlayerCount];
10401051
GUIBanner *m_pBannerYellow[Players::MaxPlayerCount];

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
116116

117117
- `Enum` binding for `SceneObject.BuyableMode`: `NORESTRICTIONS = 0, BUYMENUONLY = 1, OBJECTPICKERONLY = 2, SCRIPTONLY = 3`.
118118

119+
- Exposed `UInputMan::AbsoluteMousePos` to Lua
120+
121+
- New `GameActivity::LockControlledActor` Lua function to allow grab player input in the way menus (buy menu/full inventorymenu) do.
122+
119123
</details>
120124

121125
<details><summary><b>Changed</b></summary>

Entities/HDFirearm.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ThrownDevice.h"
2323
#include "MOPixel.h"
2424
#include "Actor.h"
25+
#include "Scene.h"
2526

2627
namespace RTE {
2728

@@ -1062,7 +1063,12 @@ void HDFirearm::Update()
10621063
if (m_FireSound && !(m_FireSound->GetLoopSetting() == -1 && m_FireSound->IsBeingPlayed())) {
10631064
m_FireSound->Play(m_Pos);
10641065
}
1065-
if (m_FireEchoSound) { m_FireEchoSound->Play(m_Pos); }
1066+
if (m_FireEchoSound) {
1067+
Scene::Area* noEchoArea = g_SceneMan.GetScene()->GetOptionalArea("IndoorArea");
1068+
if (noEchoArea == nullptr || !noEchoArea->IsInside(m_Pos)) {
1069+
m_FireEchoSound->Play(m_Pos);
1070+
}
1071+
}
10661072
}
10671073

10681074
if (m_Loudness > 0) { g_MovableMan.RegisterAlarmEvent(AlarmEvent(m_Pos, m_Team, m_Loudness)); }

Lua/LuaBindingsActivities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ namespace RTE {
149149
.def("SetActorSelectCursor", &GameActivity::SetActorSelectCursor)
150150
.def("GetBuyGUI", &GameActivity::GetBuyGUI)
151151
.def("GetEditorGUI", &GameActivity::GetEditorGUI)
152+
.def("LockControlledActor", &GameActivity::LockControlledActor)
152153
.def("OtherTeam", &GameActivity::OtherTeam)
153154
.def("OneOrNoneTeamsLeft", &GameActivity::OneOrNoneTeamsLeft)
154155
.def("WhichTeamLeft", &GameActivity::WhichTeamLeft)

Lua/LuaBindingsManagers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ namespace RTE {
414414
.def("MouseButtonPressed", &UInputMan::MouseButtonPressed)
415415
.def("MouseButtonReleased", &UInputMan::MouseButtonReleased)
416416
.def("MouseButtonHeld", &UInputMan::MouseButtonHeld)
417+
.def("GetMousePos", &UInputMan::GetAbsoluteMousePosition)
417418
.def("MouseWheelMoved", &UInputMan::MouseWheelMoved)
418419
.def("JoyButtonPressed", &UInputMan::JoyButtonPressed)
419420
.def("JoyButtonReleased", &UInputMan::JoyButtonReleased)

0 commit comments

Comments
 (0)