diff --git a/src/fps_overlay.cpp b/src/fps_overlay.cpp index 8a99bacb5b..f45c599aad 100644 --- a/src/fps_overlay.cpp +++ b/src/fps_overlay.cpp @@ -85,7 +85,7 @@ void FpsOverlay::Draw(Bitmap& dst) { } // Always drawn when speedup is on independent of FPS - if (last_speed_mod > 1) { + if (!Game_Clock::GetSpeedOverlayMode() && last_speed_mod > 1) { if (speedup_dirty) { std::string text = "> x" + std::to_string(last_speed_mod); diff --git a/src/game_clock.cpp b/src/game_clock.cpp index 99c7dae5b8..15c3c029f9 100644 --- a/src/game_clock.cpp +++ b/src/game_clock.cpp @@ -25,6 +25,8 @@ constexpr bool Game_Clock::is_steady; Game_Clock::Data Game_Clock::data; +int hideDisplay = 0; + // Damping factor fps computation. static constexpr auto _fps_smooth = 2.0f / 121.0f; diff --git a/src/game_clock.h b/src/game_clock.h index c277cf2d9d..a5dbf3e0ce 100644 --- a/src/game_clock.h +++ b/src/game_clock.h @@ -36,6 +36,8 @@ class Game_Clock { using duration = clock::duration; using time_point = clock::time_point; + int hideDisplay; + static constexpr bool is_steady = clock::is_steady; /** Get current time */ @@ -76,6 +78,12 @@ class Game_Clock { /** @return the speed up or slowdown factor we'll use to run the game. */ static float GetGameSpeedFactor(); + /** Set either if Speed Multiplier Overlay is hidden or Visible. */ + static void setSpeedOverlayMode(bool mode); + + /** Check if Speed Multiplier Overlay is hidden or Visible. */ + static int GetSpeedOverlayMode(); + /** Get the time of the current frame */ static time_point GetFrameTime(); @@ -117,6 +125,7 @@ class Game_Clock { float speed = 1.0; float fps = 0.0; int frame = 0; + bool hideSpeedOverlay = 0; }; static Data data; }; @@ -180,4 +189,12 @@ inline float Game_Clock::GetGameSpeedFactor() { return data.speed; } +inline int Game_Clock::GetSpeedOverlayMode() { + return data.hideSpeedOverlay; +} + +inline void Game_Clock::setSpeedOverlayMode(bool s) { + data.hideSpeedOverlay = s; +} + #endif diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 0b61a59070..ec20fa4d06 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -825,6 +825,8 @@ bool Game_Interpreter::ExecuteCommand(lcf::rpg::EventCommand const& com) { return CommandManiacControlStrings(com); case Cmd::Maniac_CallCommand: return CommandManiacCallCommand(com); + case static_cast(2049) : //Cmd::Easy_SetGameSpeed + return CommandSetGameSpeed(com); default: return true; } @@ -4985,6 +4987,25 @@ bool Game_Interpreter::CommandManiacCallCommand(lcf::rpg::EventCommand const&) { return true; } +bool Game_Interpreter::CommandSetGameSpeed(lcf::rpg::EventCommand const& com) { + // #SetGameSpeed, "",[speedIsVar, speed, speedLimitIsVar,speedLimit, hideSpeedMultiplierIsVar, hideSpeedMultiplier ]; + + int32_t speed = ValueOrVariable(com.parameters[0], com.parameters[1]) * Game_Clock::GetGameSpeedFactor(); + int32_t speedLimit = ValueOrVariable(com.parameters[2], com.parameters[3]); + bool hideSpeedMultiplier = ValueOrVariable(com.parameters[4], com.parameters[5]); + + if (speedLimit == 0) speedLimit = 100; + if (speed > speedLimit) speed = speedLimit; + + if (Input::IsSystemPressed(Input::FAST_FORWARD_A) || Input::IsSystemPressed(Input::FAST_FORWARD_B)) + Game_Clock::setSpeedOverlayMode(0); + else + Game_Clock::setSpeedOverlayMode(hideSpeedMultiplier); + + Game_Clock::SetGameSpeedFactor(speed); + return true; +} + Game_Interpreter& Game_Interpreter::GetForegroundInterpreter() { return Game_Battle::IsBattleRunning() ? Game_Battle::GetInterpreter() diff --git a/src/game_interpreter.h b/src/game_interpreter.h index a24c51e9dd..32ad9b771b 100644 --- a/src/game_interpreter.h +++ b/src/game_interpreter.h @@ -285,6 +285,7 @@ class Game_Interpreter bool CommandManiacSetGameOption(lcf::rpg::EventCommand const& com); bool CommandManiacControlStrings(lcf::rpg::EventCommand const& com); bool CommandManiacCallCommand(lcf::rpg::EventCommand const& com); + bool CommandSetGameSpeed(lcf::rpg::EventCommand const& com); int DecodeInt(lcf::DBArray::const_iterator& it); const std::string DecodeString(lcf::DBArray::const_iterator& it); diff --git a/src/player.cpp b/src/player.cpp index f1e23add71..735dd6f42b 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -310,6 +310,7 @@ void Player::UpdateInput() { if (Input::IsSystemPressed(Input::FAST_FORWARD_B)) { speed = speed_modifier_b; } + Game_Clock::setSpeedOverlayMode(0); Game_Clock::SetGameSpeedFactor(speed); if (Main_Data::game_quit) {