@@ -28,6 +28,7 @@ struct RackWidget : OpaqueWidget { | |||||
void loadDialog(); | void loadDialog(); | ||||
void saveDialog(); | void saveDialog(); | ||||
void saveAsDialog(); | void saveAsDialog(); | ||||
void saveTemplate(); | |||||
/** If `lastPath` is defined, ask the user to reload it */ | /** If `lastPath` is defined, ask the user to reload it */ | ||||
void revert(); | void revert(); | ||||
/** Disconnects all wires */ | /** Disconnects all wires */ | ||||
@@ -145,6 +145,12 @@ void RackWidget::saveAsDialog() { | |||||
lastPath = pathStr; | lastPath = pathStr; | ||||
} | } | ||||
void RackWidget::saveTemplate() { | |||||
if (osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, "Overwrite template patch?")) { | |||||
save(asset::user("template.vcv")); | |||||
} | |||||
} | |||||
void RackWidget::save(std::string filename) { | void RackWidget::save(std::string filename) { | ||||
INFO("Saving patch %s", filename.c_str()); | INFO("Saving patch %s", filename.c_str()); | ||||
json_t *rootJ = toJson(); | json_t *rootJ = toJson(); | ||||
@@ -76,6 +76,16 @@ struct SaveAsItem : MenuItem { | |||||
}; | }; | ||||
struct SaveTemplateItem : MenuItem { | |||||
SaveTemplateItem() { | |||||
text = "Save template"; | |||||
} | |||||
void onAction(const event::Action &e) override { | |||||
context()->scene->rackWidget->saveTemplate(); | |||||
} | |||||
}; | |||||
struct RevertItem : MenuItem { | struct RevertItem : MenuItem { | ||||
RevertItem() { | RevertItem() { | ||||
text = "Revert"; | text = "Revert"; | ||||
@@ -120,6 +130,7 @@ struct FileButton : MenuButton { | |||||
menu->addChild(new OpenItem); | menu->addChild(new OpenItem); | ||||
menu->addChild(new SaveItem); | menu->addChild(new SaveItem); | ||||
menu->addChild(new SaveAsItem); | menu->addChild(new SaveAsItem); | ||||
menu->addChild(new SaveTemplateItem); | |||||
menu->addChild(new RevertItem); | menu->addChild(new RevertItem); | ||||
menu->addChild(new DisconnectCablesItem); | menu->addChild(new DisconnectCablesItem); | ||||
menu->addChild(new QuitItem); | menu->addChild(new QuitItem); | ||||
@@ -183,7 +183,7 @@ void WireWidget::draw(NVGcontext *vg) { | |||||
if (wire && wire->outputModule) { | if (wire && wire->outputModule) { | ||||
Output *output = &wire->outputModule->outputs[wire->outputId]; | Output *output = &wire->outputModule->outputs[wire->outputId]; | ||||
if (output->numChannels != 1) { | if (output->numChannels != 1) { | ||||
thickness = 8; | |||||
thickness = 9; | |||||
} | } | ||||
} | } | ||||