]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
"Portable" Radiant support: when a subdirectory "settings" of the directory with...
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Thu, 2 Apr 2009 17:07:17 +0000 (17:07 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Thu, 2 Apr 2009 17:07:17 +0000 (17:07 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@242 61c419a2-8eb2-4b30-bcec-8cead039b335

radiant/environment.cpp

index 16aba7f7098089e52ee18c0d64928fae96d7523a..58a405dd3485f12a27d26af3d51af217f0bd1a50 100644 (file)
@@ -163,6 +163,17 @@ const char* environment_get_app_path()
   return app_path.c_str();
 }
 
+bool portable_app_setup()
+{
+       StringOutputStream confdir(256);
+       confdir << app_path.c_str() << "settings/";
+       if(file_exists(confdir.c_str()))
+       {
+               home_path = confdir.c_str();
+               return true;
+       }
+       return false;
+}
 
 #if defined(POSIX)
 
@@ -226,17 +237,19 @@ void environment_init(int argc, char* argv[])
 
   args_init(argc, argv);
 
+  {
+    char real[PATH_MAX];
+    app_path = getexename(real);
+    ASSERT_MESSAGE(!string_empty(app_path.c_str()), "failed to deduce app path");
+  }
+
+  if(!portable_app_setup())
   {
     StringOutputStream home(256);
     home << DirectoryCleaned(g_get_home_dir()) << ".netradiant/";
     Q_mkdir(home.c_str());
     home_path = home.c_str();
   }
-  {
-    char real[PATH_MAX];
-    app_path = getexename(real);
-    ASSERT_MESSAGE(!string_empty(app_path.c_str()), "failed to deduce app path");
-  }
   gamedetect();
 }
 
@@ -248,24 +261,6 @@ void environment_init(int argc, char* argv[])
 {
   args_init(argc, argv);
 
-  {
-    char *appdata = getenv("APPDATA");
-
-    StringOutputStream home(256);
-    if(!appdata || string_empty(appdata))
-    {
-      ERROR_MESSAGE("Application Data folder not available.\n"
-        "Radiant will use C:\\ for user preferences.\n");
-      home << "C:";
-    }
-    else
-    {
-      home << PathCleaned(appdata);
-    }
-    home << "/NetRadiantSettings/";
-    Q_mkdir(home.c_str());
-    home_path = home.c_str();
-  }
   {
     // get path to the editor
     char filename[MAX_PATH+1];
@@ -283,6 +278,25 @@ void environment_init(int argc, char* argv[])
     app << PathCleaned(filename);
     app_path = app.c_str();
   }
+
+  if(!portable_app_setup())
+  {
+    char *appdata = getenv("APPDATA");
+    StringOutputStream home(256);
+    if(!appdata || string_empty(appdata))
+    {
+      ERROR_MESSAGE("Application Data folder not available.\n"
+        "Radiant will use C:\\ for user preferences.\n");
+      home << "C:";
+    }
+    else
+    {
+      home << PathCleaned(appdata);
+    }
+    home << "/NetRadiantSettings/";
+    Q_mkdir(home.c_str());
+    home_path = home.c_str();
+  }
   gamedetect();
 }