]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge remote branch 'icculus/master'
authorRudolf Polzer <divverent@alientrap.org>
Fri, 4 Jun 2010 18:58:08 +0000 (20:58 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 4 Jun 2010 18:58:08 +0000 (20:58 +0200)
14 files changed:
contrib/prtview/LoadPortalFileDialog.cpp
include/ifilesystem.h
libs/xml/xmlparser.h
libs/xml/xmlwriter.h
plugins/entity/entity.cpp
plugins/shaders/shaders.cpp
plugins/vfspk3/vfs.cpp
radiant/console.cpp
radiant/dialog.cpp
radiant/entity.cpp
radiant/entityinspector.cpp
radiant/mru.cpp
radiant/qe3.cpp
radiant/watchbsp.cpp

index d9984a0b8a7b66f935feedc5f67247a643855f95..03d8439777e08e01c6282f91a5af79900d3a9f10 100644 (file)
@@ -176,7 +176,7 @@ int DoLoadPortalFileDialog ()
   }
 
   StringOutputStream value(256);
-  value << ConvertLocaleToUTF8(portals.fn);
+  value << portals.fn;
   gtk_entry_set_text (GTK_ENTRY (entry), value.c_str());
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check2d), portals.show_2d);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check3d), portals.show_3d);
index 339c82f1aad65258f22e90f30b226625c0b5ad9a..ed9e99fd3dc517e084df0de39b7e6c6b979b9f4d 100644 (file)
@@ -98,8 +98,8 @@ public:
   /// \brief Detach an \p observer previously-attached by calling \c attach.
   virtual void detach(ModuleObserver& observer) = 0;
 
-  virtual Archive* getArchive(const char* archiveName) = 0;
-  virtual void forEachArchive(const ArchiveNameCallback& callback) = 0;
+  virtual Archive* getArchive(const char* archiveName, bool pakonly=true) = 0;
+  virtual void forEachArchive(const ArchiveNameCallback& callback, bool pakonly=true, bool reverse=false) = 0;
 };
 
 #include "modulesystem.h"
index 0b70c2f4224859d291ce0e3cf918ccec59c0adca..8fef04f56c720c2305e1fba24347bd5a077e6e2b 100644 (file)
@@ -138,7 +138,7 @@ class XMLSAXImporter
   static void characters(void *user_data, const xmlChar *ch, int len)
   {
     reinterpret_cast<XMLSAXImporter*>(user_data)->m_importer
-      << ConvertUTF8ToLocale(StringRange(reinterpret_cast<const char*>(ch), reinterpret_cast<const char*>(ch + len)));
+      << StringRange(reinterpret_cast<const char*>(ch), reinterpret_cast<const char*>(ch + len));
   }
 
   static void warning(void *user_data, const char *msg, ...)
index 85e49d45b34d2836cb37f5fc7f98d300a14cc407..ec5a4ade54ac2a2119ea693cb338a9683551ec1a 100644 (file)
@@ -113,7 +113,7 @@ class XMLStreamWriter : public XMLImporter, public XMLAttrVisitor
 
   void write_cdata(const char* buffer, std::size_t length)
   {
-    m_ostream << ConvertLocaleToUTF8(StringRange(buffer, buffer + length));
+    m_ostream << StringRange(buffer, buffer + length);
   }
   void write_string(const char* string)
   {
index 16dd77494aa99ef5f9346830e0c5c8fe33b97fff..ec02abdaa273167e140412923f6e8e9d27695ea8 100644 (file)
@@ -50,8 +50,7 @@ EGameType g_gameType;
 
 inline scene::Node& entity_for_eclass(EntityClass* eclass)
 {
-  if(classname_equal(eclass->name(), "misc_model")
-  || classname_equal(eclass->name(), "misc_gamemodel")
+  if((string_compare_nocase_n(eclass->name(), "misc_", 5) == 0 && string_equal_nocase(eclass->name() + string_length(eclass->name()) - 5, "model")) // misc_*model (also misc_model) // TODO make classname_* wrapper functions for this
   || classname_equal(eclass->name(), "model_static"))
   {
     return New_MiscModel(eclass);
index e95adaffc7ea170de87d5e63c9da5bb363503e48..202a817f6596d0497389be58db1b5dde9c6f1d70 100644 (file)
@@ -1768,9 +1768,9 @@ void IfFound_dumpUnreferencedShader(bool& bFound, const char* filename)
     if(!bFound)
     {
       bFound = true;
-      globalOutputStream() << "Following shader files are not referenced in shaderlist.txt:\n";
+      globalOutputStream() << "Following shader files are not referenced in any shaderlist.txt:\n";
     }
-    globalOutputStream() << filename << "\n";
+    globalOutputStream() << "\t" << filename << "\n";
   }
 }
 typedef ReferenceCaller1<bool, const char*, IfFound_dumpUnreferencedShader> IfFoundDumpUnreferencedShaderCaller;
@@ -1840,6 +1840,30 @@ void FreeShaderList()
   }
 }
 
+void ShaderList_addFromArchive(const char *archivename)
+{
+  const char *shaderpath = GlobalRadiant().getGameDescriptionKeyValue("shaderpath");
+  if (string_empty(shaderpath))
+    return;
+
+  StringOutputStream shaderlist(256);
+  shaderlist << DirectoryCleaned(shaderpath) << "shaderlist.txt";
+
+  Archive *archive = GlobalFileSystem().getArchive(archivename, false);
+  if (archive)
+  {
+    ArchiveTextFile *file = archive->openTextFile(shaderlist.c_str());
+    if (file)
+    {
+      globalOutputStream() << "Found shaderlist.txt in " << archivename << "\n";
+      BuildShaderList(file->getInputStream());
+      file->release();
+    }
+  }
+}
+
+typedef FreeCaller1<const char *, ShaderList_addFromArchive> AddShaderListFromArchiveCaller;
+
 #include "stream/filestream.h"
 
 bool shaderlist_findOrInstall(const char* enginePath, const char* toolsPath, const char* shaderPath, const char* gamename)
@@ -1898,22 +1922,8 @@ void Shaders_Load()
         shaderlist_findOrInstall(enginePath, toolsPath, path.c_str(), gamename);
       }
 
-      StringOutputStream absShaderList(256);
-      absShaderList << enginePath << gamename << '/' << path.c_str() << "shaderlist.txt";
-
-      {
-        globalOutputStream() << "Parsing shader files from " << absShaderList.c_str() << "\n";
-        TextFileInputStream shaderlistFile(absShaderList.c_str());
-        if(shaderlistFile.failed())
-        {
-          globalErrorStream() << "Couldn't find '" << absShaderList.c_str() << "'\n";
-        }
-        else
-        {
-          BuildShaderList(shaderlistFile);
-          DumpUnreferencedShaders();
-        }
-      }
+      GlobalFileSystem().forEachArchive(AddShaderListFromArchiveCaller(), false, true);
+      DumpUnreferencedShaders();
     }
     else
     {
index 6220f773982757ca5262498c7bb3ce3986cc6c91..8b52b535cefb3350000fd3296b4de5cf5c73a1e4 100644 (file)
@@ -661,29 +661,33 @@ public:
     g_observers.detach(observer);
   }
 
-  Archive* getArchive(const char* archiveName)
+  Archive* getArchive(const char* archiveName, bool pakonly)
   {
     for(archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i)
     {
-      if((*i).is_pakfile)
-      {
-        if(path_equal((*i).name.c_str(), archiveName))
-        {
-          return (*i).archive;
-        }
-      }
+      if(pakonly && !(*i).is_pakfile)
+        continue;
+
+      if(path_equal((*i).name.c_str(), archiveName))
+        return (*i).archive;
     }
     return 0;
   }
-  void forEachArchive(const ArchiveNameCallback& callback)
+  void forEachArchive(const ArchiveNameCallback& callback, bool pakonly, bool reverse)
   {
+    if (reverse)
+      g_archives.reverse();
+
     for(archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i)
     {
-      if((*i).is_pakfile)
-      {
-        callback((*i).name.c_str());
-      }
+      if(pakonly && !(*i).is_pakfile)
+        continue;
+
+      callback((*i).name.c_str());
     }
+
+    if (reverse)
+      g_archives.reverse();
   }
 };
 
index 94a496f696bf61e69d24466bc8be9e3739becfaf..db7997e18be53d14319a47664486f41a0fa9a650 100644 (file)
@@ -216,7 +216,7 @@ std::size_t Sys_Print(int level, const char* buf, std::size_t length)
         if(!globalCharacterSet().isUTF8())
         {
           BufferedTextOutputStream<GtkTextBufferOutputStream> buffered(textBuffer);
-          buffered << ConvertLocaleToUTF8(StringRange(buf, buf + length));
+          buffered << StringRange(buf, buf + length);
         }
         else
         {
index 3f24bf84dc15398bff311da864ead0fc130dffce..d3e4dba131d57a78c4d2c36f3ba6d6c190667c9f 100644 (file)
@@ -170,31 +170,13 @@ void IntRadioExport(GtkRadioButton& widget, const IntImportCallback& importCallb
 }
 typedef ImportExport<GtkRadioButton, int, IntRadioImport, IntRadioExport> IntRadioImportExport;
 
-template<typename Type, typename Formatter>
-class StringFromType
-{
-  StringOutputStream value;
-public:
-  StringFromType(const Type& type)
-  {
-    value << Formatter(type);
-  }
-  operator const char*() const
-  {
-    return value.c_str();
-  }
-};
-
-typedef StringFromType<const char*, ConvertLocaleToUTF8> LocaleToUTF8;
-typedef StringFromType<const char*, ConvertUTF8ToLocale> UTF8ToLocale;
-
 void TextEntryImport(GtkEntry& widget, const char* text)
 {
-  gtk_entry_set_text(&widget, LocaleToUTF8(text));
+  gtk_entry_set_text(&widget, text);
 }
 void TextEntryExport(GtkEntry& widget, const StringImportCallback& importCallback)
 {
-  importCallback(UTF8ToLocale(gtk_entry_get_text(&widget)));
+  importCallback(gtk_entry_get_text(&widget));
 }
 typedef ImportExport<GtkEntry, const char*, TextEntryImport, TextEntryExport> TextEntryImportExport;
 
index a572539e65bde0cfd9ba8e557bdda038335792f6..055de6362f10b58b6204326a3f25cc6a08f7df30 100644 (file)
@@ -328,8 +328,7 @@ void Entity_createFromSelection(const char* name, const Vector3& origin)
 
   EntityClass* entityClass = GlobalEntityClassManager().findOrInsert(name, true);
 
-  bool isModel = string_equal_nocase(name, "misc_model")
-    || string_equal_nocase(name, "misc_gamemodel")
+  bool isModel = (string_compare_nocase_n(name, "misc_", 5) == 0 && string_equal_nocase(name + string_length(name) - 5, "model")) // misc_*model (also misc_model)
     || string_equal_nocase(name, "model_static")
     || (GlobalSelectionSystem().countSelected() == 0 && string_equal_nocase(name, "func_static"));
 
index e2f3c194938ef89dc676eda77e3cbff77761dbfa..ab9cabd7073c03281a3588a7ee0f5b7d661ed2d6 100644 (file)
@@ -216,7 +216,7 @@ public:
   void apply()
   {
     StringOutputStream value(64);
-    value << ConvertUTF8ToLocale(gtk_entry_get_text(m_entry));
+    value << gtk_entry_get_text(m_entry);
     Scene_EntitySetKeyValue_Selected_Undoable(m_key.c_str(), value.c_str());
   }
   typedef MemberCaller<StringAttribute, &StringAttribute::apply> ApplyCaller;
@@ -224,7 +224,7 @@ public:
   void update()
   {
     StringOutputStream value(64);
-    value << ConvertLocaleToUTF8(SelectedEntity_getValueForKey(m_key.c_str()));
+    value << SelectedEntity_getValueForKey(m_key.c_str());
     gtk_entry_set_text(m_entry, value.c_str());
   }
   typedef MemberCaller<StringAttribute, &StringAttribute::update> UpdateCaller;
@@ -264,14 +264,14 @@ public:
   void apply()
   {
     StringOutputStream value(64);
-    value << ConvertUTF8ToLocale(gtk_entry_get_text(GTK_ENTRY(m_entry.m_entry.m_entry)));
+    value << gtk_entry_get_text(GTK_ENTRY(m_entry.m_entry.m_entry));
     Scene_EntitySetKeyValue_Selected_Undoable(m_key.c_str(), value.c_str());
   }
   typedef MemberCaller<ModelAttribute, &ModelAttribute::apply> ApplyCaller;
   void update()
   {
     StringOutputStream value(64);
-    value << ConvertLocaleToUTF8(SelectedEntity_getValueForKey(m_key.c_str()));
+    value << SelectedEntity_getValueForKey(m_key.c_str());
     gtk_entry_set_text(GTK_ENTRY(m_entry.m_entry.m_entry), value.c_str());
   }
   typedef MemberCaller<ModelAttribute, &ModelAttribute::update> UpdateCaller;
@@ -338,14 +338,14 @@ public:
   void apply()
   {
     StringOutputStream value(64);
-    value << ConvertUTF8ToLocale(gtk_entry_get_text(GTK_ENTRY(m_entry.m_entry.m_entry)));
+    value << gtk_entry_get_text(GTK_ENTRY(m_entry.m_entry.m_entry));
     Scene_EntitySetKeyValue_Selected_Undoable(m_key.c_str(), value.c_str());
   }
   typedef MemberCaller<SoundAttribute, &SoundAttribute::apply> ApplyCaller;
   void update()
   {
     StringOutputStream value(64);
-    value << ConvertLocaleToUTF8(SelectedEntity_getValueForKey(m_key.c_str()));
+    value << SelectedEntity_getValueForKey(m_key.c_str());
     gtk_entry_set_text(GTK_ENTRY(m_entry.m_entry.m_entry), value.c_str());
   }
   typedef MemberCaller<SoundAttribute, &SoundAttribute::update> UpdateCaller;
@@ -1170,9 +1170,9 @@ void EntityInspector_updateKeyValues()
     GtkTreeIter iter;
     gtk_list_store_append(store, &iter);
     StringOutputStream key(64);
-    key << ConvertLocaleToUTF8((*i).first.c_str());
+    key << (*i).first.c_str();
     StringOutputStream value(64);
-    value << ConvertLocaleToUTF8((*i).second.c_str());
+    value << (*i).second.c_str();
     gtk_list_store_set(store, &iter, 0, key.c_str(), 1, value.c_str(), -1);
   }
 
@@ -1243,9 +1243,9 @@ void EntityInspector_applyKeyValue()
 {
   // Get current selection text
   StringOutputStream key(64);
-  key << ConvertUTF8ToLocale(gtk_entry_get_text(g_entityKeyEntry));
+  key << gtk_entry_get_text(g_entityKeyEntry);
   StringOutputStream value(64);
-  value << ConvertUTF8ToLocale(gtk_entry_get_text(g_entityValueEntry));
+  value << gtk_entry_get_text(g_entityValueEntry);
 
 
   // TTimo: if you change the classname to worldspawn you won't merge back in the structural brushes but create a parasite entity
@@ -1280,7 +1280,7 @@ void EntityInspector_clearKeyValue()
 {
   // Get current selection text
   StringOutputStream key(64);
-  key << ConvertUTF8ToLocale(gtk_entry_get_text(g_entityKeyEntry));
+  key << gtk_entry_get_text(g_entityKeyEntry);
 
   if(strcmp(key.c_str(), "classname") != 0)
   {
index 7f3fbeebf4ced43eba311b44f683e541e70254d6..2dd0da72090c65cfdfb6a08741576baacaaa77ca 100644 (file)
@@ -90,7 +90,7 @@ inline EscapedMnemonic& operator<<(EscapedMnemonic& ostream, const T& t)
 void MRU_updateWidget(std::size_t index, const char *filename)
 {
   EscapedMnemonic mnemonic(64);
-  mnemonic << Unsigned(index + 1) << "- " << ConvertLocaleToUTF8(filename);
+  mnemonic << Unsigned(index + 1) << "- " << filename;
   gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(MRU_items[index]))), mnemonic.c_str());
 }
 
index 451489b531c83b765d21e661c3bf4f54244fec00..0291d2cfb9b2a12014a13cf4f9696ff66c4de4c2 100644 (file)
@@ -346,7 +346,7 @@ void RunBSP(const char* name)
 void Sys_SetTitle(const char *text, bool modified)
 {
   StringOutputStream title;
-  title << ConvertLocaleToUTF8(text);
+  title << text;
 
   if(modified)
   {
index e2cc86c37d176e4cf70b81007230a29031ee652d..83fba9009a45258516115baf151f3d1b4cf0f57a 100644 (file)
@@ -431,7 +431,7 @@ inline MessageOutputStream& operator<<(MessageOutputStream& ostream, const T& t)
 static void saxCharacters(message_info_t *data, const xmlChar *ch, int len)
 {
   MessageOutputStream ostream(data);
-  ostream << ConvertUTF8ToLocale(StringRange(reinterpret_cast<const char*>(ch), reinterpret_cast<const char*>(ch + len)));
+  ostream << StringRange(reinterpret_cast<const char*>(ch), reinterpret_cast<const char*>(ch + len));
 }
 
 static void saxComment(void *ctx, const xmlChar *msg)