Show warning if default action or condition cannot be created

This commit is contained in:
WarmUpTill 2024-08-02 20:19:30 +02:00 committed by WarmUpTill
parent 9941cfe9b5
commit c431e6c31d
6 changed files with 33 additions and 0 deletions

View File

@ -37,6 +37,7 @@ AdvSceneSwitcher.generalTab.generalBehavior.disableUIHints="Disable UI hints"
AdvSceneSwitcher.generalTab.generalBehavior.comboBoxFilterDisable="Disable filtering by typing in drop down menus"
AdvSceneSwitcher.generalTab.generalBehavior.warnPluginLoadFailure="Display warning if plugins cannot be loaded"
AdvSceneSwitcher.generalTab.generalBehavior.warnPluginLoadFailureMessage="<html><body>Loading of the following plugin libraries was unsuccessful, which could result in some Advanced Scene Switcher functions not being available:%1Check the OBS logs for details.<br>This message can be disabled on the General tab.</body></html>"
AdvSceneSwitcher.generalTab.generalBehavior.warnCorruptedInstallMessage="The plugin installation seems to be corrupted and might crash!\nPlease make sure the plugin was installed correctly!"
AdvSceneSwitcher.generalTab.generalBehavior.hideLegacyTabs="Hide tabs which can be represented via macros"
AdvSceneSwitcher.generalTab.matchBehavior="Match behavior"
AdvSceneSwitcher.generalTab.priority="Priority"

View File

@ -93,10 +93,24 @@ static void DisplayMissingDataDirWarning()
DisplayMessage(msg);
}
bool CanCreateDefaultAction();
bool CanCreateDefaultCondition();
static void DisplayCorruptedInstallWarning()
{
if (CanCreateDefaultAction() && CanCreateDefaultCondition()) {
return;
}
DisplayMessage(obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.warnCorruptedInstallMessage"));
}
void AdvSceneSwitcher::LoadUI()
{
DisplayMissingDataDirWarning();
DisplayMissingDependencyWarning();
DisplayCorruptedInstallWarning();
SetupGeneralTab();
SetupTitleTab();

View File

@ -54,4 +54,11 @@ std::string MacroActionFactory::GetIdByName(const QString &name)
return "";
}
bool CanCreateDefaultAction()
{
const auto action = MacroActionFactory::Create(
MacroAction::GetDefaultID().data(), nullptr);
return !!action;
}
} // namespace advss

View File

@ -31,4 +31,6 @@ private:
static std::map<std::string, MacroActionInfo> &GetMap();
};
bool CanCreateDefaultAction();
} // namespace advss

View File

@ -63,4 +63,11 @@ bool MacroConditionFactory::UsesDurationModifier(const std::string &id)
return false;
}
bool CanCreateDefaultCondition()
{
const auto condition = MacroConditionFactory::Create(
MacroCondition::GetDefaultID().data(), nullptr);
return !!condition;
}
} // namespace advss

View File

@ -32,4 +32,6 @@ private:
static std::map<std::string, MacroConditionInfo> &GetMap();
};
bool CanCreateDefaultCondition();
} // namespace advss