From 571ecf096433ac0e19e1c48feea20d7f34dce1ef Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 25 Mar 2014 00:45:31 -0700 Subject: [PATCH] add first cut at firstrun support --- interface/src/Application.cpp | 24 ++++++++++++++++++++---- interface/src/Application.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8bcfb5151b..437f050c88 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -251,7 +251,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection); _settings = new QSettings(this); - + // Check to see if the user passed in a command line option for loading a local // Voxel File. _voxelsFilename = getCmdOption(argc, constArgv, "-i"); @@ -330,9 +330,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); - - // do this as late as possible so that all required subsystems are inialized - loadScripts(); + + // check first run... + QVariant firstRunValue = _settings->value("firstRun",QVariant(true)); + if (firstRunValue.isValid() && firstRunValue.toBool()) { + qDebug() << "This is a first run..."; + // clear the scripts, and set out script to our default scripts + clearScriptsBeforeRunning(); + loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); + } else { + // do this as late as possible so that all required subsystems are inialized + loadScripts(); + } } Application::~Application() { @@ -3454,6 +3463,13 @@ void Application::loadScripts() { settings->endArray(); } +void Application::clearScriptsBeforeRunning() { + // clears all scripts from the settings + QSettings* settings = new QSettings(this); + settings->beginWriteArray("Settings"); + settings->endArray(); +} + void Application::saveScripts() { // saves all current running scripts QSettings* settings = new QSettings(this); diff --git a/interface/src/Application.h b/interface/src/Application.h index ccd07d41b6..15778f2a17 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -115,6 +115,7 @@ public: void loadScript(const QString& fileNameString); void loadScripts(); void storeSizeAndPosition(); + void clearScriptsBeforeRunning(); void saveScripts(); void initializeGL(); void paintGL();