Initialise script engine off main thread (#22230)

* Initialise script engine off main thread

* Do not run ScriptEngine.Tick() during initialisation/preloading

* Add 'Loading plugin engine…' string

* Add changelog entry

---------

Co-authored-by: Bas <Basssiiie@users.noreply.github.com>
This commit is contained in:
Aaron van GeffenandBas authored and GitHub committed 2024-07-09 20:19:01 +02:00
1 parent bc0f6c4489
commit 4bfd3f3369
8 files changed
+29 -10

No files matched your search

+1
View File
@@ -3719,6 +3719,7 @@ STR_6644 :Touch enhancements
STR_6645 :Makes some UI elements bigger so they are easier to click or tap.
STR_6646 :Author: {STRING}
STR_6647 :Authors: {STRING}
STR_6648 :Loading plugin engine…
#############
# Scenarios #
+1
View File
@@ -4,6 +4,7 @@
- Feature: [#20832] The ride music tab now shows a track listing for the current music style.
- Feature: [#22172] [Plugin] Expose ride satisfaction ratings to the plugin API.
- Feature: [#22213] [Plugin] Allow plugins to focus on textboxes in custom windows.
- Change: [#22230] The plugin/script engine is now initialised off the main thread.
- Change: [#22251] Hide author info in the scenery window unless debug tools are active.
0.4.12 (2024-07-07)
+1 -1
View File
@@ -131,7 +131,7 @@ public:
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
void Initialise() override
void InitialiseScriptExtensions() override
{
#ifdef ENABLE_SCRIPTING
auto& scriptEngine = GetContext()->GetScriptEngine();
+17 -7
View File
@@ -523,18 +523,14 @@ namespace OpenRCT2
// TODO: preload the title scene in another (parallel) job.
preloaderScene->AddJob([this]() { InitialiseRepositories(); });
preloaderScene->AddJob([this]() { InitialiseScriptEngine(); });
}
else
{
InitialiseRepositories();
InitialiseScriptEngine();
}
#ifdef ENABLE_SCRIPTING
_scriptEngine.Initialise();
#endif
_uiContext->Initialise();
return true;
}
@@ -574,6 +570,17 @@ namespace OpenRCT2
OpenProgress(STR_LOADING_GENERIC);
}
void InitialiseScriptEngine()
{
#ifdef ENABLE_SCRIPTING
OpenProgress(STR_LOADING_PLUGIN_ENGINE);
_scriptEngine.Initialise();
_uiContext->InitialiseScriptExtensions();
OpenProgress(STR_LOADING_GENERIC);
#endif
}
public:
void InitialiseDrawingEngine() final override
{
@@ -1349,7 +1356,10 @@ namespace OpenRCT2
ChatUpdate();
#ifdef ENABLE_SCRIPTING
_scriptEngine.Tick();
if (GetActiveScene() != GetPreloaderScene())
{
_scriptEngine.Tick();
}
#endif
_stdInOutConsole.ProcessEvalQueue();
_uiContext->Tick();
+2
View File
@@ -1692,6 +1692,8 @@ enum : StringId
STR_STRING_M_OF_N = 6642,
STR_STRING_M_OF_N_KIB = 6643,
STR_LOADING_PLUGIN_ENGINE = 6648,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
/* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings
};
+5
View File
@@ -913,6 +913,11 @@ bool ScriptEngine::ShouldStartPlugin(const std::shared_ptr<Plugin>& plugin)
void ScriptEngine::Tick()
{
if (!_initialised)
{
return;
}
PROFILED_FUNCTION();
CheckAndStartPlugins();
+1 -1
View File
@@ -24,7 +24,7 @@ namespace OpenRCT2::Ui
std::unique_ptr<IWindowManager> const _windowManager = CreateDummyWindowManager();
public:
void Initialise() override
void InitialiseScriptExtensions() override
{
}
void Tick() override
+1 -1
View File
@@ -99,7 +99,7 @@ namespace OpenRCT2
{
virtual ~IUiContext() = default;
virtual void Initialise() abstract;
virtual void InitialiseScriptExtensions() abstract;
virtual void Tick() abstract;
virtual void Draw(DrawPixelInfo& dpi) abstract;