diff --git a/CHANGELOG.md b/CHANGELOG.md index cec94b1c5a..ec7da77798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,10 +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/Source/Activities/GameActivity.cpp b/Source/Activities/GameActivity.cpp index 05d3b7b6f8..78402d7560 100644 --- a/Source/Activities/GameActivity.cpp +++ b/Source/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 diff --git a/Source/Lua/LuaBindingsManagers.cpp b/Source/Lua/LuaBindingsManagers.cpp index 3ee688f836..5ec1706fb4 100644 --- a/Source/Lua/LuaBindingsManagers.cpp +++ b/Source/Lua/LuaBindingsManagers.cpp @@ -71,7 +71,10 @@ namespace RTE { .property("PlayerScreenWidth", &FrameMan::GetPlayerScreenWidth) .property("PlayerScreenHeight", &FrameMan::GetPlayerScreenHeight) + .property("ScreenCount", &FrameMan::GetScreenCount) + .def("IsHudDisabled", &FrameMan::IsHudDisabled) + .def("SetHudDisabled", &FrameMan::SetHudDisabled) .def("LoadPalette", &FrameMan::LoadPalette) .def("SetScreenText", &FrameMan::SetScreenText) .def("ClearScreenText", &FrameMan::ClearScreenText) diff --git a/Source/Managers/FrameMan.cpp b/Source/Managers/FrameMan.cpp index 075028acd0..63a047ddee 100644 --- a/Source/Managers/FrameMan.cpp +++ b/Source/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/Source/Managers/FrameMan.h b/Source/Managers/FrameMan.h index d67288220a..55d74eb619 100644 --- a/Source/Managers/FrameMan.h +++ b/Source/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/Source/Managers/SceneMan.cpp b/Source/Managers/SceneMan.cpp index d78779ae2c..438bec0411 100644 --- a/Source/Managers/SceneMan.cpp +++ b/Source/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")) {