mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2025-01-10 03:51:18 +00:00
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:
parent
988b2f6fbc
commit
d498eb592d
10 changed files with 67 additions and 53 deletions
1
CHANGES
1
CHANGES
|
@ -8,6 +8,7 @@ SPoG
|
|||
- Fixed title of wait-dialog when loading a model.
|
||||
- Fixed doom3 func_static with blank 'model' key being invisible.
|
||||
- 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
|
||||
Shaderman
|
||||
|
|
|
@ -63,17 +63,17 @@ struct EntityClassScanner
|
|||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<EntityClassScanner> GlobalEClassModule;
|
||||
class ModuleRef;
|
||||
typedef ModuleRef<EntityClassScanner> EClassModuleRef;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<EntityClassScanner> GlobalEClassModuleRef;
|
||||
class Modules;
|
||||
typedef Modules<EntityClassScanner> EClassModules;
|
||||
|
||||
template<typename Type>
|
||||
class ModulesRef;
|
||||
typedef ModulesRef<EntityClassScanner> EClassModulesRef;
|
||||
|
||||
inline EntityClassScanner& GlobalEClassLoader()
|
||||
{
|
||||
return GlobalEClassModule::getTable();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
class Visitor
|
||||
{
|
||||
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;
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
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 void foreachModule(const char* type, int version, Visitor& visitor) = 0;
|
||||
virtual void foreachModule(const char* type, int version, const Visitor& visitor) = 0;
|
||||
};
|
||||
|
||||
class ModuleServerHolder
|
||||
|
@ -112,11 +112,11 @@ public:
|
|||
class Visitor
|
||||
{
|
||||
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 void foreachModule(Visitor& visitor) = 0;
|
||||
virtual void foreachModule(const Visitor& visitor) = 0;
|
||||
};
|
||||
|
||||
#include "debugging/debugging.h"
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
{
|
||||
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)
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
: m_modules(modules)
|
||||
{
|
||||
}
|
||||
void visit(const char* name, Module& module)
|
||||
void visit(const char* name, Module& module) const
|
||||
{
|
||||
m_modules.insert(name, module);
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace
|
|||
ListAttributeTypes g_listTypes;
|
||||
}
|
||||
|
||||
EClassModules& EntityClassManager_getEClassModules();
|
||||
|
||||
/*!
|
||||
implementation of the EClass manager API
|
||||
*/
|
||||
|
@ -144,9 +146,10 @@ public:
|
|||
|
||||
class EntityClassesLoadFile
|
||||
{
|
||||
const EntityClassScanner& scanner;
|
||||
const char* m_directory;
|
||||
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
|
||||
|
@ -178,7 +181,7 @@ public:
|
|||
StringOutputStream relPath(256);
|
||||
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)
|
||||
{
|
||||
globalOutputStream() << "EntityClass: searching " << makeQuoted(directory) << " for *." << extension << '\n';
|
||||
Directory_forEach(directory, matchFileExtension(extension, PathsInsert(paths, directory)));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void EntityClassQuake3_Construct()
|
||||
{
|
||||
#if 1
|
||||
StringOutputStream baseDirectory(256);
|
||||
StringOutputStream gameDirectory(256);
|
||||
const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue("basegame");
|
||||
|
@ -230,22 +226,32 @@ void EntityClassQuake3_Construct()
|
|||
baseDirectory << GlobalRadiant().getGameToolsPath() << basegame << '/';
|
||||
gameDirectory << GlobalRadiant().getGameToolsPath() << gamename << '/';
|
||||
|
||||
Paths paths;
|
||||
EntityClassQuake3_constructDirectory(baseDirectory.c_str(), GlobalEClassLoader().getExtension(), paths);
|
||||
if(!string_equal(basegame, gamename))
|
||||
class LoadEntityDefinitionsVisitor : public EClassModules::Visitor
|
||||
{
|
||||
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)
|
||||
{
|
||||
EntityClassesLoadFile((*i).second)((*i).first.c_str());
|
||||
}
|
||||
#else
|
||||
StringOutputStream directory(256);
|
||||
directory << GlobalRadiant().getGameToolsPath() << GlobalRadiant().getGameName() << '/';
|
||||
EntityClassQuake3_constructDirectory(directory.c_str(), GlobalEClassLoader().getExtension());
|
||||
#endif
|
||||
for(Paths::iterator i = paths.begin(); i != paths.end(); ++i)
|
||||
{
|
||||
EntityClassesLoadFile(table, (*i).second)((*i).first.c_str());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
EntityClassManager_getEClassModules().foreachModule(LoadEntityDefinitionsVisitor(baseDirectory.c_str(), gameDirectory.c_str()));
|
||||
}
|
||||
|
||||
EntityClass *Eclass_ForName(const char *name, bool has_brushes)
|
||||
|
@ -338,17 +344,23 @@ void EntityClassQuake3_destroy()
|
|||
eclass_bad->free(eclass_bad);
|
||||
}
|
||||
|
||||
#include "modulesystem/modulesmap.h"
|
||||
|
||||
class EntityClassQuake3Dependencies :
|
||||
public GlobalRadiantModuleRef,
|
||||
public GlobalFileSystemModuleRef,
|
||||
public GlobalShaderCacheModuleRef,
|
||||
public GlobalEClassModuleRef
|
||||
public GlobalShaderCacheModuleRef
|
||||
{
|
||||
EClassModulesRef m_eclass_modules;
|
||||
public:
|
||||
EntityClassQuake3Dependencies() :
|
||||
GlobalEClassModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclasstype"))
|
||||
m_eclass_modules(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclasstype"))
|
||||
{
|
||||
}
|
||||
EClassModules& getEClassModules()
|
||||
{
|
||||
return m_eclass_modules.get();
|
||||
}
|
||||
};
|
||||
|
||||
class EclassManagerAPI
|
||||
|
@ -395,4 +407,8 @@ typedef SingletonModule<EclassManagerAPI, EntityClassQuake3Dependencies> EclassM
|
|||
typedef Static<EclassManagerModule> StaticEclassManagerModule;
|
||||
StaticRegisterModule staticRegisterEclassManager(StaticEclassManagerModule::instance());
|
||||
|
||||
EClassModules& EntityClassManager_getEClassModules()
|
||||
{
|
||||
return StaticEclassManagerModule::instance().getDependencies().getEClassModules();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ Image* QERApp_LoadImage(void* environment, const char* name)
|
|||
: 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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ void FillPluginSlots(CPluginSlots& slots, GtkWidget* 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);
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ void PluginToolbar_populate()
|
|||
: 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();
|
||||
for(std::size_t i=0;i<count;++i)
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -888,7 +888,7 @@ public:
|
|||
: 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));
|
||||
}
|
||||
|
@ -919,10 +919,7 @@ void TextureBrowser_ShowDirectory(TextureBrowser& textureBrowser, const char* di
|
|||
StringOutputStream dirstring(64);
|
||||
dirstring << "textures/" << directory;
|
||||
|
||||
{
|
||||
LoadTexturesByTypeVisitor visitor(dirstring.c_str());
|
||||
Radiant_getImageModules().foreachModule(visitor);
|
||||
}
|
||||
Radiant_getImageModules().foreachModule(LoadTexturesByTypeVisitor(dirstring.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue