From cd528665e64d252dbfe754268432d32df569002a Mon Sep 17 00:00:00 2001 From: Katherine Norton Date: Fri, 3 May 2024 10:59:57 -0500 Subject: [PATCH] Expose whether the game is paused to the plugin API --- distribution/changelog.txt | 1 + distribution/openrct2.d.ts | 5 +++++ src/openrct2/scripting/ScriptEngine.h | 2 +- src/openrct2/scripting/bindings/game/ScContext.hpp | 6 ++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index ea327ed55e..6cef976887 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -2,6 +2,7 @@ ------------------------------------------------------------------------ - Feature: [#11512] Coloured usernames by group on multiplayer servers. - Feature: [#21734] Park admittance price can now be set via text input. +- Feature: [#21957] [Plugin] Expose whether the game is paused to the plugin API. - Improved: [#21728] “Fix all rides” cheat now also works if a mechanic is already fixing the ride. - Improved: [#21769] Expose “animation is backwards” wall property in Tile Inspector. - Improved: [#21855] Add a separator between “Load Game” and “Save Game”, to avoid accidental overwriting. diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index eafdaafd42..4cc2078b17 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -216,6 +216,11 @@ declare global { */ readonly mode: GameMode; + /** + * Whether the game is currently paused or not. + */ + readonly paused: boolean; + /** * Render the current state of the map and save to disc. * Useful for server administration and timelapse creation. diff --git a/src/openrct2/scripting/ScriptEngine.h b/src/openrct2/scripting/ScriptEngine.h index dcc7019303..e0e64948bd 100644 --- a/src/openrct2/scripting/ScriptEngine.h +++ b/src/openrct2/scripting/ScriptEngine.h @@ -47,7 +47,7 @@ namespace OpenRCT2 namespace OpenRCT2::Scripting { - static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 84; + static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 85; // Versions marking breaking changes. static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33; diff --git a/src/openrct2/scripting/bindings/game/ScContext.hpp b/src/openrct2/scripting/bindings/game/ScContext.hpp index 76d5d67ca6..13beeb76c9 100644 --- a/src/openrct2/scripting/bindings/game/ScContext.hpp +++ b/src/openrct2/scripting/bindings/game/ScContext.hpp @@ -126,6 +126,11 @@ namespace OpenRCT2::Scripting return "normal"; } + bool paused_get() + { + return GameIsPaused(); + } + void captureImage(const DukValue& options) { auto ctx = GetContext()->GetScriptEngine().GetContext(); @@ -433,6 +438,7 @@ namespace OpenRCT2::Scripting dukglue_register_property(ctx, &ScContext::sharedStorage_get, nullptr, "sharedStorage"); dukglue_register_method(ctx, &ScContext::getParkStorage, "getParkStorage"); dukglue_register_property(ctx, &ScContext::mode_get, nullptr, "mode"); + dukglue_register_property(ctx, &ScContext::paused_get, nullptr, "paused"); dukglue_register_method(ctx, &ScContext::captureImage, "captureImage"); dukglue_register_method(ctx, &ScContext::getObject, "getObject"); dukglue_register_method(ctx, &ScContext::getAllObjects, "getAllObjects");