@@ -19,6 +19,8 @@ struct Context { | |||||
Scene *scene = NULL; | Scene *scene = NULL; | ||||
Engine *engine = NULL; | Engine *engine = NULL; | ||||
Window *window = NULL; | Window *window = NULL; | ||||
bool skipLoadOnLaunch = false; | |||||
}; | }; | ||||
@@ -141,7 +141,6 @@ TMenuItem *createMenuItem(std::string text, std::string rightText = "") { | |||||
return o; | return o; | ||||
} | } | ||||
// TODO Reevaluate this. Does it belong here? | |||||
inline Menu *createMenu() { | inline Menu *createMenu() { | ||||
Menu *o = new Menu; | Menu *o = new Menu; | ||||
o->box.pos = context()->window->mousePos; | o->box.pos = context()->window->mousePos; | ||||
@@ -6,8 +6,6 @@ namespace rack { | |||||
namespace settings { | namespace settings { | ||||
extern bool gSkipAutosaveOnLaunch; | |||||
void save(std::string filename); | void save(std::string filename); | ||||
void load(std::string filename); | void load(std::string filename); | ||||
@@ -1,15 +1,16 @@ | |||||
#pragma once | #pragma once | ||||
#include "ui/common.hpp" | #include "ui/common.hpp" | ||||
#include "color.hpp" | #include "color.hpp" | ||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace ui { | |||||
void uiInit(); | |||||
void uiDestroy(); | |||||
void uiSetTheme(NVGcolor bg, NVGcolor fg); | |||||
void init(); | |||||
void destroy(); | |||||
void setTheme(NVGcolor bg, NVGcolor fg); | |||||
} // namespace ui | |||||
} // namespace rack | } // namespace rack |
@@ -3,7 +3,6 @@ | |||||
#include "window.hpp" | #include "window.hpp" | ||||
#include "event.hpp" | #include "event.hpp" | ||||
#include "context.hpp" | #include "context.hpp" | ||||
#include "ui.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -6,7 +6,6 @@ | |||||
#include "app/Scene.hpp" | #include "app/Scene.hpp" | ||||
#include "helpers.hpp" | #include "helpers.hpp" | ||||
#include "context.hpp" | #include "context.hpp" | ||||
#include "ui.hpp" | |||||
#include "osdialog.h" | #include "osdialog.h" | ||||
@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) { | |||||
bridgeInit(); | bridgeInit(); | ||||
keyboard::init(); | keyboard::init(); | ||||
gamepad::init(); | gamepad::init(); | ||||
uiInit(); | |||||
ui::init(); | |||||
plugin::init(devMode); | plugin::init(devMode); | ||||
// Log environment | // Log environment | ||||
@@ -90,11 +90,11 @@ int main(int argc, char *argv[]) { | |||||
if (patchFile.empty()) { | if (patchFile.empty()) { | ||||
// To prevent launch crashes, if Rack crashes between now and 15 seconds from now, the "skipAutosaveOnLaunch" property will remain in settings.json, so that in the next launch, the broken autosave will not be loaded. | // To prevent launch crashes, if Rack crashes between now and 15 seconds from now, the "skipAutosaveOnLaunch" property will remain in settings.json, so that in the next launch, the broken autosave will not be loaded. | ||||
bool oldSkipAutosaveOnLaunch = settings::gSkipAutosaveOnLaunch; | |||||
settings::gSkipAutosaveOnLaunch = true; | |||||
bool oldSkipLoadOnLaunch = context()->skipLoadOnLaunch; | |||||
context()->skipLoadOnLaunch = true; | |||||
settings::save(asset::user("settings.json")); | settings::save(asset::user("settings.json")); | ||||
settings::gSkipAutosaveOnLaunch = false; | |||||
if (oldSkipAutosaveOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, possibly caused by a faulty module in your patch. Clear your patch and start over?")) { | |||||
context()->skipLoadOnLaunch = false; | |||||
if (oldSkipLoadOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, possibly caused by a faulty module in your patch. Clear your patch and start over?")) { | |||||
context()->scene->rackWidget->lastPath = ""; | context()->scene->rackWidget->lastPath = ""; | ||||
} | } | ||||
else { | else { | ||||
@@ -128,7 +128,7 @@ int main(int argc, char *argv[]) { | |||||
// Destroy environment | // Destroy environment | ||||
plugin::destroy(); | plugin::destroy(); | ||||
uiDestroy(); | |||||
ui::destroy(); | |||||
bridgeDestroy(); | bridgeDestroy(); | ||||
midiDestroy(); | midiDestroy(); | ||||
logger::destroy(); | logger::destroy(); | ||||
@@ -13,9 +13,6 @@ namespace rack { | |||||
namespace settings { | namespace settings { | ||||
bool gSkipAutosaveOnLaunch = false; | |||||
static json_t *settingsToJson() { | static json_t *settingsToJson() { | ||||
// root | // root | ||||
json_t *rootJ = json_object(); | json_t *rootJ = json_object(); | ||||
@@ -63,9 +60,9 @@ static json_t *settingsToJson() { | |||||
json_t *lastPathJ = json_string(context()->scene->rackWidget->lastPath.c_str()); | json_t *lastPathJ = json_string(context()->scene->rackWidget->lastPath.c_str()); | ||||
json_object_set_new(rootJ, "lastPath", lastPathJ); | json_object_set_new(rootJ, "lastPath", lastPathJ); | ||||
// skipAutosaveOnLaunch | |||||
if (gSkipAutosaveOnLaunch) { | |||||
json_object_set_new(rootJ, "skipAutosaveOnLaunch", json_true()); | |||||
// skipLoadOnLaunch | |||||
if (context()->skipLoadOnLaunch) { | |||||
json_object_set_new(rootJ, "skipLoadOnLaunch", json_true()); | |||||
} | } | ||||
// moduleBrowser | // moduleBrowser | ||||
@@ -135,10 +132,10 @@ static void settingsFromJson(json_t *rootJ) { | |||||
if (lastPathJ) | if (lastPathJ) | ||||
context()->scene->rackWidget->lastPath = json_string_value(lastPathJ); | context()->scene->rackWidget->lastPath = json_string_value(lastPathJ); | ||||
// skipAutosaveOnLaunch | |||||
json_t *skipAutosaveOnLaunchJ = json_object_get(rootJ, "skipAutosaveOnLaunch"); | |||||
if (skipAutosaveOnLaunchJ) | |||||
gSkipAutosaveOnLaunch = json_boolean_value(skipAutosaveOnLaunchJ); | |||||
// skipLoadOnLaunch | |||||
json_t *skipLoadOnLaunchJ = json_object_get(rootJ, "skipLoadOnLaunch"); | |||||
if (skipLoadOnLaunchJ) | |||||
context()->skipLoadOnLaunch = json_boolean_value(skipLoadOnLaunchJ); | |||||
// moduleBrowser | // moduleBrowser | ||||
json_t *moduleBrowserJ = json_object_get(rootJ, "moduleBrowser"); | json_t *moduleBrowserJ = json_object_get(rootJ, "moduleBrowser"); | ||||
@@ -2,16 +2,17 @@ | |||||
namespace rack { | namespace rack { | ||||
namespace ui { | |||||
void uiInit(){ | |||||
uiSetTheme(nvgRGB(0x33, 0x33, 0x33), nvgRGB(0xf0, 0xf0, 0xf0)); | |||||
void init(){ | |||||
setTheme(nvgRGB(0x33, 0x33, 0x33), nvgRGB(0xf0, 0xf0, 0xf0)); | |||||
} | } | ||||
void uiDestroy() { | |||||
void destroy() { | |||||
} | } | ||||
void uiSetTheme(NVGcolor bg, NVGcolor fg) { | |||||
void setTheme(NVGcolor bg, NVGcolor fg) { | |||||
// Assume dark background and light foreground | // Assume dark background and light foreground | ||||
BNDwidgetTheme w; | BNDwidgetTheme w; | ||||
@@ -58,7 +59,5 @@ void uiSetTheme(NVGcolor bg, NVGcolor fg) { | |||||
} | } | ||||
std::shared_ptr<Font> gGuiFont; | |||||
} // namespace ui | |||||
} // namespace rack | } // namespace rack |