added support for both ent and def files at the same time

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@95 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
spog 2006-07-22 16:30:32 +00:00
parent 988b2f6fbc
commit d498eb592d
10 changed files with 67 additions and 53 deletions

View file

@ -8,6 +8,7 @@ SPoG
- Fixed title of wait-dialog when loading a model. - Fixed title of wait-dialog when loading a model.
- Fixed doom3 func_static with blank 'model' key being invisible. - Fixed doom3 func_static with blank 'model' key being invisible.
- Changed doom3 func_static model creation to replace selected models. - Changed doom3 func_static model creation to replace selected models.
- Added support for loading both .ent and .def files at the same time.
09/07/2006 09/07/2006
Shaderman Shaderman

View file

@ -63,17 +63,17 @@ struct EntityClassScanner
#include "modulesystem.h" #include "modulesystem.h"
template<typename Type> template<typename Type>
class GlobalModule; class ModuleRef;
typedef GlobalModule<EntityClassScanner> GlobalEClassModule; typedef ModuleRef<EntityClassScanner> EClassModuleRef;
template<typename Type> template<typename Type>
class GlobalModuleRef; class Modules;
typedef GlobalModuleRef<EntityClassScanner> GlobalEClassModuleRef; typedef Modules<EntityClassScanner> EClassModules;
template<typename Type>
class ModulesRef;
typedef ModulesRef<EntityClassScanner> EClassModulesRef;
inline EntityClassScanner& GlobalEClassLoader()
{
return GlobalEClassModule::getTable();
}

View file

@ -54,7 +54,7 @@ public:
class Visitor class Visitor
{ {
public: public:
virtual void visit(const char* name, Module& module) = 0; virtual void visit(const char* name, Module& module) const = 0;
}; };
virtual void setError(bool error) = 0; virtual void setError(bool error) = 0;
@ -66,7 +66,7 @@ public:
virtual void registerModule(const char* type, int version, const char* name, Module& module) = 0; virtual void registerModule(const char* type, int version, const char* name, Module& module) = 0;
virtual Module* findModule(const char* type, int version, const char* name) const = 0; virtual Module* findModule(const char* type, int version, const char* name) const = 0;
virtual void foreachModule(const char* type, int version, Visitor& visitor) = 0; virtual void foreachModule(const char* type, int version, const Visitor& visitor) = 0;
}; };
class ModuleServerHolder class ModuleServerHolder
@ -112,11 +112,11 @@ public:
class Visitor class Visitor
{ {
public: public:
virtual void visit(const char* name, const Type& table) = 0; virtual void visit(const char* name, const Type& table) const = 0;
}; };
virtual Type* findModule(const char* name) = 0; virtual Type* findModule(const char* name) = 0;
virtual void foreachModule(Visitor& visitor) = 0; virtual void foreachModule(const Visitor& visitor) = 0;
}; };
#include "debugging/debugging.h" #include "debugging/debugging.h"

View file

@ -80,7 +80,7 @@ public:
{ {
return find(name); return find(name);
} }
void foreachModule(typename Modules<Type>::Visitor& visitor) void foreachModule(const typename Modules<Type>::Visitor& visitor)
{ {
for(modules_t::iterator i = m_modules.begin(); i != m_modules.end(); ++i) for(modules_t::iterator i = m_modules.begin(); i != m_modules.end(); ++i)
{ {
@ -98,7 +98,7 @@ public:
: m_modules(modules) : m_modules(modules)
{ {
} }
void visit(const char* name, Module& module) void visit(const char* name, Module& module) const
{ {
m_modules.insert(name, module); m_modules.insert(name, module);
} }

View file

@ -50,6 +50,8 @@ namespace
ListAttributeTypes g_listTypes; ListAttributeTypes g_listTypes;
} }
EClassModules& EntityClassManager_getEClassModules();
/*! /*!
implementation of the EClass manager API implementation of the EClass manager API
*/ */
@ -144,9 +146,10 @@ public:
class EntityClassesLoadFile class EntityClassesLoadFile
{ {
const EntityClassScanner& scanner;
const char* m_directory; const char* m_directory;
public: public:
EntityClassesLoadFile(const char* directory) : m_directory(directory) EntityClassesLoadFile(const EntityClassScanner& scanner, const char* directory) : scanner(scanner), m_directory(directory)
{ {
} }
void operator()(const char* name) const void operator()(const char* name) const
@ -178,7 +181,7 @@ public:
StringOutputStream relPath(256); StringOutputStream relPath(256);
relPath << m_directory << name; relPath << m_directory << name;
GlobalEClassLoader().scanFile(g_collector, relPath.c_str()); scanner.scanFile(g_collector, relPath.c_str());
} }
}; };
@ -206,23 +209,16 @@ public:
} }
}; };
#if 0
void EntityClassQuake3_constructDirectory(const char* directory, const char* extension)
{
globalOutputStream() << "EntityClass: searching " << makeQuoted(directory) << " for *." << extension << '\n';
Directory_forEach(directory, matchFileExtension(extension, EntityClassesLoadFile(directory)));
}
#else
void EntityClassQuake3_constructDirectory(const char* directory, const char* extension, Paths& paths) void EntityClassQuake3_constructDirectory(const char* directory, const char* extension, Paths& paths)
{ {
globalOutputStream() << "EntityClass: searching " << makeQuoted(directory) << " for *." << extension << '\n'; globalOutputStream() << "EntityClass: searching " << makeQuoted(directory) << " for *." << extension << '\n';
Directory_forEach(directory, matchFileExtension(extension, PathsInsert(paths, directory))); Directory_forEach(directory, matchFileExtension(extension, PathsInsert(paths, directory)));
} }
#endif
void EntityClassQuake3_Construct() void EntityClassQuake3_Construct()
{ {
#if 1
StringOutputStream baseDirectory(256); StringOutputStream baseDirectory(256);
StringOutputStream gameDirectory(256); StringOutputStream gameDirectory(256);
const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue("basegame"); const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue("basegame");
@ -230,22 +226,32 @@ void EntityClassQuake3_Construct()
baseDirectory << GlobalRadiant().getGameToolsPath() << basegame << '/'; baseDirectory << GlobalRadiant().getGameToolsPath() << basegame << '/';
gameDirectory << GlobalRadiant().getGameToolsPath() << gamename << '/'; gameDirectory << GlobalRadiant().getGameToolsPath() << gamename << '/';
Paths paths; class LoadEntityDefinitionsVisitor : public EClassModules::Visitor
EntityClassQuake3_constructDirectory(baseDirectory.c_str(), GlobalEClassLoader().getExtension(), paths);
if(!string_equal(basegame, gamename))
{ {
EntityClassQuake3_constructDirectory(gameDirectory.c_str(), GlobalEClassLoader().getExtension(), paths); const char* baseDirectory;
const char* gameDirectory;
public:
LoadEntityDefinitionsVisitor(const char* baseDirectory, const char* gameDirectory)
: baseDirectory(baseDirectory), gameDirectory(gameDirectory)
{
}
void visit(const char* name, const EntityClassScanner& table) const
{
Paths paths;
EntityClassQuake3_constructDirectory(baseDirectory, table.getExtension(), paths);
if(!string_equal(baseDirectory, gameDirectory))
{
EntityClassQuake3_constructDirectory(gameDirectory, table.getExtension(), paths);
} }
for(Paths::iterator i = paths.begin(); i != paths.end(); ++i) for(Paths::iterator i = paths.begin(); i != paths.end(); ++i)
{ {
EntityClassesLoadFile((*i).second)((*i).first.c_str()); EntityClassesLoadFile(table, (*i).second)((*i).first.c_str());
} }
#else }
StringOutputStream directory(256); };
directory << GlobalRadiant().getGameToolsPath() << GlobalRadiant().getGameName() << '/';
EntityClassQuake3_constructDirectory(directory.c_str(), GlobalEClassLoader().getExtension()); EntityClassManager_getEClassModules().foreachModule(LoadEntityDefinitionsVisitor(baseDirectory.c_str(), gameDirectory.c_str()));
#endif
} }
EntityClass *Eclass_ForName(const char *name, bool has_brushes) EntityClass *Eclass_ForName(const char *name, bool has_brushes)
@ -338,17 +344,23 @@ void EntityClassQuake3_destroy()
eclass_bad->free(eclass_bad); eclass_bad->free(eclass_bad);
} }
#include "modulesystem/modulesmap.h"
class EntityClassQuake3Dependencies : class EntityClassQuake3Dependencies :
public GlobalRadiantModuleRef, public GlobalRadiantModuleRef,
public GlobalFileSystemModuleRef, public GlobalFileSystemModuleRef,
public GlobalShaderCacheModuleRef, public GlobalShaderCacheModuleRef
public GlobalEClassModuleRef
{ {
EClassModulesRef m_eclass_modules;
public: public:
EntityClassQuake3Dependencies() : EntityClassQuake3Dependencies() :
GlobalEClassModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclasstype")) m_eclass_modules(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclasstype"))
{ {
} }
EClassModules& getEClassModules()
{
return m_eclass_modules.get();
}
}; };
class EclassManagerAPI class EclassManagerAPI
@ -395,4 +407,8 @@ typedef SingletonModule<EclassManagerAPI, EntityClassQuake3Dependencies> EclassM
typedef Static<EclassManagerModule> StaticEclassManagerModule; typedef Static<EclassManagerModule> StaticEclassManagerModule;
StaticRegisterModule staticRegisterEclassManager(StaticEclassManagerModule::instance()); StaticRegisterModule staticRegisterEclassManager(StaticEclassManagerModule::instance());
EClassModules& EntityClassManager_getEClassModules()
{
return StaticEclassManagerModule::instance().getDependencies().getEClassModules();
}

View file

@ -47,7 +47,7 @@ Image* QERApp_LoadImage(void* environment, const char* name)
: m_name(name), m_image(image) : m_name(name), m_image(image)
{ {
} }
void visit(const char* name, const _QERPlugImageTable& table) void visit(const char* name, const _QERPlugImageTable& table) const
{ {
if(m_image == 0) if(m_image == 0)
{ {
@ -61,9 +61,9 @@ Image* QERApp_LoadImage(void* environment, const char* name)
} }
} }
} }
} visitor(name, image); };
Textures_getImageModules().foreachModule(visitor); Textures_getImageModules().foreachModule(LoadImageVisitor(name, image));
return image; return image;
} }

View file

@ -214,7 +214,7 @@ void FillPluginSlots(CPluginSlots& slots, GtkWidget* main_window)
: m_slots(slots), m_main_window(main_window) : m_slots(slots), m_main_window(main_window)
{ {
} }
void visit(const char* name, const _QERPluginTable& table) void visit(const char* name, const _QERPluginTable& table) const
{ {
m_slots.AddPluginSlot(m_main_window, name, table); m_slots.AddPluginSlot(m_main_window, name, table);
} }

View file

@ -113,7 +113,7 @@ void PluginToolbar_populate()
: m_toolbar(toolbar) : m_toolbar(toolbar)
{ {
} }
void visit(const char* name, const _QERPlugToolbarTable& table) void visit(const char* name, const _QERPlugToolbarTable& table) const
{ {
const std::size_t count = table.m_pfnToolbarButtonCount(); const std::size_t count = table.m_pfnToolbarButtonCount();
for(std::size_t i=0;i<count;++i) for(std::size_t i=0;i<count;++i)

View file

@ -88,7 +88,7 @@ public:
return 0; return 0;
} }
void foreachModule(const char* type, int version, Visitor& visitor) void foreachModule(const char* type, int version, const Visitor& visitor)
{ {
for(Modules_::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i) for(Modules_::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i)
{ {

View file

@ -888,7 +888,7 @@ public:
: m_dirstring(dirstring) : m_dirstring(dirstring)
{ {
} }
void visit(const char* minor, const _QERPlugImageTable& table) void visit(const char* minor, const _QERPlugImageTable& table) const
{ {
GlobalFileSystem().forEachFile(m_dirstring, minor, TextureDirectoryLoadTextureCaller(m_dirstring)); GlobalFileSystem().forEachFile(m_dirstring, minor, TextureDirectoryLoadTextureCaller(m_dirstring));
} }
@ -919,10 +919,7 @@ void TextureBrowser_ShowDirectory(TextureBrowser& textureBrowser, const char* di
StringOutputStream dirstring(64); StringOutputStream dirstring(64);
dirstring << "textures/" << directory; dirstring << "textures/" << directory;
{ Radiant_getImageModules().foreachModule(LoadTexturesByTypeVisitor(dirstring.c_str()));
LoadTexturesByTypeVisitor visitor(dirstring.c_str());
Radiant_getImageModules().foreachModule(visitor);
}
} }
} }