Skip to content

Commit 1be830e

Browse files
committed
Allow disabling HUD from script with new FrameMan SetHudDisabled/IsHudDisabled functions
1 parent 01ccb96 commit 1be830e

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

Lua/LuaBindingsManagers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ namespace RTE {
7272
.property("PlayerScreenWidth", &FrameMan::GetPlayerScreenWidth)
7373
.property("PlayerScreenHeight", &FrameMan::GetPlayerScreenHeight)
7474

75+
.def("IsHudDisabled", &FrameMan::IsHudDisabled)
76+
.def("SetHudDisabled", &FrameMan::SetHudDisabled)
7577
.def("LoadPalette", &FrameMan::LoadPalette)
7678
.def("SetScreenText", &FrameMan::SetScreenText)
7779
.def("ClearScreenText", &FrameMan::ClearScreenText)

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();

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.

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)