mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-22 10:07:29 -05:00
Also ex-/import variables when ex-/importing macros
Manually creating necessary variables and reconfiguring the macros to use them can be unintuitive so instead just create the missing variables included in the export.
This commit is contained in:
parent
e50522ab89
commit
25ce8cd2e4
|
|
@ -244,6 +244,7 @@ void AdvSceneSwitcher::ExportMacros()
|
|||
obs_data_release(obj);
|
||||
}
|
||||
obs_data_set_array(data, "macros", macroArray);
|
||||
switcher->SaveVariables(data);
|
||||
obs_data_array_release(macroArray);
|
||||
obs_data_set_string(data, "version", g_GIT_TAG);
|
||||
auto json = obs_data_get_json(data);
|
||||
|
|
@ -367,6 +368,26 @@ bool AdvSceneSwitcher::ResolveMacroImportNameConflict(
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool variableWithNameExists(const std::string &name)
|
||||
{
|
||||
return !!GetVariableByName(name);
|
||||
}
|
||||
|
||||
static void importVariables(obs_data_t *obj)
|
||||
{
|
||||
OBSDataArrayAutoRelease array = obs_data_get_array(obj, "variables");
|
||||
size_t count = obs_data_array_count(array);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
OBSDataAutoRelease data = obs_data_array_item(array, i);
|
||||
auto var = Variable::Create();
|
||||
var->Load(data);
|
||||
if (variableWithNameExists(var->Name())) {
|
||||
continue;
|
||||
}
|
||||
switcher->variables.emplace_back(var);
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::ImportMacros()
|
||||
{
|
||||
QString json;
|
||||
|
|
@ -380,6 +401,7 @@ void AdvSceneSwitcher::ImportMacros()
|
|||
ImportMacros();
|
||||
return;
|
||||
}
|
||||
importVariables(data);
|
||||
|
||||
auto version = obs_data_get_string(data, "version");
|
||||
if (strcmp(version, g_GIT_TAG) != 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user