From 4e72d580f8cf0e123ecd784b01e6afcdb1c13465 Mon Sep 17 00:00:00 2001 From: spacek531 Date: Tue, 25 Jun 2024 02:36:01 -0700 Subject: [PATCH] Allow non-networked plug-ins to set pause state directly --- distribution/changelog.txt | 1 + distribution/openrct2.d.ts | 4 ++-- src/openrct2/scripting/bindings/game/ScContext.hpp | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 1ed92c6d76..131e89e4cd 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -9,6 +9,7 @@ - Feature: [#22046] [Plugin] Add interface for crashed vehicle particle. - Feature: [#22085] [Plugin] The result of actions that create banners now includes the bannerIndex. - Feature: [#22087] [Plugin] Expose guests’ favourite rides to the plugin API. +- Feature: [#22090] [Plugin] Allow writing of paused state in non-networked settings. - Feature: [#22140] Add option to automatically close dropdown menus if Enlarged UI is enabled. - Feature: [#22150] [Plugin] Expose monthly expenditure history to the plugin API. - Improved: [#19870] Allow using new colours in UI themes. diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index 3ad16189b7..f335ab7716 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -217,9 +217,9 @@ declare global { readonly mode: GameMode; /** - * Whether the game is currently paused or not. + * Whether the game is currently paused or not. Readonly in network mode. */ - readonly paused: boolean; + paused: boolean; /** * Render the current state of the map and save to disc. diff --git a/src/openrct2/scripting/bindings/game/ScContext.hpp b/src/openrct2/scripting/bindings/game/ScContext.hpp index a4544b2461..f398c39f14 100644 --- a/src/openrct2/scripting/bindings/game/ScContext.hpp +++ b/src/openrct2/scripting/bindings/game/ScContext.hpp @@ -131,6 +131,13 @@ namespace OpenRCT2::Scripting return GameIsPaused(); } + void paused_set(const bool& value) + { + ThrowIfGameStateNotMutable(); + if (value != GameIsPaused()) + PauseToggle(); + } + void captureImage(const DukValue& options) { auto ctx = GetContext()->GetScriptEngine().GetContext(); @@ -438,7 +445,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_property(ctx, &ScContext::paused_get, &ScContext::paused_set, "paused"); dukglue_register_method(ctx, &ScContext::captureImage, "captureImage"); dukglue_register_method(ctx, &ScContext::getObject, "getObject"); dukglue_register_method(ctx, &ScContext::getAllObjects, "getAllObjects");