diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 42ad66a704..7665964bd4 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -3,6 +3,7 @@ - Feature: [#13967] Track List window now displays the path to the design when debugging tools are on. - Feature: [#14071] “Vandals stopped” statistic for security guards. - Feature: [#14296] Allow using early scenario completion in multiplayer. +- Feature: [#14538] [Plugin] Add property for getting current plugin api version. - Change: [#14496] [Plugin] Rename Object to LoadedObject to fix conflicts with Typescript's Object interface. - Change: [#14536] [Plugin] Rename ListView to ListViewWidget to make it consistent with names of other widgets. - Fix: [#11829] Visual glitches and crashes when using RCT1 assets from mismatched or corrupt CSG1.DAT and CSG1i.DAT files. diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index 775d804c9c..8d110c2120 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -159,6 +159,12 @@ declare global { * Core APIs for storage and subscriptions. */ interface Context { + /** + * Gets the current version of the plugin api. This is an integer that increments + * by 1 every time a change to the plugin api is made. + */ + readonly apiVersion: number; + /** * The user's current configuration. */ diff --git a/src/openrct2/scripting/ScContext.hpp b/src/openrct2/scripting/ScContext.hpp index 83b1905065..049e37963e 100644 --- a/src/openrct2/scripting/ScContext.hpp +++ b/src/openrct2/scripting/ScContext.hpp @@ -42,6 +42,11 @@ namespace OpenRCT2::Scripting } private: + int32_t apiVersion_get() + { + return OPENRCT2_PLUGIN_API_VERSION; + } + std::shared_ptr configuration_get() { return std::make_shared(); @@ -373,6 +378,7 @@ namespace OpenRCT2::Scripting public: static void Register(duk_context* ctx) { + dukglue_register_property(ctx, &ScContext::apiVersion_get, nullptr, "apiVersion"); dukglue_register_property(ctx, &ScContext::configuration_get, nullptr, "configuration"); dukglue_register_property(ctx, &ScContext::sharedStorage_get, nullptr, "sharedStorage"); dukglue_register_method(ctx, &ScContext::captureImage, "captureImage"); diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index 4332c1ddaa..bb93efdc36 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -44,8 +44,6 @@ using namespace OpenRCT2; using namespace OpenRCT2::Scripting; -static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 26; - struct ExpressionStringifier final { private: diff --git a/src/openrct2/scripting/ScriptEngine.h b/src/openrct2/scripting/ScriptEngine.h index 0c5ba8df20..35fa413c15 100644 --- a/src/openrct2/scripting/ScriptEngine.h +++ b/src/openrct2/scripting/ScriptEngine.h @@ -46,6 +46,8 @@ namespace OpenRCT2 namespace OpenRCT2::Scripting { + static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 27; + # ifndef DISABLE_NETWORK class ScSocketBase; # endif