]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/preferences.cpp
q3map2 -scale: new arg -spawn_ref - sets reference point in spawnpoints
[xonotic/netradiant.git] / radiant / preferences.cpp
index 3869361159136b1095677f4ef8b88c55c8f04617..a691d812770cdd93c22fc26b8c7d2983a1b77f27 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";
   }
@@ -446,7 +461,21 @@ void CGameDialog::Init()
   ScanForGames();
   if (mGames.empty())
   {
-    Error("Didn't find any valid game file descriptions, aborting\n");
+         Error("Didn't find any valid game file descriptions, aborting\n");
+  }
+  else
+  {
+         std::list<CGameDescription *>::iterator iGame, iPrevGame;
+         for(iGame=mGames.begin(), iPrevGame = mGames.end(); iGame!=mGames.end(); iPrevGame = iGame, ++iGame)
+         {
+                 if(iPrevGame != mGames.end())
+                         if(strcmp((*iGame)->getRequiredKeyValue("name"), (*iPrevGame)->getRequiredKeyValue("name")) < 0)
+                         {
+                                 CGameDescription *h = *iGame;
+                                 *iGame = *iPrevGame;
+                                 *iPrevGame = h;
+                         }
+         }
   }
  
   CGameDescription* currentGameDescription = 0;
@@ -751,7 +780,7 @@ GtkWindow* PrefsDlg::BuildDialog()
   PreferencesDialog_addInterfacePreferences(FreeCaller1<PreferencesPage&, Interface_constructPreferences>());
   Mouse_registerPreferencesPage();
 
-  GtkWindow* dialog = create_floating_window("GtkRadiant Preferences", m_parent);
+  GtkWindow* dialog = create_floating_window("NetRadiant Preferences", m_parent);
 
   {
     GtkWidget* mainvbox = gtk_vbox_new(FALSE, 5);
@@ -806,7 +835,7 @@ GtkWindow* PrefsDlg::BuildDialog()
 
           {
             GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
-            GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Preferences", renderer, "text", 0, 0);
+            GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Preferences", renderer, "text", 0, NULL);
             gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
           }
 
@@ -948,7 +977,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";
   }