]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
add command line options:
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Wed, 4 Mar 2009 08:12:04 +0000 (08:12 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Wed, 4 Mar 2009 08:12:04 +0000 (08:12 +0000)
-global-Key Value
-gamename.game-Key Value

and use it in netradiant.sh on OS X to detect whether NetRadiant.app is located
in a subdir of a Nexuiz install. If it is, automatically select this game dir.

git-svn-id: svn://svn.icculus.org/netradiant/trunk@202 61c419a2-8eb2-4b30-bcec-8cead039b335

games/NexuizPack/games/nexuiz.game
radiant/environment.h
radiant/preferencedictionary.h
radiant/preferences.cpp
setup/data/osx/NetRadiant.app/Contents/MacOS/netradiant.sh

index 8190d51093db66464f609ce37ba5617bd842db14..4e1bc61055b8cd388543d3042197db44b504ed1b 100644 (file)
@@ -6,7 +6,7 @@
   name="Nexuiz"
   enginepath_win32="C:/Program Files/Nexuiz/"
   enginepath_linux="/usr/share/games/nexuiz/"
-  enginepath_macos="../../../../.."
+  enginepath_macos="/Applications/Nexuiz"
   engine_win32="nexuiz-sdl.exe"
   engine_linux="nexuiz-sdl"
   engine_macos="Nexuiz.app"
index 7667fbfe5bf484fda857fbf236f87620fca0a0ac..49d595e0cc9e169369afd64a280c66c6036c788f 100644 (file)
@@ -26,4 +26,7 @@ void environment_init(int argc, char* argv[]);
 const char* environment_get_home_path();
 const char* environment_get_app_path();
 
+extern int g_argc;
+extern char** g_argv;
+
 #endif
index 35a281ad42fc8a7a386a613ad94b1c2b0527928a..45757d01b4db390750fba955c13186d15a1a0887 100644 (file)
@@ -92,6 +92,7 @@ public:
     }
     else
     {
+      m_cache.erase(name);
       m_cache.insert(PreferenceCache::value_type(name, value));
     }
   }
index 3d167025191cf816adb71dd77a99e775f8f77969..5302c375fc9c79fac9714956a660848cc6d872ab 100644 (file)
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
 #include "preferences.h"
+#include "environment.h"
 
 #include "debugging/debugging.h"
 
@@ -187,17 +188,31 @@ CGameDescription *g_pGameDescription; ///< shortcut to g_GamesDialog.m_pCurrentD
 
 const char* const PREFERENCES_VERSION = "1.0";
 
-bool Preferences_Load(PreferenceDictionary& preferences, const char* filename)
+bool Preferences_Load(PreferenceDictionary& preferences, const char* filename, const char *cmdline_prefix)
 {
+  bool ret = false;
   TextFileInputStream file(filename);
   if(!file.failed())
   {
     XMLStreamParser parser(file);
     XMLPreferenceDictionaryImporter importer(preferences, PREFERENCES_VERSION);
     parser.exportXML(importer);
-    return true;
+    ret = true;
   }
-  return false;
+
+  int l = strlen(cmdline_prefix);
+  for(int i = 1; i < g_argc - 1; ++i)
+  {
+    if(g_argv[i][0] == '-')
+    {
+      if(!strncmp(g_argv[i]+1, cmdline_prefix, l))
+        if(g_argv[i][l+1] == '-')
+         preferences.importPref(g_argv[i]+l+2, g_argv[i+1]);
+      ++i;
+    }
+  } 
+
+  return ret;
 }
 
 bool Preferences_Save(PreferenceDictionary& preferences, const char* filename)
@@ -259,7 +274,7 @@ void CGameDialog::LoadPrefs()
 
   globalOutputStream() << "loading global preferences from " << makeQuoted(strGlobalPref.c_str()) << "\n";
 
-  if(!Preferences_Load(g_global_preferences, strGlobalPref.c_str()))
+  if(!Preferences_Load(g_global_preferences, strGlobalPref.c_str(), "global"))
   {
     globalOutputStream() << "failed to load global preferences from " << strGlobalPref.c_str() << "\n";
   }
@@ -948,7 +963,7 @@ void Preferences_Load()
 
   globalOutputStream() << "loading local preferences from " << g_Preferences.m_inipath->str << "\n";
 
-  if(!Preferences_Load(g_preferences, g_Preferences.m_inipath->str))
+  if(!Preferences_Load(g_preferences, g_Preferences.m_inipath->str, g_GamesDialog.m_sGameFile.c_str()))
   {
     globalOutputStream() << "failed to load local preferences from " << g_Preferences.m_inipath->str << "\n";
   }
index 389ac04a21ca0392bca4e00d9686f9025b628f51..cb07b08d15cdb499496d9bf0d84b376101ae6229 100755 (executable)
@@ -7,8 +7,33 @@ MY_DIRECTORY="${MY_DIRECTORY%/*}" # cut off Contents
 #export DYLD_LIBRARY_PATH="$MY_DIRECTORY/Contents/MacOS"
 
 cd "$MY_DIRECTORY/Contents/MacOS/install"
+
+# autodetect nexuiz installs
+NEX_DIRECTORY="/${MY_DIRECTORY%/*}"
+while :; do
+       if [ -z "$NEX_DIRECTORY" ]; then
+               break
+       fi
+       if [ -f "$NEX_DIRECTORY/data/common-spog.pk3" ]; then
+               if [ -d "$NEX_DIRECTORY/Nexuiz.app" ]; then
+                       break
+               fi
+       fi
+       NEX_DIRECTORY=${NEX_DIRECTORY%/*}
+done
+case "$NEX_DIRECTORY" in
+       //*)
+               NEX_DIRECTORY=${NEX_DIRECTORY#/}
+               set -- -global-gamefile nexuiz.game -nexuiz.game-EnginePath "$NEX_DIRECTORY/"
+               # -global-gamePrompt false?
+               ;;
+       *)
+               set --
+               ;;
+esac
+
 if [ -x /usr/bin/open-x11 ]; then
-       exec /usr/bin/open-x11 ./radiant.ppc
+       exec /usr/bin/open-x11 ./radiant.ppc "$@"
 else
-       exec ./radiant.ppc
+       exec ./radiant.ppc "$@"
 fi