Show dialogs after OBS_FRONTEND_EVENT_FINISHED_LOADING is fired
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled

This commit is contained in:
WarmUpTill
2026-02-23 17:18:15 +01:00
committed by WarmUpTill
parent 4966802f14
commit ff98ec36d6
5 changed files with 57 additions and 49 deletions

View File

@@ -3,12 +3,42 @@
#include "macro-signals.hpp"
#include "switcher-data.hpp"
#include "obs-frontend-api.h"
namespace advss {
static std::mutex initMutex;
static std::mutex postLoadMutex;
static std::mutex finishLoadMutex;
static std::mutex mutex;
static bool setup();
static bool setupDonw = setup();
bool loadingFinished = false;
static std::vector<std::function<void()>> &getFinishLoadSteps();
static bool setup()
{
static auto handleEvent = [](enum obs_frontend_event event, void *) {
switch (event) {
case OBS_FRONTEND_EVENT_FINISHED_LOADING: {
std::lock_guard<std::mutex> lock(finishLoadMutex);
for (const auto &step : getFinishLoadSteps()) {
step();
}
getFinishLoadSteps().clear();
loadingFinished = true;
break;
}
default:
break;
};
};
obs_frontend_add_event_callback(handleEvent, nullptr);
return true;
}
static std::vector<std::function<void()>> &getPluginInitSteps()
{
static std::vector<std::function<void()>> steps;
@@ -63,6 +93,12 @@ static std::vector<std::function<void()>> &getPostLoadSteps()
return steps;
}
static std::vector<std::function<void()>> &getFinishLoadSteps()
{
static std::vector<std::function<void()>> steps;
return steps;
}
void SavePluginSettings(obs_data_t *obj)
{
GetSwitcher()->SaveSettings(obj);
@@ -178,6 +214,16 @@ void RunIntervalResetSteps()
}
}
void AddFinishedLoadingStep(std::function<void()> step)
{
std::lock_guard<std::mutex> lock(finishLoadMutex);
if (loadingFinished) {
return;
}
getFinishLoadSteps().emplace_back(step);
}
void AddStartStep(std::function<void()> step)
{
std::lock_guard<std::mutex> lock(mutex);