Handle example/demo patches as templates

Closes #270

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-06-30 19:42:01 +01:00
parent 0de51ecba8
commit a37016969d
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
3 changed files with 10 additions and 4 deletions

View file

@ -151,11 +151,17 @@ void loadDialog()
#endif #endif
} }
void loadPathDialog(const std::string& path) void loadPathDialog(const std::string& path, const bool asTemplate)
{ {
#ifndef HEADLESS #ifndef HEADLESS
promptClear("The current patch is unsaved. Clear it and open the new patch?", [path]() { promptClear("The current patch is unsaved. Clear it and open the new patch?", [path, asTemplate]() {
APP->patch->loadAction(path); APP->patch->loadAction(path);
if (asTemplate)
{
APP->patch->path = "";
APP->history->setSaved();
}
}); });
#endif #endif
} }

View file

@ -58,7 +58,7 @@ std::string getSpecialPath(SpecialPath type);
namespace patchUtils { namespace patchUtils {
void loadDialog(); void loadDialog();
void loadPathDialog(const std::string& path); void loadPathDialog(const std::string& path, bool asTemplate = false);
void loadSelectionDialog(); void loadSelectionDialog();
void loadTemplateDialog(); void loadTemplateDialog();
void revertDialog(); void revertDialog();

View file

@ -176,7 +176,7 @@ struct FileButton : MenuButton {
} }
menu->addChild(createMenuItem(label, "", [path]() { menu->addChild(createMenuItem(label, "", [path]() {
patchUtils::loadPathDialog(path); patchUtils::loadPathDialog(path, true);
})); }));
} }
})); }));