mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 13:03:11 +01:00
Add API for getting the current game mode
This commit is contained in:
17
distribution/openrct2.d.ts
vendored
17
distribution/openrct2.d.ts
vendored
@@ -173,7 +173,7 @@ declare global {
|
||||
/**
|
||||
* The user's current configuration.
|
||||
*/
|
||||
configuration: Configuration;
|
||||
readonly configuration: Configuration;
|
||||
|
||||
/**
|
||||
* Shared generic storage for all plugins. Data is persistent across instances
|
||||
@@ -183,7 +183,7 @@ declare global {
|
||||
* the `set` method, do not rely on the file being saved by modifying your own
|
||||
* objects. Functions and other internal structures will not be persisted.
|
||||
*/
|
||||
sharedStorage: Configuration;
|
||||
readonly sharedStorage: Configuration;
|
||||
|
||||
/**
|
||||
* Gets the storage for the current plugin if no name is specified.
|
||||
@@ -199,6 +199,12 @@ declare global {
|
||||
*/
|
||||
getParkStorage(pluginName?: string): Configuration;
|
||||
|
||||
/**
|
||||
* The current mode / screen the game is in. Can be used for example to check
|
||||
* whether the game is currently on the title screen or in the scenario editor.
|
||||
*/
|
||||
readonly mode: GameMode;
|
||||
|
||||
/**
|
||||
* Render the current state of the map and save to disc.
|
||||
* Useful for server administration and timelapse creation.
|
||||
@@ -370,6 +376,13 @@ declare global {
|
||||
transparent?: boolean;
|
||||
}
|
||||
|
||||
type GameMode =
|
||||
"normal" |
|
||||
"title" |
|
||||
"scenario_editor" |
|
||||
"track_designer" |
|
||||
"track_manager";
|
||||
|
||||
type ObjectType =
|
||||
"ride" |
|
||||
"small_scenery" |
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
|
||||
# include "../../../OpenRCT2.h"
|
||||
# include "../../../actions/GameAction.h"
|
||||
# include "../../../interface/Screenshot.h"
|
||||
# include "../../../localisation/Formatting.h"
|
||||
@@ -110,6 +111,19 @@ namespace OpenRCT2::Scripting
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string mode_get()
|
||||
{
|
||||
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
|
||||
return "title";
|
||||
else if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
|
||||
return "scenario_editor";
|
||||
else if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|
||||
return "track_designer";
|
||||
else if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
|
||||
return "track_manager";
|
||||
return "normal";
|
||||
}
|
||||
|
||||
void captureImage(const DukValue& options)
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
@@ -439,6 +453,7 @@ namespace OpenRCT2::Scripting
|
||||
dukglue_register_property(ctx, &ScContext::configuration_get, nullptr, "configuration");
|
||||
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_method(ctx, &ScContext::captureImage, "captureImage");
|
||||
dukglue_register_method(ctx, &ScContext::getObject, "getObject");
|
||||
dukglue_register_method(ctx, &ScContext::getAllObjects, "getAllObjects");
|
||||
|
||||
Reference in New Issue
Block a user