1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Make all GameAction types accessible to plugins (#12708)

* add ActionType

* Make all game actions available to plugins

Includes list of game actions in the .d.ts

* Add an overload for internal game actions

This allows things like Visual Studio Code to autocomplete

* action can be a string (custom gameactions)

* Increment OPENRCT2_PLUGIN_API_VERSION

* Add #12708 to changelog and tombomp to contributors.
This commit is contained in:
Tom Parsons
2020-09-10 12:30:56 +01:00
committed by GitHub
parent 11ebe78328
commit 9a30100a81
4 changed files with 146 additions and 3 deletions

View File

@@ -155,6 +155,7 @@ The following people are not part of the development team, but have been contrib
* Ryan Bello (ryan-bello)
* Simon Jarrett (mwnciau)
* Richard Fine (richard-fine)
* Tom Parsons (tombomp)
## Toolchain
* (Balletie) - macOS

View File

@@ -1,6 +1,7 @@
0.3.0+ (in development)
------------------------------------------------------------------------
- Feature: [#10807] Add 2x and 4x zoom levels (currently limited to OpenGL).
- Feature: [#12708] Add plugin-accessible names to all game actions.
- Feature: [#12712] Add TCP / socket plugin APIs.
- Feature: [#12840] Add Park.entranceFee to the plugin API.
- Fix: [#400] Unable to place some saved tracks flush to the ground (original bug).

View File

@@ -200,6 +200,7 @@ declare global {
* @param args The action parameters.
* @param callback The function to be called with the result of the action.
*/
queryAction(action: ActionType, args: object, callback: (result: GameActionResult) => void): void;
queryAction(action: string, args: object, callback: (result: GameActionResult) => void): void;
/**
@@ -209,6 +210,7 @@ declare global {
* @param args The action parameters.
* @param callback The function to be called with the result of the action.
*/
executeAction(action: ActionType, args: object, callback: (result: GameActionResult) => void): void;
executeAction(action: string, args: object, callback: (result: GameActionResult) => void): void;
/**
@@ -309,9 +311,89 @@ declare global {
"research" |
"interest";
type ActionType =
"balloonpress" |
"bannerplace" |
"bannerremove" |
"bannersetcolour" |
"bannersetname" |
"bannersetstyle" |
"clearscenery" |
"climateset" |
"footpathplace" |
"footpathplacefromtrack" |
"foothpathremove" |
"footpathsceneryplace" |
"footpathsceneryremove" |
"guestsetflags" |
"guestsetname" |
"landbuyrights" |
"landlower" |
"landraise" |
"landsetheight" |
"landsetrights" |
"landsmoothaction" |
"largesceneryplace" |
"largesceneryremove" |
"largescenerysetcolour" |
"loadorquit" |
"mazeplacetrack" |
"mazesettrack" |
"networkmodifygroup" |
"parkentranceremove" |
"parkmarketing" |
"parksetdate" |
"parksetloan" |
"parksetname" |
"parksetparameter" |
"parksetresearchfunding" |
"pausetoggle" |
"peeppickup" |
"placeparkentrance" |
"placepeepspawn" |
"playerkick" |
"playersetgroup" |
"ridecreate" |
"ridedemolish" |
"rideentranceexitplace" |
"rideentranceexitremove" |
"ridesetappearance" |
"ridesetcolourscheme" |
"ridesetname" |
"ridesetprice" |
"ridesetsetting" |
"ridesetstatus" |
"ridesetvehicles" |
"scenariosetsetting" |
"setcheataction" |
"setparkentrancefee" |
"signsetname" |
"smallsceneryplace" |
"smallsceneryremove" |
"stafffire" |
"staffhire" |
"staffsetcolour" |
"staffsetcostume" |
"staffsetname" |
"staffsetorders" |
"staffsetpatrolarea" |
"surfacesetstyle" |
"tilemodify" |
"trackdesign" |
"trackplace" |
"trackremove" |
"tracksetbrakespeed" |
"wallplace" |
"wallremove" |
"wallsetcolour" |
"waterlower" |
"waterraise" |
"watersetheight";
interface GameActionEventArgs {
readonly player: number;
readonly type: string;
readonly type: number;
readonly action: string;
readonly isClientOnly: boolean;
readonly args: object;
result: GameActionResult;

View File

@@ -42,7 +42,7 @@
using namespace OpenRCT2;
using namespace OpenRCT2::Scripting;
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 4;
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 5;
struct ExpressionStringifier final
{
@@ -948,25 +948,84 @@ public:
};
const static std::unordered_map<std::string, uint32_t> ActionNameToType = {
{ "balloonpress", GAME_COMMAND_BALLOON_PRESS },
{ "bannerplace", GAME_COMMAND_PLACE_BANNER },
{ "bannerremove", GAME_COMMAND_REMOVE_BANNER },
{ "bannersetcolour", GAME_COMMAND_SET_BANNER_COLOUR },
{ "bannersetname", GAME_COMMAND_SET_BANNER_NAME },
{ "bannersetstyle", GAME_COMMAND_SET_BANNER_STYLE },
{ "clearscenery", GAME_COMMAND_CLEAR_SCENERY },
{ "climateset", GAME_COMMAND_SET_CLIMATE },
{ "footpathplace", GAME_COMMAND_PLACE_PATH },
{ "footpathplacefromtrack", GAME_COMMAND_PLACE_PATH_FROM_TRACK },
{ "footpathremove", GAME_COMMAND_REMOVE_PATH },
{ "footpathsceneryplace", GAME_COMMAND_PLACE_FOOTPATH_SCENERY },
{ "footpathsceneryremove", GAME_COMMAND_REMOVE_FOOTPATH_SCENERY },
{ "guestsetflags", GAME_COMMAND_GUEST_SET_FLAGS },
{ "guestsetname", GAME_COMMAND_SET_GUEST_NAME },
{ "landbuyrights", GAME_COMMAND_BUY_LAND_RIGHTS },
{ "landlower", GAME_COMMAND_LOWER_LAND },
{ "landraise", GAME_COMMAND_RAISE_LAND },
{ "landsetheight", GAME_COMMAND_SET_LAND_HEIGHT },
{ "landsetrights", GAME_COMMAND_SET_LAND_OWNERSHIP },
{ "landsmoothaction", GAME_COMMAND_EDIT_LAND_SMOOTH },
{ "largesceneryplace", GAME_COMMAND_PLACE_LARGE_SCENERY },
{ "largesceneryremove", GAME_COMMAND_REMOVE_LARGE_SCENERY },
{ "largescenerysetcolour", GAME_COMMAND_SET_SCENERY_COLOUR },
{ "loadorquit", GAME_COMMAND_LOAD_OR_QUIT },
{ "mazeplacetrack", GAME_COMMAND_PLACE_MAZE_DESIGN },
{ "mazesettrack", GAME_COMMAND_SET_MAZE_TRACK },
{ "networkmodifygroup", GAME_COMMAND_MODIFY_GROUPS },
{ "parkentranceremove", GAME_COMMAND_REMOVE_PARK_ENTRANCE },
{ "parkmarketing", GAME_COMMAND_START_MARKETING_CAMPAIGN },
{ "parksetdate", GAME_COMMAND_SET_DATE },
{ "parksetloan", GAME_COMMAND_SET_CURRENT_LOAN },
{ "parksetname", GAME_COMMAND_SET_PARK_NAME },
{ "parksetparameter", GAME_COMMAND_SET_PARK_OPEN },
{ "parksetresearchfunding", GAME_COMMAND_SET_RESEARCH_FUNDING },
{ "pausetoggle", GAME_COMMAND_TOGGLE_PAUSE },
{ "peeppickup", GAME_COMMAND_PICKUP_GUEST },
{ "placeparkentrance", GAME_COMMAND_PLACE_PARK_ENTRANCE },
{ "placepeepspawn", GAME_COMMAND_PLACE_PEEP_SPAWN },
{ "playerkick", GAME_COMMAND_KICK_PLAYER },
{ "playersetgroup", GAME_COMMAND_SET_PLAYER_GROUP },
{ "ridecreate", GAME_COMMAND_CREATE_RIDE },
{ "ridedemolish", GAME_COMMAND_DEMOLISH_RIDE },
{ "rideentranceexitplace", GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT },
{ "rideentranceexitremove", GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT },
{ "ridesetappearance", GAME_COMMAND_SET_RIDE_APPEARANCE },
{ "ridesetcolourscheme.hpp", GAME_COMMAND_SET_COLOUR_SCHEME },
{ "ridesetcolourscheme", GAME_COMMAND_SET_COLOUR_SCHEME },
{ "ridesetname", GAME_COMMAND_SET_RIDE_NAME },
{ "ridesetprice", GAME_COMMAND_SET_RIDE_PRICE },
{ "ridesetsetting", GAME_COMMAND_SET_RIDE_SETTING },
{ "ridesetstatus", GAME_COMMAND_SET_RIDE_STATUS },
{ "ridesetvehicles", GAME_COMMAND_SET_RIDE_VEHICLES },
{ "scenariosetsetting", GAME_COMMAND_EDIT_SCENARIO_OPTIONS },
{ "setcheataction", GAME_COMMAND_CHEAT },
{ "setparkentrancefee", GAME_COMMAND_SET_PARK_ENTRANCE_FEE },
{ "signsetname", GAME_COMMAND_SET_SIGN_NAME },
{ "signsetstyle", GAME_COMMAND_SET_SIGN_STYLE },
{ "smallsceneryplace", GAME_COMMAND_PLACE_SCENERY },
{ "smallsceneryremove", GAME_COMMAND_REMOVE_SCENERY },
{ "stafffire", GAME_COMMAND_FIRE_STAFF_MEMBER },
{ "staffhire", GAME_COMMAND_HIRE_NEW_STAFF_MEMBER },
{ "staffsetcolour", GAME_COMMAND_SET_STAFF_COLOUR },
{ "staffsetcostume", GAME_COMMAND_SET_STAFF_COSTUME },
{ "staffsetname", GAME_COMMAND_SET_STAFF_NAME },
{ "staffsetorders", GAME_COMMAND_SET_STAFF_ORDERS },
{ "staffsetpatrolarea", GAME_COMMAND_SET_STAFF_PATROL },
{ "surfacesetstyle", GAME_COMMAND_CHANGE_SURFACE_STYLE },
{ "tilemodify", GAME_COMMAND_MODIFY_TILE },
{ "trackdesign", GAME_COMMAND_PLACE_TRACK_DESIGN },
{ "trackplace", GAME_COMMAND_PLACE_TRACK },
{ "trackremove", GAME_COMMAND_REMOVE_TRACK },
{ "tracksetbrakespeed", GAME_COMMAND_SET_BRAKES_SPEED },
{ "wallplace", GAME_COMMAND_PLACE_WALL },
{ "wallremove", GAME_COMMAND_REMOVE_WALL },
{ "wallsetcolour", GAME_COMMAND_SET_WALL_COLOUR },
{ "waterlower", GAME_COMMAND_LOWER_WATER },
{ "waterraise", GAME_COMMAND_RAISE_WATER },
{ "watersetheight", GAME_COMMAND_SET_WATER_HEIGHT }
};
static std::string GetActionName(uint32_t commandId)