From ff0eb2fb70df3aa374acd1bbba23871a2d4b1cf5 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Fri, 29 Sep 2023 08:23:52 +0200 Subject: Refresh Callback (+ Extra for AboutToRun) (#1884) * Add working directory and arguments to onAboutToRun (optional). * Add onRefreshCallback functionality. --- src/organizerproxy.cpp | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'src/organizerproxy.cpp') diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index a47e8798..0c1fb409 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -323,6 +323,19 @@ MOBase::IPluginGame const* OrganizerProxy::managedGame() const // CALLBACKS bool OrganizerProxy::onAboutToRun(const std::function& func) +{ + return m_Proxied + ->onAboutToRun(MOShared::callIfPluginActive( + this, + [func](const QString& binary, const QDir&, const QString&) { + return func(binary); + }, + true)) + .connected(); +} + +bool OrganizerProxy::onAboutToRun( + const std::function& func) { return m_Proxied->onAboutToRun(MOShared::callIfPluginActive(this, func, true)) .connected(); @@ -334,6 +347,25 @@ bool OrganizerProxy::onFinishedRun( return m_Proxied->onFinishedRun(MOShared::callIfPluginActive(this, func)).connected(); } +bool OrganizerProxy::onUserInterfaceInitialized( + std::function const& func) +{ + // Always call this one to allow plugin to initialize themselves even when not active: + return m_UserInterfaceInitialized.connect(func).connected(); +} + +bool OrganizerProxy::onNextRefresh(const std::function& func, + bool immediateIfPossible) +{ + using enum OrganizerCore::RefreshCallbackMode; + return m_Proxied + ->onNextRefresh(MOShared::callIfPluginActive(this, func), + OrganizerCore::RefreshCallbackGroup::EXTERNAL, + immediateIfPossible ? RUN_NOW_IF_POSSIBLE + : FORCE_WAIT_FOR_REFRESH) + .connected(); +} + bool OrganizerProxy::onProfileCreated(std::function const& func) { return m_ProfileCreated.connect(func).connected(); @@ -355,14 +387,6 @@ bool OrganizerProxy::onProfileChanged( { return m_ProfileChanged.connect(func).connected(); } - -bool OrganizerProxy::onUserInterfaceInitialized( - std::function const& func) -{ - // Always call this one to allow plugin to initialize themselves even when not active: - return m_UserInterfaceInitialized.connect(func).connected(); -} - // Always call these one, otherwise plugin cannot detect they are being enabled / // disabled: bool OrganizerProxy::onPluginSettingChanged( -- cgit v1.3.1