mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 06:44:38 +01:00
Merge pull request #16707 from IntelOrca/plugin/intransient-2
Add initial functionality for intransient plugins. Intransient plugins are a new type of plugin that will start when OpenRCT2 launches, and remain loaded until shutdown. This provides plugins with the ability to hook map change and provide functionality on other screens such as the title menu.
**Example:**
```js
registerPlugin({
type: 'intransient',
...
});
```
The [title sequence editor](https://github.com/OpenRCT2/title-sequence-editor) will be an intransient plugin so that it can be used from the title screen like the built in one.
Three new APIs have been introduced alongside this.
* `context.mode`
* `context.subscribe('map.change', callback)`
* `context.subscribe('map.changed', callback)`
* `ui.registerToolboxMenuItem(text, callback)`
This commit is contained in:
@@ -203,6 +203,11 @@ void NetworkBase::Close()
|
||||
_pendingPlayerLists.clear();
|
||||
_pendingPlayerInfo.clear();
|
||||
|
||||
# ifdef ENABLE_SCRIPTING
|
||||
auto& scriptEngine = GetContext().GetScriptEngine();
|
||||
scriptEngine.RemoveNetworkPlugins();
|
||||
# endif
|
||||
|
||||
gfx_invalidate_screen();
|
||||
|
||||
_requireClose = false;
|
||||
@@ -403,6 +408,7 @@ bool NetworkBase::BeginServer(uint16_t port, const std::string& address)
|
||||
_advertiser = CreateServerAdvertiser(listening_port);
|
||||
|
||||
game_load_scripts();
|
||||
game_notify_map_changed();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2680,6 +2686,9 @@ void NetworkBase::Client_Handle_MAP([[maybe_unused]] NetworkConnection& connecti
|
||||
GameActions::ResumeQueue();
|
||||
|
||||
context_force_close_window_by_class(WC_NETWORK_STATUS);
|
||||
game_unload_scripts();
|
||||
game_notify_map_change();
|
||||
|
||||
bool has_to_free = false;
|
||||
uint8_t* data = &chunk_buffer[0];
|
||||
size_t data_size = size;
|
||||
@@ -2688,6 +2697,7 @@ void NetworkBase::Client_Handle_MAP([[maybe_unused]] NetworkConnection& connecti
|
||||
{
|
||||
game_load_init();
|
||||
game_load_scripts();
|
||||
game_notify_map_changed();
|
||||
_serverState.tick = gCurrentTicks;
|
||||
// window_network_status_open("Loaded new map from network");
|
||||
_serverState.state = NetworkServerState::Ok;
|
||||
|
||||
Reference in New Issue
Block a user