From 1be830e724bb1b2cd7d90095cb3343d9e6c24854 Mon Sep 17 00:00:00 2001 From: Causeless Date: Fri, 5 Jan 2024 16:00:02 +0000 Subject: [PATCH 1/4] Allow disabling HUD from script with new FrameMan SetHudDisabled/IsHudDisabled functions --- Lua/LuaBindingsManagers.cpp | 2 ++ Managers/FrameMan.cpp | 1 + Managers/FrameMan.h | 16 ++++++++++++++++ Managers/SceneMan.cpp | 11 +++++++++-- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Lua/LuaBindingsManagers.cpp b/Lua/LuaBindingsManagers.cpp index 3ee688f836..1637e5fd22 100644 --- a/Lua/LuaBindingsManagers.cpp +++ b/Lua/LuaBindingsManagers.cpp @@ -72,6 +72,8 @@ namespace RTE { .property("PlayerScreenWidth", &FrameMan::GetPlayerScreenWidth) .property("PlayerScreenHeight", &FrameMan::GetPlayerScreenHeight) + .def("IsHudDisabled", &FrameMan::IsHudDisabled) + .def("SetHudDisabled", &FrameMan::SetHudDisabled) .def("LoadPalette", &FrameMan::LoadPalette) .def("SetScreenText", &FrameMan::SetScreenText) .def("ClearScreenText", &FrameMan::ClearScreenText) diff --git a/Managers/FrameMan.cpp b/Managers/FrameMan.cpp index 075028acd0..63a047ddee 100644 --- a/Managers/FrameMan.cpp +++ b/Managers/FrameMan.cpp @@ -78,6 +78,7 @@ namespace RTE { m_TextDurationTimer[screenCount].Reset(); m_TextBlinking[screenCount] = 0; m_TextCentered[screenCount] = false; + m_HUDDisabled[screenCount] = false; m_FlashScreenColor[screenCount] = -1; m_FlashedLastFrame[screenCount] = false; m_FlashTimer[screenCount].Reset(); diff --git a/Managers/FrameMan.h b/Managers/FrameMan.h index d67288220a..55d74eb619 100644 --- a/Managers/FrameMan.h +++ b/Managers/FrameMan.h @@ -301,6 +301,20 @@ namespace RTE { } #pragma endregion + /// + /// Gets whether or not the HUD is disabled for a given screen. + /// + /// The screen to check for. + /// True if in given screen's HUD is disabled. + bool IsHudDisabled(int screenId = 0) const { return m_HUDDisabled[screenId]; } + + /// + /// Sets whether or not the HUD is disabled for a given screen. + /// + /// Whether the HUD should be disabled. + /// The screen to set for. + void SetHudDisabled(bool value, int screenId = 0) { m_HUDDisabled[screenId] = value; } + #pragma region Network Handling /// /// Returns true if this manager is in multiplayer mode, storing the 8bpp backbuffer for network transmission. @@ -503,9 +517,11 @@ namespace RTE { bool m_TextCentered[c_MaxScreenCount]; //!< Whether screen text is centered vertically. int m_TextDuration[c_MaxScreenCount]; //!< The minimum duration the current message is supposed to show before it can be overwritten. Timer m_TextDurationTimer[c_MaxScreenCount]; //!< Screen text display duration time. + int m_TextBlinking[c_MaxScreenCount]; //!< Screen text messages blinking interval in ms. 0 is no blink at all, just show message. Timer m_TextBlinkTimer; //!< Screen text blink timer. + bool m_HUDDisabled[c_MaxScreenCount]; //!< Whether the HUD is currently disabled for a given screen. int m_FlashScreenColor[c_MaxScreenCount]; //!< Whether to flash a player's screen a specific color this frame. -1 means no flash. bool m_FlashedLastFrame[c_MaxScreenCount]; //!< Whether we flashed last frame or not. Timer m_FlashTimer[c_MaxScreenCount]; //!< Flash screen timer. diff --git a/Managers/SceneMan.cpp b/Managers/SceneMan.cpp index d78779ae2c..438bec0411 100644 --- a/Managers/SceneMan.cpp +++ b/Managers/SceneMan.cpp @@ -2857,9 +2857,16 @@ void SceneMan::Draw(BITMAP *targetBitmap, BITMAP *targetGUIBitmap, const Vector } } - g_MovableMan.DrawHUD(targetGUIBitmap, targetPos, m_LastUpdatedScreen); + bool shouldDrawHUD = !g_FrameMan.IsHudDisabled(m_LastUpdatedScreen); + if (shouldDrawHUD) { + g_MovableMan.DrawHUD(targetGUIBitmap, targetPos, m_LastUpdatedScreen); + } + g_PrimitiveMan.DrawPrimitives(m_LastUpdatedScreen, targetGUIBitmap, targetPos); - g_ActivityMan.GetActivity()->DrawGUI(targetGUIBitmap, targetPos, m_LastUpdatedScreen); + + if (shouldDrawHUD) { + g_ActivityMan.GetActivity()->DrawGUI(targetGUIBitmap, targetPos, m_LastUpdatedScreen); + } #ifdef DRAW_NOGRAV_BOXES if (Scene::Area* noGravArea = m_pCurrentScene->GetArea("NoGravityArea")) { From 5ca42ff2638693468f5853ad7621c455fd84f2bd Mon Sep 17 00:00:00 2001 From: Causeless Date: Fri, 5 Jan 2024 16:04:25 +0000 Subject: [PATCH 2/4] Updated CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cec94b1c5a..f8b5cf060f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,6 +120,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - New `GameActivity::LockControlledActor` Lua function to allow grab player input in the way menus (buy menu/full inventorymenu) do. +- 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. +
Changed From 063f0ac9aea7ab96ec4d20611b0fd520bfde8905 Mon Sep 17 00:00:00 2001 From: Causeless Date: Fri, 5 Jan 2024 16:14:02 +0000 Subject: [PATCH 3/4] Expose ScreenCount --- CHANGELOG.md | 4 +++- Lua/LuaBindingsManagers.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8b5cf060f..ec7da77798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,12 +116,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - `Enum` binding for `SceneObject.BuyableMode`: `NORESTRICTIONS = 0, BUYMENUONLY = 1, OBJECTPICKERONLY = 2, SCRIPTONLY = 3`. -- Exposed `UInputMan::AbsoluteMousePos` to Lua +- Exposed `UInputMan::AbsoluteMousePos` to Lua. - New `GameActivity::LockControlledActor` Lua function to allow grab player input in the way menus (buy menu/full inventorymenu) do. - 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. +- Exposed `FrameMan` property `ScreenCount` to Lua (R). +
Changed diff --git a/Lua/LuaBindingsManagers.cpp b/Lua/LuaBindingsManagers.cpp index 1637e5fd22..5ec1706fb4 100644 --- a/Lua/LuaBindingsManagers.cpp +++ b/Lua/LuaBindingsManagers.cpp @@ -71,6 +71,7 @@ namespace RTE { .property("PlayerScreenWidth", &FrameMan::GetPlayerScreenWidth) .property("PlayerScreenHeight", &FrameMan::GetPlayerScreenHeight) + .property("ScreenCount", &FrameMan::GetScreenCount) .def("IsHudDisabled", &FrameMan::IsHudDisabled) .def("SetHudDisabled", &FrameMan::SetHudDisabled) From 6cd323706167e0e58b44f3f88307045c3c8e2399 Mon Sep 17 00:00:00 2001 From: Causeless Date: Fri, 5 Jan 2024 17:12:11 +0000 Subject: [PATCH 4/4] Hopeful fix for the player being able to input their way out of observe state --- Activities/GameActivity.cpp | 83 +++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/Activities/GameActivity.cpp b/Activities/GameActivity.cpp index 05d3b7b6f8..78402d7560 100644 --- a/Activities/GameActivity.cpp +++ b/Activities/GameActivity.cpp @@ -1430,55 +1430,50 @@ void GameActivity::Update() m_ControlledActor[player] = 0; } - /////////////////////////////////////////// // Player-commanded actor switching + if (m_ViewState[player] != ViewState::Observe) { + // Switch to brain actor directly if the player wants to + if (m_PlayerController[player].IsState(ACTOR_BRAIN) && m_ViewState[player] != ViewState::ActorSelect) { + SwitchToActor(m_Brain[player], player, team); + m_ViewState[player] = ViewState::Normal; + } else if (m_PlayerController[player].IsState(ACTOR_NEXT) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && !m_LuaLockActor[player]) { + // Switch to next actor if the player wants to. Don't do it while the buy menu is open + if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) { + m_ControlledActor[player]->GetPieMenu()->SetEnabled(false); + } - // Switch to brain actor directly if the player wants to - if (m_PlayerController[player].IsState(ACTOR_BRAIN) && m_ViewState[player] != ViewState::ActorSelect) - { - SwitchToActor(m_Brain[player], player, team); - m_ViewState[player] = ViewState::Normal; - } - // Switch to next actor if the player wants to. Don't do it while the buy menu is open - else if (m_PlayerController[player].IsState(ACTOR_NEXT) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible() && !m_LuaLockActor[player]) - { - if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) { - m_ControlledActor[player]->GetPieMenu()->SetEnabled(false); - } - SwitchToNextActor(player, team); - m_ViewState[player] = ViewState::Normal; - g_FrameMan.ClearScreenText(ScreenOfPlayer(player)); - } - // Switch to prev actor if the player wants to. Don't do it while the buy menu is open - else if (m_PlayerController[player].IsState(ACTOR_PREV) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible()) - { - if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) { - m_ControlledActor[player]->GetPieMenu()->SetEnabled(false); - } - SwitchToPrevActor(player, team); - m_ViewState[player] = ViewState::Normal; - g_FrameMan.ClearScreenText(ScreenOfPlayer(player)); - } - // Go into manual actor select mode if either actor switch buttons are held for a duration - 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))) - { - if (m_ActorSelectTimer[player].IsPastRealMS(250)) - { - // Set cursor to start at the head of controlled actor - if (m_ControlledActor[player]) - { - // Give switched from actor an AI controller - m_ControlledActor[player]->SetControllerMode(Controller::CIM_AI); - m_ControlledActor[player]->GetController()->SetDisabled(false); - m_ActorCursor[player] = m_ControlledActor[player]->GetCPUPos(); - m_CursorTimer.Reset(); + SwitchToNextActor(player, team); + m_ViewState[player] = ViewState::Normal; + g_FrameMan.ClearScreenText(ScreenOfPlayer(player)); + } + // Switch to prev actor if the player wants to. Don't do it while the buy menu is open + else if (m_PlayerController[player].IsState(ACTOR_PREV) && m_ViewState[player] != ViewState::ActorSelect && !m_pBuyGUI[player]->IsVisible()) { + if (m_ControlledActor[player] && m_ControlledActor[player]->GetPieMenu()) { + m_ControlledActor[player]->GetPieMenu()->SetEnabled(false); } - m_ViewState[player] = ViewState::ActorSelect; + + SwitchToPrevActor(player, team); + m_ViewState[player] = ViewState::Normal; g_FrameMan.ClearScreenText(ScreenOfPlayer(player)); - } + } 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))) { + // Go into manual actor select mode if either actor switch buttons are held for a duration + if (m_ActorSelectTimer[player].IsPastRealMS(250)) { + // Set cursor to start at the head of controlled actor + if (m_ControlledActor[player]) { + // Give switched from actor an AI controller + m_ControlledActor[player]->SetControllerMode(Controller::CIM_AI); + m_ControlledActor[player]->GetController()->SetDisabled(false); + m_ActorCursor[player] = m_ControlledActor[player]->GetCPUPos(); + m_CursorTimer.Reset(); + } + + m_ViewState[player] = ViewState::ActorSelect; + g_FrameMan.ClearScreenText(ScreenOfPlayer(player)); + } + } else { + m_ActorSelectTimer[player].Reset(); + } } - else - m_ActorSelectTimer[player].Reset(); //////////////////////////////////// // Update sceneman scroll targets