mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-05-06 04:47:08 -05:00
Use static self-registration for action queue and variable setup
Removes explicit setup calls from the plugin core. Each module now registers its own save/load/cleanup steps via a static initializer, decoupling them from InitSceneSwitcher and SwitcherData.
This commit is contained in:
parent
c02896ea17
commit
4f3d9e3a00
|
|
@ -774,8 +774,6 @@ void HighlightMacroSettingsButton(bool enable)
|
|||
enable);
|
||||
}
|
||||
|
||||
void SetupActionQueues();
|
||||
|
||||
extern "C" EXPORT void InitSceneSwitcher(obs_module_t *module,
|
||||
translateFunc translate)
|
||||
{
|
||||
|
|
@ -787,7 +785,6 @@ extern "C" EXPORT void InitSceneSwitcher(obs_module_t *module,
|
|||
PlatformInit();
|
||||
LoadPlugins();
|
||||
SetupDock();
|
||||
SetupActionQueues();
|
||||
|
||||
RunPluginInitSteps();
|
||||
|
||||
|
|
|
|||
|
|
@ -468,7 +468,6 @@ void SwitcherData::LoadSettings(obs_data_t *obj)
|
|||
// Needs to be loaded before any entries which might rely on scene group
|
||||
// selections to be available.
|
||||
loadSceneGroups(obj);
|
||||
LoadVariables(obj);
|
||||
|
||||
RunLoadSteps(obj);
|
||||
|
||||
|
|
@ -507,7 +506,6 @@ void SwitcherData::SaveSettings(obs_data_t *obj)
|
|||
saveSceneGroups(obj);
|
||||
SaveMacros(obj);
|
||||
SaveGlobalMacroSettings(obj);
|
||||
SaveVariables(obj);
|
||||
saveWindowTitleSwitches(obj);
|
||||
saveScreenRegionSwitches(obj);
|
||||
savePauseSwitches(obj);
|
||||
|
|
|
|||
|
|
@ -16,14 +16,17 @@ static void setupTab(QTabWidget *);
|
|||
|
||||
static ActionQueueTable *tabWidget = nullptr;
|
||||
|
||||
void RegisterActionQueueTab()
|
||||
static bool setup()
|
||||
{
|
||||
AddPluginInitStep([]() {
|
||||
AddPluginInitStep([] {
|
||||
AddSetupTabCallback("actionQueueTab", ActionQueueTable::Create,
|
||||
setupTab);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool setupDone = setup();
|
||||
|
||||
static void setTabVisible(QTabWidget *tabWidget, bool visible)
|
||||
{
|
||||
SetTabVisibleByName(
|
||||
|
|
|
|||
|
|
@ -12,20 +12,16 @@ std::deque<std::shared_ptr<Item>> &GetActionQueues()
|
|||
return queues;
|
||||
}
|
||||
|
||||
void RegisterActionQueueTab();
|
||||
|
||||
void SetupActionQueues()
|
||||
static bool setup()
|
||||
{
|
||||
static bool done = false;
|
||||
if (done) {
|
||||
return;
|
||||
}
|
||||
AddSaveStep(SaveActionQueues);
|
||||
AddLoadStep(LoadActionQueues);
|
||||
RegisterActionQueueTab();
|
||||
done = true;
|
||||
AddPluginCleanupStep([]() { queues.clear(); });
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool setupDone = setup();
|
||||
|
||||
ActionQueue::ActionQueue() : Item()
|
||||
{
|
||||
_lastEmpty = std::chrono::high_resolution_clock::now();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ signals:
|
|||
};
|
||||
|
||||
std::deque<std::shared_ptr<Item>> &GetActionQueues();
|
||||
void SetupActionQueues();
|
||||
void SaveActionQueues(obs_data_t *);
|
||||
void LoadActionQueues(obs_data_t *);
|
||||
void ImportQueues(obs_data_t *);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "variable.hpp"
|
||||
#include "math-helpers.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
#include "ui-helpers.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
|
|
@ -17,6 +18,15 @@ static std::deque<std::shared_ptr<Item>> variables;
|
|||
static std::mutex lastVariableChangeMutex;
|
||||
static std::chrono::high_resolution_clock::time_point lastVariableChange{};
|
||||
|
||||
static bool setup()
|
||||
{
|
||||
AddSaveStep(SaveVariables);
|
||||
AddLoadStep(LoadVariables);
|
||||
AddPluginCleanupStep([]() { variables.clear(); });
|
||||
return true;
|
||||
}
|
||||
static bool setupDone = setup();
|
||||
|
||||
static void setLastVariableChangeTime()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(lastVariableChangeMutex);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user