simplify TYPE_CONSTANT code
This commit is contained in:
parent
edabdd157e
commit
5008fa278f
|
|
@ -130,10 +130,10 @@ class ModuleRef
|
|||
public:
|
||||
ModuleRef( const char* name ) : m_table( 0 ){
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
m_module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
|
||||
m_module = globalModuleServer().findModule( Type::Name, Type::Version, name );
|
||||
if ( m_module == 0 ) {
|
||||
globalModuleServer().setError( true );
|
||||
globalErrorStream() << "ModuleRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
globalErrorStream() << "ModuleRef::initialise: type=" << makeQuoted( Type::Name ) << " version=" << makeQuoted( Type::Version ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -151,7 +151,7 @@ public:
|
|||
}
|
||||
Type* getTable(){
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( m_table != 0, "ModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" );
|
||||
ASSERT_MESSAGE( m_table != 0, "ModuleRef::getTable: type=" << makeQuoted( Type::Name ) << " version=" << makeQuoted( Type::Version ) << " - module-reference used without being initialised" );
|
||||
#endif
|
||||
return m_table;
|
||||
}
|
||||
|
|
@ -173,16 +173,16 @@ public:
|
|||
}
|
||||
|
||||
void initialise( const char* name ){
|
||||
m_module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
|
||||
m_module = globalModuleServer().findModule( Type::Name, Type::Version, name );
|
||||
if ( m_module == 0 ) {
|
||||
globalModuleServer().setError( true );
|
||||
globalErrorStream() << "SingletonModuleRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
globalErrorStream() << "SingletonModuleRef::initialise: type=" << makeQuoted( Type::Name ) << " version=" << makeQuoted( Type::Version ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
}
|
||||
}
|
||||
|
||||
Type* getTable(){
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( m_table != 0, "SingletonModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" );
|
||||
ASSERT_MESSAGE( m_table != 0, "SingletonModuleRef::getTable: type=" << makeQuoted( Type::Name ) << " version=" << makeQuoted( Type::Version ) << " - module-reference used without being initialised" );
|
||||
#endif
|
||||
return m_table;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ public:
|
|||
INTEGER_CONSTANT( Version, 1 );
|
||||
};
|
||||
|
||||
int version = Bleh::Version();
|
||||
const char* name = Bleh::Name();
|
||||
int version = Bleh::Version;
|
||||
const char* name = Bleh::Name;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,25 +25,7 @@
|
|||
/// \file
|
||||
/// \brief Language extensions for constants that are guaranteed to be evaluated at compile-time.
|
||||
|
||||
/// \brief A compile-time-constant as a type.
|
||||
template<typename Type>
|
||||
struct ConstantWrapper
|
||||
{
|
||||
typedef typename Type::Value Value;
|
||||
operator Value() const
|
||||
{
|
||||
return Type::evaluate();
|
||||
}
|
||||
};
|
||||
template<typename TextOutputStreamType, typename Type>
|
||||
inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const ConstantWrapper<Type>& c ){
|
||||
return ostream_write( ostream, typename Type::Value( c ) );
|
||||
}
|
||||
|
||||
#define TYPE_CONSTANT( name, value, type ) struct name ## _CONSTANT_ { typedef type Value; static Value evaluate() { return value; } }; typedef ConstantWrapper<name ## _CONSTANT_> name
|
||||
#define STRING_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, const char* )
|
||||
#define INTEGER_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, int )
|
||||
|
||||
STRING_CONSTANT( EmptyString, "" );
|
||||
#define STRING_CONSTANT( name, value ) static constexpr const char* name = value
|
||||
#define INTEGER_CONSTANT( name, value ) static constexpr int name = value
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public:
|
|||
if ( !globalModuleServer().getError() ) {
|
||||
if ( string_equal( names, "*" ) ) {
|
||||
InsertModules<Type> visitor( m_modules );
|
||||
globalModuleServer().foreachModule( typename Type::Name(), typename Type::Version(), visitor );
|
||||
globalModuleServer().foreachModule( Type::Name, Type::Version, visitor );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -113,11 +113,11 @@ public:
|
|||
if ( string_empty( name ) ) {
|
||||
break;
|
||||
}
|
||||
Module* module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
|
||||
Module* module = globalModuleServer().findModule( Type::Name, Type::Version, name );
|
||||
if ( module == 0 ) {
|
||||
globalErrorStream() << "ModulesRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
globalErrorStream() << "ModulesRef::initialise: type=" << makeQuoted( Type::Name ) << " version=" << makeQuoted( Type::Version ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
// do not fail on missing image or model plugin, they can be optional
|
||||
if ( !string_equal( typename Type::Name(), "image" ) && !string_equal( typename Type::Name(), "model" ) ){
|
||||
if ( !string_equal( Type::Name, "image" ) && !string_equal( Type::Name, "model" ) ){
|
||||
globalModuleServer().setError( true );
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class DefaultAPIConstructor
|
|||
{
|
||||
public:
|
||||
const char* getName(){
|
||||
return typename API::Name();
|
||||
return API::Name;
|
||||
}
|
||||
|
||||
API* constructAPI( Dependencies& dependencies ){
|
||||
|
|
@ -49,7 +49,7 @@ class DependenciesAPIConstructor
|
|||
{
|
||||
public:
|
||||
const char* getName(){
|
||||
return typename API::Name();
|
||||
return API::Name;
|
||||
}
|
||||
|
||||
API* constructAPI( Dependencies& dependencies ){
|
||||
|
|
@ -87,7 +87,7 @@ public:
|
|||
}
|
||||
|
||||
void selfRegister(){
|
||||
globalModuleServer().registerModule( typename Type::Name(), typename Type::Version(), APIConstructor::getName(), *this );
|
||||
globalModuleServer().registerModule( Type::Name, Type::Version, APIConstructor::getName(), *this );
|
||||
}
|
||||
|
||||
Dependencies& getDependencies(){
|
||||
|
|
@ -101,16 +101,16 @@ public:
|
|||
}
|
||||
void capture(){
|
||||
if ( ++m_refcount == 1 ) {
|
||||
globalOutputStream() << "Module Initialising: '" << typename Type::Name() << "' '" << APIConstructor::getName() << "'\n";
|
||||
globalOutputStream() << "Module Initialising: '" << Type::Name << "' '" << APIConstructor::getName() << "'\n";
|
||||
m_dependencies = new Dependencies();
|
||||
m_dependencyCheck = !globalModuleServer().getError();
|
||||
if ( m_dependencyCheck ) {
|
||||
m_api = APIConstructor::constructAPI( *m_dependencies );
|
||||
globalOutputStream() << "Module Ready: '" << typename Type::Name() << "' '" << APIConstructor::getName() << "'\n";
|
||||
globalOutputStream() << "Module Ready: '" << Type::Name << "' '" << APIConstructor::getName() << "'\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
globalErrorStream() << "Module Dependencies Failed: '" << typename Type::Name() << "' '" << APIConstructor::getName() << "'\n";
|
||||
globalErrorStream() << "Module Dependencies Failed: '" << Type::Name << "' '" << APIConstructor::getName() << "'\n";
|
||||
}
|
||||
m_cycleCheck = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,17 +98,16 @@ class NodeType : public StaticTypeSystemInitialiser
|
|||
{
|
||||
TypeId m_typeId;
|
||||
public:
|
||||
typedef typename Type::Name Name;
|
||||
NodeType() : m_typeId( NODETYPEID_NONE ){
|
||||
StaticTypeSystemInitialiser::instance().addInitialiser( InitialiseCaller( *this ) );
|
||||
}
|
||||
void initialise(){
|
||||
m_typeId = GlobalSceneGraph().getNodeTypeId( Name() );
|
||||
m_typeId = GlobalSceneGraph().getNodeTypeId( Type::Name );
|
||||
}
|
||||
typedef MemberCaller<NodeType<Type>, &NodeType<Type>::initialise> InitialiseCaller;
|
||||
TypeId getTypeId(){
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( m_typeId != NODETYPEID_NONE, "node-type " << makeQuoted( Name() ) << " used before being initialised" );
|
||||
ASSERT_MESSAGE( m_typeId != NODETYPEID_NONE, "node-type " << makeQuoted( Name ) << " used before being initialised" );
|
||||
#endif
|
||||
return m_typeId;
|
||||
}
|
||||
|
|
@ -433,17 +432,16 @@ class InstanceType : public StaticTypeSystemInitialiser
|
|||
{
|
||||
TypeId m_typeId;
|
||||
public:
|
||||
typedef typename Type::Name Name;
|
||||
InstanceType() : m_typeId( INSTANCETYPEID_NONE ){
|
||||
StaticTypeSystemInitialiser::instance().addInitialiser( InitialiseCaller( *this ) );
|
||||
}
|
||||
void initialise(){
|
||||
m_typeId = GlobalSceneGraph().getInstanceTypeId( Name() );
|
||||
m_typeId = GlobalSceneGraph().getInstanceTypeId( Type::Name );
|
||||
}
|
||||
typedef MemberCaller<InstanceType<Type>, &InstanceType<Type>::initialise> InitialiseCaller;
|
||||
TypeId getTypeId(){
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( m_typeId != INSTANCETYPEID_NONE, "instance-type " << makeQuoted( Name() ) << " used before being initialised" );
|
||||
ASSERT_MESSAGE( m_typeId != INSTANCETYPEID_NONE, "instance-type " << makeQuoted( Type::Name ) << " used before being initialised" );
|
||||
#endif
|
||||
return m_typeId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ public:
|
|||
INTEGER_CONSTANT( MapVersion, 2 );
|
||||
|
||||
MapDoom3API( MapDoom3Dependencies& dependencies ) : m_dependencies( dependencies ){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "doom3 maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "doom3 region", "*.reg" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "doom3 maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "doom3 region", "*.reg" ) );
|
||||
}
|
||||
MapFormat* getTable(){
|
||||
return this;
|
||||
|
|
@ -110,8 +110,8 @@ public:
|
|||
if ( !Tokeniser_getInteger( tokeniser, version ) ) {
|
||||
return;
|
||||
}
|
||||
if ( version != MapVersion() ) {
|
||||
globalErrorStream() << "Doom 3 map version " << MapVersion() << " supported, version is " << version << "\n";
|
||||
if ( version != MapVersion ) {
|
||||
globalErrorStream() << "Doom 3 map version " << MapVersion << " supported, version is " << version << "\n";
|
||||
return;
|
||||
}
|
||||
tokeniser.nextLine();
|
||||
|
|
@ -121,7 +121,7 @@ public:
|
|||
void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
|
||||
TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter( outputStream );
|
||||
writer.writeToken( "Version" );
|
||||
writer.writeInteger( MapVersion() );
|
||||
writer.writeInteger( MapVersion );
|
||||
writer.nextLine();
|
||||
Map_Write( root, traverse, writer, false );
|
||||
writer.release();
|
||||
|
|
@ -147,8 +147,8 @@ public:
|
|||
INTEGER_CONSTANT( MapVersion, 3 );
|
||||
|
||||
MapQuake4API( MapDoom3Dependencies& dependencies ) : m_dependencies( dependencies ){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake4 maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake4 region", "*.reg" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "quake4 maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "quake4 region", "*.reg" ) );
|
||||
}
|
||||
MapFormat* getTable(){
|
||||
return this;
|
||||
|
|
@ -181,8 +181,8 @@ public:
|
|||
if ( !Tokeniser_getInteger( tokeniser, version ) ) {
|
||||
return;
|
||||
}
|
||||
if ( version != MapVersion() ) {
|
||||
globalErrorStream() << "Quake 4 map version " << MapVersion() << " supported, version is " << version << "\n";
|
||||
if ( version != MapVersion ) {
|
||||
globalErrorStream() << "Quake 4 map version " << MapVersion << " supported, version is " << version << "\n";
|
||||
return;
|
||||
}
|
||||
tokeniser.nextLine();
|
||||
|
|
@ -192,7 +192,7 @@ public:
|
|||
void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
|
||||
TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter( outputStream );
|
||||
writer.writeToken( "Version" );
|
||||
writer.writeInteger( MapVersion() );
|
||||
writer.writeInteger( MapVersion );
|
||||
writer.nextLine();
|
||||
Map_Write( root, traverse, writer, false );
|
||||
writer.release();
|
||||
|
|
@ -234,9 +234,9 @@ public:
|
|||
STRING_CONSTANT( Name, "mapq3" );
|
||||
|
||||
MapQ3API(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake3 maps", "*.map", true, true, true ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake3 region", "*.reg", true, true, true ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake3 compiled maps", "*.bsp", false, true, false ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "quake3 maps", "*.map", true, true, true ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "quake3 region", "*.reg", true, true, true ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "quake3 compiled maps", "*.bsp", false, true, false ) );
|
||||
}
|
||||
MapFormat* getTable(){
|
||||
return this;
|
||||
|
|
@ -316,8 +316,8 @@ public:
|
|||
STRING_CONSTANT( Name, "mapq1" );
|
||||
|
||||
MapQ1API(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake region", "*.reg" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "quake maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "quake region", "*.reg" ) );
|
||||
}
|
||||
MapFormat* getTable(){
|
||||
return this;
|
||||
|
|
@ -392,8 +392,8 @@ public:
|
|||
STRING_CONSTANT( Name, "maphl" );
|
||||
|
||||
MapHalfLifeAPI(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "half-life maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "half-life region", "*.reg" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "half-life maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "half-life region", "*.reg" ) );
|
||||
}
|
||||
MapFormat* getTable(){
|
||||
return this;
|
||||
|
|
@ -436,8 +436,8 @@ public:
|
|||
STRING_CONSTANT( Name, "mapq2" );
|
||||
|
||||
MapQ2API(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake2 maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake2 region", "*.reg" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "quake2 maps", "*.map" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "quake2 region", "*.reg" ) );
|
||||
}
|
||||
MapFormat* getTable(){
|
||||
return this;
|
||||
|
|
@ -639,8 +639,8 @@ public:
|
|||
STRING_CONSTANT( Name, "mapvmf" );
|
||||
|
||||
MapVMFAPI(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "vmf maps", "*.vmf" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "vmf region", "*.reg" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "vmf maps", "*.vmf" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "vmf region", "*.reg" ) );
|
||||
}
|
||||
MapFormat* getTable(){
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public:
|
|||
STRING_CONSTANT( Name, "xmldoom3" );
|
||||
|
||||
MapXMLAPI(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "xml doom3 maps", "*.xmap" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "xml doom3 maps", "*.xmap" ) );
|
||||
}
|
||||
MapFormat* getTable(){
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public:
|
|||
STRING_CONSTANT( Name, "md3" );
|
||||
|
||||
ModelMD3API(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "md3 models", "*.md3" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "md3 models", "*.md3" ) );
|
||||
}
|
||||
ModelLoader* getTable(){
|
||||
return &m_modelmd3;
|
||||
|
|
@ -99,7 +99,7 @@ public:
|
|||
STRING_CONSTANT( Name, "md2" );
|
||||
|
||||
ModelMD2API(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "md2 models", "*.md2" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "md2 models", "*.md2" ) );
|
||||
}
|
||||
ModelLoader* getTable(){
|
||||
return &m_modelmd2;
|
||||
|
|
@ -126,7 +126,7 @@ public:
|
|||
STRING_CONSTANT( Name, "mdl" );
|
||||
|
||||
ModelMDLAPI(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "mdl models", "*.mdl" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "mdl models", "*.mdl" ) );
|
||||
}
|
||||
ModelLoader* getTable(){
|
||||
return &m_modelmdl;
|
||||
|
|
@ -153,7 +153,7 @@ public:
|
|||
STRING_CONSTANT( Name, "mdc" );
|
||||
|
||||
ModelMDCAPI(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "mdc models", "*.mdc" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "mdc models", "*.mdc" ) );
|
||||
}
|
||||
ModelLoader* getTable(){
|
||||
return &m_modelmdc;
|
||||
|
|
@ -205,7 +205,7 @@ public:
|
|||
STRING_CONSTANT( Name, "md5mesh" );
|
||||
|
||||
ModelMD5API(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "md5 meshes", "*.md5mesh" ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, Name, filetype_t( "md5 meshes", "*.md5mesh" ) );
|
||||
}
|
||||
ModelLoader* getTable(){
|
||||
return &m_modelmd5;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public:
|
|||
m_modelLoader( module ){
|
||||
StringOutputStream filter( 128 );
|
||||
filter << "*." << extension;
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), extension, filetype_t( module->displayName, filter.c_str() ) );
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name, extension, filetype_t( module->displayName, filter.c_str() ) );
|
||||
}
|
||||
ModelLoader* getTable(){
|
||||
return &m_modelLoader;
|
||||
|
|
|
|||
|
|
@ -604,7 +604,7 @@ const char* misc_model_dialog( GtkWidget* parent, const char* filepath ){
|
|||
}
|
||||
}
|
||||
|
||||
const char *filename = file_dialog( parent, true, "Choose Model", buffer.c_str(), ModelLoader::Name() );
|
||||
const char *filename = file_dialog( parent, true, "Choose Model", buffer.c_str(), ModelLoader::Name );
|
||||
if ( filename != 0 ) {
|
||||
// use VFS to get the correct relative path
|
||||
const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) );
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ bool Map_Unnamed( const Map& map ){
|
|||
}
|
||||
|
||||
inline const MapFormat& MapFormat_forFile( const char* filename ){
|
||||
const char* moduleName = findModuleName( GetFileTypeRegistry(), MapFormat::Name(), path_get_extension( filename ) );
|
||||
const char* moduleName = findModuleName( GetFileTypeRegistry(), MapFormat::Name, path_get_extension( filename ) );
|
||||
MapFormat* format = Radiant_getMapModules().findModule( moduleName );
|
||||
ASSERT_MESSAGE( format != 0, "map format not found for file " << makeQuoted( filename ) );
|
||||
return *format;
|
||||
|
|
@ -1974,17 +1974,17 @@ const char* getMapsPath(){
|
|||
|
||||
const char* map_open( const char* title ){
|
||||
const char* path = Map_Unnamed( g_map )? getMapsPath() : g_map.m_name.c_str();
|
||||
return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), true, title, path, MapFormat::Name(), true, false, false );
|
||||
return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), true, title, path, MapFormat::Name, true, false, false );
|
||||
}
|
||||
|
||||
const char* map_import( const char* title ){
|
||||
const char* path = Map_Unnamed( g_map )? getMapsPath() : g_map.m_name.c_str();
|
||||
return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), true, title, path, MapFormat::Name(), false, true, false );
|
||||
return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), true, title, path, MapFormat::Name, false, true, false );
|
||||
}
|
||||
|
||||
const char* map_save( const char* title ){
|
||||
const char* path = Map_Unnamed( g_map )? getMapsPath() : g_map.m_name.c_str();
|
||||
return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), false, title, path, MapFormat::Name(), false, false, true );
|
||||
return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), false, title, path, MapFormat::Name, false, false, true );
|
||||
}
|
||||
|
||||
void OpenMap(){
|
||||
|
|
|
|||
|
|
@ -1231,7 +1231,7 @@ void ModelBrowser_constructTree(){
|
|||
m_modelExtensions.emplace( moduleName );
|
||||
}
|
||||
} typelist;
|
||||
GlobalFiletypes().getTypeList( ModelLoader::Name(), &typelist, true, false, false );
|
||||
GlobalFiletypes().getTypeList( ModelLoader::Name, &typelist, true, false, false );
|
||||
|
||||
ModelFolders modelFolders( g_ModelBrowser.m_prefFoldersToLoad.c_str() );
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ NullModelLoader g_NullModelLoader;
|
|||
|
||||
/// \brief Returns the model loader for the model \p type or 0 if the model \p type has no loader module
|
||||
ModelLoader* ModelLoader_forType( const char* type ){
|
||||
const char* moduleName = findModuleName( &GlobalFiletypes(), ModelLoader::Name(), type );
|
||||
const char* moduleName = findModuleName( &GlobalFiletypes(), ModelLoader::Name, type );
|
||||
if ( string_not_empty( moduleName ) ) {
|
||||
ModelLoader* table = ReferenceAPI_getModelModules().findModule( moduleName );
|
||||
if ( table != 0 ) {
|
||||
|
|
@ -283,7 +283,7 @@ NodeSmartReference Model_load( ModelLoader* loader, const char* path, const char
|
|||
}
|
||||
else
|
||||
{
|
||||
const char* moduleName = findModuleName( &GlobalFiletypes(), MapFormat::Name(), type );
|
||||
const char* moduleName = findModuleName( &GlobalFiletypes(), MapFormat::Name, type );
|
||||
if ( string_not_empty( moduleName ) ) {
|
||||
const MapFormat* format = ReferenceAPI_getMapModules().findModule( moduleName );
|
||||
if ( format != 0 ) {
|
||||
|
|
@ -398,7 +398,7 @@ struct ModelResource : public Resource
|
|||
}
|
||||
bool save(){
|
||||
if ( !mapSaved() ) {
|
||||
const char* moduleName = findModuleName( GetFileTypeRegistry(), MapFormat::Name(), m_type.c_str() );
|
||||
const char* moduleName = findModuleName( GetFileTypeRegistry(), MapFormat::Name, m_type.c_str() );
|
||||
if ( string_not_empty( moduleName ) ) {
|
||||
const MapFormat* format = ReferenceAPI_getMapModules().findModule( moduleName );
|
||||
if ( format != 0 && MapResource_save( *format, m_model.get(), m_path.c_str(), m_name.c_str() ) ) {
|
||||
|
|
|
|||
|
|
@ -254,8 +254,8 @@ public:
|
|||
m_undoables.erase( undoable );
|
||||
}
|
||||
void setLevels( std::size_t levels ){
|
||||
if ( levels > static_cast<unsigned>( MAX_UNDO_LEVELS() ) ) {
|
||||
levels = MAX_UNDO_LEVELS();
|
||||
if ( levels > static_cast<unsigned>( MAX_UNDO_LEVELS ) ) {
|
||||
levels = MAX_UNDO_LEVELS;
|
||||
}
|
||||
|
||||
while ( m_undo_stack.size() > levels )
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user