You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 1.7KB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "engine.hpp"
  2. #include "gui.hpp"
  3. #include "app.hpp"
  4. #include "plugin.hpp"
  5. #include "settings.hpp"
  6. #include "asset.hpp"
  7. #include <unistd.h>
  8. #include "../ext/osdialog/osdialog.h"
  9. using namespace rack;
  10. int main(int argc, char* argv[]) {
  11. randomInit();
  12. #ifdef RELEASE
  13. std::string logFilename = assetLocal("log.txt");
  14. gLogFile = fopen(logFilename.c_str(), "w");
  15. #endif
  16. info("Rack v%s", gApplicationVersion.c_str());
  17. {
  18. char *cwd = getcwd(NULL, 0);
  19. info("Current working directory: %s", cwd);
  20. free(cwd);
  21. std::string globalDir = assetGlobal("");
  22. std::string localDir = assetLocal("");
  23. info("Global directory: %s", globalDir.c_str());
  24. info("Local directory: %s", localDir.c_str());
  25. }
  26. pluginInit();
  27. engineInit();
  28. guiInit();
  29. sceneInit();
  30. settingsLoad(assetLocal("settings.json"));
  31. // 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.
  32. bool oldSkipAutosaveOnLaunch = skipAutosaveOnLaunch;
  33. skipAutosaveOnLaunch = true;
  34. settingsSave(assetLocal("settings.json"));
  35. skipAutosaveOnLaunch = false;
  36. if (oldSkipAutosaveOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, likely caused by a faulty module in your patch. Would you like to clear your patch and start over?")) {
  37. // Do nothing. Empty patch is already loaded.
  38. }
  39. else {
  40. gRackWidget->loadPatch(assetLocal("autosave.vcv"));
  41. }
  42. engineStart();
  43. guiRun();
  44. engineStop();
  45. gRackWidget->savePatch(assetLocal("autosave.vcv"));
  46. settingsSave(assetLocal("settings.json"));
  47. sceneDestroy();
  48. guiDestroy();
  49. engineDestroy();
  50. pluginDestroy();
  51. #ifdef RELEASE
  52. fclose(gLogFile);
  53. #endif
  54. return 0;
  55. }