}
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);
/// \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"
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, ...)
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)
{
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);
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;
}
}
+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)
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
{
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();
}
};
if(!globalCharacterSet().isUTF8())
{
BufferedTextOutputStream<GtkTextBufferOutputStream> buffered(textBuffer);
- buffered << ConvertLocaleToUTF8(StringRange(buf, buf + length));
+ buffered << StringRange(buf, buf + length);
}
else
{
}
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;
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"));
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;
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;
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;
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;
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);
}
{
// 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
{
// 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)
{
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());
}
void Sys_SetTitle(const char *text, bool modified)
{
StringOutputStream title;
- title << ConvertLocaleToUTF8(text);
+ title << text;
if(modified)
{
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)