Add getter for current plugin api version (#14538)

This commit is contained in:
Basssiiie 2021-04-28 02:08:56 +02:00 committed by GitHub
parent ec7088364e
commit 6c65105261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 2 deletions

View File

@ -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.

View File

@ -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.
*/

View File

@ -42,6 +42,11 @@ namespace OpenRCT2::Scripting
}
private:
int32_t apiVersion_get()
{
return OPENRCT2_PLUGIN_API_VERSION;
}
std::shared_ptr<ScConfiguration> configuration_get()
{
return std::make_shared<ScConfiguration>();
@ -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");

View File

@ -44,8 +44,6 @@
using namespace OpenRCT2;
using namespace OpenRCT2::Scripting;
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 26;
struct ExpressionStringifier final
{
private:

View File

@ -46,6 +46,8 @@ namespace OpenRCT2
namespace OpenRCT2::Scripting
{
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 27;
# ifndef DISABLE_NETWORK
class ScSocketBase;
# endif