Skip to content

Commit 5b2e683

Browse files
authored
Merge pull request #7 from cortex-command-community/disable-hud
Disable HUD via Script
2 parents 556e0ec + b13604b commit 5b2e683

File tree

6 files changed

+73
-47
lines changed

6 files changed

+73
-47
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,14 @@ 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
119+
- Exposed `UInputMan::AbsoluteMousePos` to Lua.
120120

121121
- New `GameActivity::LockControlledActor` Lua function to allow grab player input in the way menus (buy menu/full inventorymenu) do.
122122

123+
- New `FrameMan` Lua functions `SetHudDisabled(disabled, screenId)` and `IsHudDisabled(screenId)` that allows disabling a given screen's HUD, and checking whether it's currently disabled. The screenId parameters are optional and default to screen 0.
124+
125+
- Exposed `FrameMan` property `ScreenCount` to Lua (R).
126+
123127
</details>
124128

125129
<details><summary><b>Changed</b></summary>

Source/Activities/GameActivity.cpp

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,55 +1430,50 @@ void GameActivity::Update()
14301430
m_ControlledActor[player] = 0;
14311431
}
14321432

1433-
///////////////////////////////////////////
14341433
// Player-commanded actor switching
1434+
if (m_ViewState[player] != ViewState::Observe) {
1435+
// Switch to brain actor directly if the player wants to
1436+
if (m_PlayerController[player].IsState(ACTOR_BRAIN) && m_ViewState[player] != ViewState::ActorSelect) {
1437+
SwitchToActor(m_Brain[player], player, team);
1438+
m_ViewState[player] = ViewState::Normal;
1439+
} else if (m_PlayerController[player].IsState(ACTOR_NEXT) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && !m_LuaLockActor[player]) {
1440+
// Switch to next actor if the player wants to. Don't do it while the buy menu is open
1441+
if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) {
1442+
m_ControlledActor[player]->GetPieMenu()->SetEnabled(false);
1443+
}
14351444

1436-
// Switch to brain actor directly if the player wants to
1437-
if (m_PlayerController[player].IsState(ACTOR_BRAIN) && m_ViewState[player] != ViewState::ActorSelect)
1438-
{
1439-
SwitchToActor(m_Brain[player], player, team);
1440-
m_ViewState[player] = ViewState::Normal;
1441-
}
1442-
// Switch to next actor if the player wants to. Don't do it while the buy menu is open
1443-
else if (m_PlayerController[player].IsState(ACTOR_NEXT) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && !m_LuaLockActor[player])
1444-
{
1445-
if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) {
1446-
m_ControlledActor[player]->GetPieMenu()->SetEnabled(false);
1447-
}
1448-
SwitchToNextActor(player, team);
1449-
m_ViewState[player] = ViewState::Normal;
1450-
g_FrameMan.ClearScreenText(ScreenOfPlayer(player));
1451-
}
1452-
// Switch to prev actor if the player wants to. Don't do it while the buy menu is open
1453-
else if (m_PlayerController[player].IsState(ACTOR_PREV) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible())
1454-
{
1455-
if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) {
1456-
m_ControlledActor[player]->GetPieMenu()->SetEnabled(false);
1457-
}
1458-
SwitchToPrevActor(player, team);
1459-
m_ViewState[player] = ViewState::Normal;
1460-
g_FrameMan.ClearScreenText(ScreenOfPlayer(player));
1461-
}
1462-
// Go into manual actor select mode if either actor switch buttons are held for a duration
1463-
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)))
1464-
{
1465-
if (m_ActorSelectTimer[player].IsPastRealMS(250))
1466-
{
1467-
// Set cursor to start at the head of controlled actor
1468-
if (m_ControlledActor[player])
1469-
{
1470-
// Give switched from actor an AI controller
1471-
m_ControlledActor[player]->SetControllerMode(Controller::CIM_AI);
1472-
m_ControlledActor[player]->GetController()->SetDisabled(false);
1473-
m_ActorCursor[player] = m_ControlledActor[player]->GetCPUPos();
1474-
m_CursorTimer.Reset();
1445+
SwitchToNextActor(player, team);
1446+
m_ViewState[player] = ViewState::Normal;
1447+
g_FrameMan.ClearScreenText(ScreenOfPlayer(player));
1448+
}
1449+
// Switch to prev actor if the player wants to. Don't do it while the buy menu is open
1450+
else if (m_PlayerController[player].IsState(ACTOR_PREV) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible()) {
1451+
if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) {
1452+
m_ControlledActor[player]->GetPieMenu()->SetEnabled(false);
14751453
}
1476-
m_ViewState[player] = ViewState::ActorSelect;
1454+
1455+
SwitchToPrevActor(player, team);
1456+
m_ViewState[player] = ViewState::Normal;
14771457
g_FrameMan.ClearScreenText(ScreenOfPlayer(player));
1478-
}
1458+
} 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))) {
1459+
// Go into manual actor select mode if either actor switch buttons are held for a duration
1460+
if (m_ActorSelectTimer[player].IsPastRealMS(250)) {
1461+
// Set cursor to start at the head of controlled actor
1462+
if (m_ControlledActor[player]) {
1463+
// Give switched from actor an AI controller
1464+
m_ControlledActor[player]->SetControllerMode(Controller::CIM_AI);
1465+
m_ControlledActor[player]->GetController()->SetDisabled(false);
1466+
m_ActorCursor[player] = m_ControlledActor[player]->GetCPUPos();
1467+
m_CursorTimer.Reset();
1468+
}
1469+
1470+
m_ViewState[player] = ViewState::ActorSelect;
1471+
g_FrameMan.ClearScreenText(ScreenOfPlayer(player));
1472+
}
1473+
} else {
1474+
m_ActorSelectTimer[player].Reset();
1475+
}
14791476
}
1480-
else
1481-
m_ActorSelectTimer[player].Reset();
14821477

14831478
////////////////////////////////////
14841479
// Update sceneman scroll targets

Source/Lua/LuaBindingsManagers.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ namespace RTE {
7171

7272
.property("PlayerScreenWidth", &FrameMan::GetPlayerScreenWidth)
7373
.property("PlayerScreenHeight", &FrameMan::GetPlayerScreenHeight)
74+
.property("ScreenCount", &FrameMan::GetScreenCount)
7475

76+
.def("IsHudDisabled", &FrameMan::IsHudDisabled)
77+
.def("SetHudDisabled", &FrameMan::SetHudDisabled)
7578
.def("LoadPalette", &FrameMan::LoadPalette)
7679
.def("SetScreenText", &FrameMan::SetScreenText)
7780
.def("ClearScreenText", &FrameMan::ClearScreenText)

Source/Managers/FrameMan.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ namespace RTE {
7878
m_TextDurationTimer[screenCount].Reset();
7979
m_TextBlinking[screenCount] = 0;
8080
m_TextCentered[screenCount] = false;
81+
m_HUDDisabled[screenCount] = false;
8182
m_FlashScreenColor[screenCount] = -1;
8283
m_FlashedLastFrame[screenCount] = false;
8384
m_FlashTimer[screenCount].Reset();

Source/Managers/FrameMan.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,20 @@ namespace RTE {
301301
}
302302
#pragma endregion
303303

304+
/// <summary>
305+
/// Gets whether or not the HUD is disabled for a given screen.
306+
/// </summary>
307+
/// <param name="screenId">The screen to check for.</param>
308+
/// <returns>True if in given screen's HUD is disabled.</returns>
309+
bool IsHudDisabled(int screenId = 0) const { return m_HUDDisabled[screenId]; }
310+
311+
/// <summary>
312+
/// Sets whether or not the HUD is disabled for a given screen.
313+
/// </summary>
314+
/// <param name="value">Whether the HUD should be disabled.</param>
315+
/// <param name="screenId">The screen to set for.</param>
316+
void SetHudDisabled(bool value, int screenId = 0) { m_HUDDisabled[screenId] = value; }
317+
304318
#pragma region Network Handling
305319
/// <summary>
306320
/// Returns true if this manager is in multiplayer mode, storing the 8bpp backbuffer for network transmission.
@@ -503,9 +517,11 @@ namespace RTE {
503517
bool m_TextCentered[c_MaxScreenCount]; //!< Whether screen text is centered vertically.
504518
int m_TextDuration[c_MaxScreenCount]; //!< The minimum duration the current message is supposed to show before it can be overwritten.
505519
Timer m_TextDurationTimer[c_MaxScreenCount]; //!< Screen text display duration time.
520+
506521
int m_TextBlinking[c_MaxScreenCount]; //!< Screen text messages blinking interval in ms. 0 is no blink at all, just show message.
507522
Timer m_TextBlinkTimer; //!< Screen text blink timer.
508523

524+
bool m_HUDDisabled[c_MaxScreenCount]; //!< Whether the HUD is currently disabled for a given screen.
509525
int m_FlashScreenColor[c_MaxScreenCount]; //!< Whether to flash a player's screen a specific color this frame. -1 means no flash.
510526
bool m_FlashedLastFrame[c_MaxScreenCount]; //!< Whether we flashed last frame or not.
511527
Timer m_FlashTimer[c_MaxScreenCount]; //!< Flash screen timer.

Source/Managers/SceneMan.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,9 +2857,16 @@ void SceneMan::Draw(BITMAP *targetBitmap, BITMAP *targetGUIBitmap, const Vector
28572857
}
28582858
}
28592859

2860-
g_MovableMan.DrawHUD(targetGUIBitmap, targetPos, m_LastUpdatedScreen);
2860+
bool shouldDrawHUD = !g_FrameMan.IsHudDisabled(m_LastUpdatedScreen);
2861+
if (shouldDrawHUD) {
2862+
g_MovableMan.DrawHUD(targetGUIBitmap, targetPos, m_LastUpdatedScreen);
2863+
}
2864+
28612865
g_PrimitiveMan.DrawPrimitives(m_LastUpdatedScreen, targetGUIBitmap, targetPos);
2862-
g_ActivityMan.GetActivity()->DrawGUI(targetGUIBitmap, targetPos, m_LastUpdatedScreen);
2866+
2867+
if (shouldDrawHUD) {
2868+
g_ActivityMan.GetActivity()->DrawGUI(targetGUIBitmap, targetPos, m_LastUpdatedScreen);
2869+
}
28632870

28642871
#ifdef DRAW_NOGRAV_BOXES
28652872
if (Scene::Area* noGravArea = m_pCurrentScene->GetArea("NoGravityArea")) {

0 commit comments

Comments
 (0)