void CGameDescription::Dump(){ globalOutputStream() << "game description file: " << makeQuoted( mGameFile.c_str() ) << "\n"; for ( GameDescription::iterator i = m_gameDescription.begin(); i != m_gameDescription.end(); ++i ) { globalOutputStream() << ( *i ).first.c_str() << " = " << makeQuoted( ( *i ).second.c_str() ) << "\n"; } }
void LoadCommandMap( const char* path ){ StringOutputStream strINI( 256 ); strINI << path << "shortcuts.ini"; FILE* f = fopen( strINI.c_str(), "r" ); if ( f != 0 ) { fclose( f ); globalOutputStream() << "loading custom shortcuts list from " << makeQuoted( strINI.c_str() ) << "\n"; Version version = version_parse( COMMANDS_VERSION ); Version dataVersion = { 0, 0 }; { char value[1024]; if ( read_var( strINI.c_str(), "Version", "number", value ) ) { dataVersion = version_parse( value ); } } if ( version_compatible( version, dataVersion ) ) { globalOutputStream() << "commands import: data version " << dataVersion << " is compatible with code version " << version << "\n"; ReadCommandMap visitor( strINI.c_str() ); GlobalShortcuts_foreach( visitor ); globalOutputStream() << "parsed " << Unsigned( visitor.count() ) << " custom shortcuts\n"; } else { globalOutputStream() << "commands import: data version " << dataVersion << " is not compatible with code version " << version << "\n"; } } else { globalOutputStream() << "failed to load custom shortcuts from " << makeQuoted( strINI.c_str() ) << "\n"; } }
void registerModule( const char* type, int version, const char* name, Module& module ){ ASSERT_NOTNULL( &module ); if ( !m_modules.insert( Modules_::value_type( ModuleKey( ModuleType( type, version ), name ), &module ) ).second ) { globalErrorStream() << "module already registered: type=" << makeQuoted( type ) << " name=" << makeQuoted( name ) << "\n"; } else { globalOutputStream() << "Module Registered: type=" << makeQuoted( type ) << " version=" << makeQuoted( version ) << " name=" << makeQuoted( name ) << "\n"; } }
void build_run(const char* name, CommandListener& listener) { for(Tools::iterator i = g_build_tools.begin(); i != g_build_tools.end(); ++i) { StringBuffer output; (*i).second.evaluate(output); build_set_variable((*i).first.c_str(), output.c_str()); } { Project::iterator i = Project_find(g_build_project, name); if(i != g_build_project.end()) { Build& build = (*i).second; for(Build::iterator j = build.begin(); j != build.end(); ++j) { StringBuffer output; (*j).evaluate(output); listener.execute(output.c_str()); } } else { globalErrorStream() << "build " << makeQuoted(name) << " not defined"; } } }
void EntityClass_resolveInheritance( EntityClass* derivedClass ){ if ( derivedClass->inheritanceResolved == false ) { derivedClass->inheritanceResolved = true; EntityClasses::iterator i = g_EntityClassDoom3_classes.find( derivedClass->m_parent.front().c_str() ); if ( i == g_EntityClassDoom3_classes.end() ) { globalErrorStream() << "failed to find entityDef " << makeQuoted( derivedClass->m_parent.front().c_str() ) << " inherited by " << makeQuoted( derivedClass->m_name.c_str() ) << "\n"; } else { EntityClass* parentClass = ( *i ).second; EntityClass_resolveInheritance( parentClass ); if ( !derivedClass->colorSpecified ) { derivedClass->colorSpecified = parentClass->colorSpecified; derivedClass->color = parentClass->color; } if ( !derivedClass->sizeSpecified ) { derivedClass->sizeSpecified = parentClass->sizeSpecified; derivedClass->mins = parentClass->mins; derivedClass->maxs = parentClass->maxs; derivedClass->fixedsize = parentClass->fixedsize; } for ( EntityClassAttributes::iterator j = parentClass->m_attributes.begin(); j != parentClass->m_attributes.end(); ++j ) { EntityClass_insertAttribute( *derivedClass, ( *j ).first.c_str(), ( *j ).second ); } } } }
void keyup_accelerators_remove(Accelerator accelerator) { //globalOutputStream() << "keyup_accelerators_remove: " << makeQuoted(accelerator) << "\n"; if(!accelerator_map_erase(g_keyup_accelerators, accelerator)) { globalErrorStream() << "keyup_accelerators_remove: not found: " << makeQuoted(accelerator) << "\n"; } }
void keyup_accelerators_add(Accelerator accelerator, const Callback& callback) { //globalOutputStream() << "keyup_accelerators_add: " << makeQuoted(accelerator) << "\n"; if(!accelerator_map_insert(g_keyup_accelerators, accelerator, callback)) { globalErrorStream() << "keyup_accelerators_add: already exists: " << makeQuoted(accelerator) << "\n"; } }
bool MapResource_save(const MapFormat& format, scene::Node& root, const char* path, const char* name) { StringOutputStream fullpath(256); fullpath << path << name; if(path_is_absolute(fullpath.c_str())) { if(!file_exists(fullpath.c_str()) || file_saveBackup(fullpath.c_str())) { return MapResource_saveFile(format, root, Map_Traverse, fullpath.c_str()); } globalErrorStream() << "failed to save a backup map file: " << makeQuoted(fullpath.c_str()) << "\n"; return false; } globalErrorStream() << "map path is not fully qualified: " << makeQuoted(fullpath.c_str()) << "\n"; return false; }
const char* build_get_variable(const char* name) { Variables::iterator i = g_build_variables.find(name); if(i != g_build_variables.end()) { return (*i).second.c_str(); } globalErrorStream() << "undefined build variable: " << makeQuoted(name) << "\n"; return ""; }
void CGameDialog::LoadPrefs(){ // load global .pref file StringOutputStream strGlobalPref( 256 ); strGlobalPref << g_Preferences.m_global_rc_path->str << "global.pref"; globalOutputStream() << "loading global preferences from " << makeQuoted( strGlobalPref.c_str() ) << "\n"; if ( !Preferences_Load( g_global_preferences, strGlobalPref.c_str(), "global" ) ) { globalOutputStream() << "failed to load global preferences from " << strGlobalPref.c_str() << "\n"; } }
void EntityClassDoom3_loadFile( const char* filename ){ globalOutputStream() << "parsing entity classes from " << makeQuoted( filename ) << "\n"; StringOutputStream fullname( 256 ); fullname << "def/" << filename; ArchiveTextFile* file = GlobalFileSystem().openTextFile( fullname.c_str() ); if ( file != 0 ) { EntityClassDoom3_parse( file->getInputStream(), fullname.c_str() ); file->release(); } }
bool file_saveBackup(const char* path) { if(file_writeable(path)) { StringOutputStream backup(256); backup << StringRange(path, path_get_extension(path)) << "bak"; return (!file_exists(backup.c_str()) || file_remove(backup.c_str())) // remove backup && file_move(path, backup.c_str()); // rename current to backup } globalErrorStream() << "map path is not writeable: " << makeQuoted(path) << "\n"; return false; }
void realise(){ if ( --m_unrealised == 0 ) { globalOutputStream() << "searching vfs directory " << makeQuoted( "def" ) << " for *.def\n"; GlobalFileSystem().forEachFile( "def/", "def", makeCallbackF(EntityClassDoom3_loadFile) ); { for ( Models::iterator i = g_models.begin(); i != g_models.end(); ++i ) { Model_resolveInheritance( ( *i ).first.c_str(), ( *i ).second ); } } { for ( EntityClasses::iterator i = g_EntityClassDoom3_classes.begin(); i != g_EntityClassDoom3_classes.end(); ++i ) { EntityClass_resolveInheritance( ( *i ).second ); if ( !string_empty( ( *i ).second->m_modelpath.c_str() ) ) { Models::iterator j = g_models.find( ( *i ).second->m_modelpath ); if ( j != g_models.end() ) { ( *i ).second->m_modelpath = ( *j ).second.m_mesh; ( *i ).second->m_skin = ( *j ).second.m_skin; } } eclass_capture_state( ( *i ).second ); StringOutputStream usage( 256 ); usage << "-------- NOTES --------\n"; if ( !string_empty( ( *i ).second->m_comments.c_str() ) ) { usage << ( *i ).second->m_comments.c_str() << "\n"; } usage << "\n-------- KEYS --------\n"; for ( EntityClassAttributes::iterator j = ( *i ).second->m_attributes.begin(); j != ( *i ).second->m_attributes.end(); ++j ) { const char* name = EntityClassAttributePair_getName( *j ); const char* description = EntityClassAttributePair_getDescription( *j ); if ( !string_equal( name, description ) ) { usage << EntityClassAttributePair_getName( *j ) << " : " << EntityClassAttributePair_getDescription( *j ) << "\n"; } } ( *i ).second->m_comments = usage.c_str(); } } m_observers.realise(); } }
/// moves selected primitives to entity, which is or its primitive is ultimateSelected() or firstSelected() void Entity_moveSelectedPrimitives( bool toLast ){ if ( GlobalSelectionSystem().countSelected() < 2 ) { globalErrorStream() << "Source and target entity primitives should be selected!\n"; return; } const scene::Path& path = toLast? GlobalSelectionSystem().ultimateSelected().path() : GlobalSelectionSystem().firstSelected().path(); scene::Node& node = ( !Node_isEntity( path.top() ) && path.size() > 1 )? path.parent() : path.top(); if ( Node_isEntity( node ) && node_is_group( node ) ) { StringOutputStream command; command << "movePrimitivesToEntity " << makeQuoted( Node_getEntity( node )->getEntityClass().name() ); UndoableCommand undo( command.c_str() ); Scene_parentSelectedBrushesToEntity( GlobalSceneGraph(), node ); } }
NodeSmartReference MapResource_load(const MapFormat& format, const char* path, const char* name) { NodeSmartReference root(NewMapRoot(name)); StringOutputStream fullpath(256); fullpath << path << name; if(path_is_absolute(fullpath.c_str())) { MapResource_loadFile(format, root, fullpath.c_str()); } else { globalErrorStream() << "map path is not fully qualified: " << makeQuoted(fullpath.c_str()) << "\n"; } return root; }
bool build_commands_parse(const char* filename) { TextFileInputStream projectFile(filename); if(!projectFile.failed()) { ProjectXMLConstructor projectConstructor(g_build_project, g_build_tools); RootXMLConstructor rootConstructor("project", projectConstructor, BUILDMENU_VERSION); XMLParser importer(rootConstructor); XMLStreamParser parser(projectFile); parser.exportXML(importer); if(rootConstructor.versionCompatible()) { project_verify(g_build_project, g_build_tools); return true; } globalErrorStream() << "failed to parse build menu: " << makeQuoted(filename) << "\n"; } return false; }
void visit( const char* name, Accelerator& accelerator ){ char value[1024]; if ( read_var( m_filename, "Commands", name, value ) ) { if ( string_empty( value ) ) { accelerator.key = 0; accelerator.modifiers = (GdkModifierType)0; return; } gtk_accelerator_parse( value, &accelerator.key, &accelerator.modifiers ); accelerator = accelerator; // fix modifiers if ( accelerator.key != 0 ) { ++m_count; } else { globalOutputStream() << "WARNING: failed to parse user command " << makeQuoted( name ) << ": unknown key " << makeQuoted( value ) << "\n"; } } }
bool EntityClassDoom3_parseModel( Tokeniser& tokeniser ){ const char* name; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, name ) ); Model& model = g_models[name]; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "{" ) ); tokeniser.nextLine(); for (;; ) { const char* parameter; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, parameter ) ); if ( string_equal( parameter, "}" ) ) { tokeniser.nextLine(); break; } else if ( string_equal( parameter, "inherit" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, model.m_parent ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "remove" ) ) { //const char* remove = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "mesh" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, model.m_mesh ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "skin" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, model.m_skin ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "offset" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "(" ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, ")" ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "channel" ) ) { //const char* channelName = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "(" ) ); for (;; ) { const char* end; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, end ) ); if ( string_equal( end, ")" ) ) { tokeniser.nextLine(); break; } } } else if ( string_equal( parameter, "anim" ) ) { CopiedString animName; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, animName ) ); const char* animFile; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, animFile ) ); model.m_anims.insert( Model::Anims::value_type( animName, animFile ) ); const char* token; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) ); while ( string_equal( token, "," ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, animFile ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) ); } if ( string_equal( token, "{" ) ) { for (;; ) { const char* end; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, end ) ); if ( string_equal( end, "}" ) ) { tokeniser.nextLine(); break; } tokeniser.nextLine(); } } else { tokeniser.ungetToken(); } } else { globalErrorStream() << "unknown model parameter: " << makeQuoted( parameter ) << "\n"; return false; } tokeniser.nextLine(); } return true; }
const KeyEvent& GlobalKeyEvents_find( const char* name ){ KeyEvents::iterator i = g_keyEvents.find( name ); ASSERT_MESSAGE( i != g_keyEvents.end(), "failed to lookup keyEvent " << makeQuoted( name ) ); return ( *i ).second; }
const char* file_dialog_show(GtkWidget* parent, bool open, const char* title, const char* path, const char* pattern) { filetype_t type; if(pattern == 0) { pattern = "*"; } FileTypeList typelist; GlobalFiletypes().getTypeList(pattern, &typelist); GTKMasks masks(typelist); if (title == 0) title = open ? "Open File" : "Save File"; GtkWidget* dialog; if (open) { dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(parent), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); } else { dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(parent), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "unnamed"); } gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT); // we expect an actual path below, if the path is 0 we might crash if (path != 0 && !string_empty(path)) { ASSERT_MESSAGE(path_is_absolute(path), "file_dialog_show: path not absolute: " << makeQuoted(path)); Array<char> new_path(strlen(path)+1); // copy path, replacing dir separators as appropriate Array<char>::iterator w = new_path.begin(); for(const char* r = path; *r != '\0'; ++r) { *w++ = (*r == '/') ? G_DIR_SEPARATOR : *r; } // remove separator from end of path if required if(*(w-1) == G_DIR_SEPARATOR) { --w; } // terminate string *w = '\0'; gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), new_path.data()); } // we should add all important paths as shortcut folder... // gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(dialog), "/tmp/", NULL); for(std::size_t i = 0; i < masks.m_filters.size(); ++i) { GtkFileFilter* filter = gtk_file_filter_new(); gtk_file_filter_add_pattern(filter, masks.m_filters[i].c_str()); gtk_file_filter_set_name(filter, masks.m_masks[i].c_str()); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); } if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { strcpy(g_file_dialog_file, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog))); if(!string_equal(pattern, "*")) { GtkFileFilter* filter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog)); if(filter != 0) // no filter set? some file-chooser implementations may allow the user to set no filter, which we treat as 'all files' { type = masks.GetTypeForGTKMask(gtk_file_filter_get_name(filter)).m_type; // last ext separator const char* extension = path_get_extension(g_file_dialog_file); // no extension if(string_empty(extension)) { strcat(g_file_dialog_file, type.pattern+1); } else { strcpy(g_file_dialog_file + (extension - g_file_dialog_file), type.pattern+2); } } } // convert back to unix format for(char* w = g_file_dialog_file; *w!='\0'; w++) { if(*w=='\\') { *w = '/'; } } } else { g_file_dialog_file[0] = '\0'; } gtk_widget_destroy(dialog); // don't return an empty filename if(g_file_dialog_file[0] == '\0') return NULL; return g_file_dialog_file; }
void GlobalKeyEvents_insert( const char* name, const Accelerator& accelerator, const Callback& keyDown, const Callback& keyUp ){ bool added = g_keyEvents.insert( KeyEvents::value_type( name, KeyEvent( GlobalShortcuts_insert( name, accelerator ), keyDown, keyUp ) ) ).second; ASSERT_MESSAGE( added, "command already registered: " << makeQuoted( name ) ); }
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))); }
CGameDescription::CGameDescription(xmlDocPtr pDoc, const CopiedString& gameFile) { // read the user-friendly game name xmlNodePtr pNode = pDoc->children; while (strcmp((const char*)pNode->name, "game") && pNode != 0) { pNode=pNode->next; } if (!pNode) { Error("Didn't find 'game' node in the game description file '%s'\n", pDoc->URL); } for(xmlAttrPtr attr = pNode->properties; attr != 0; attr = attr->next) { m_gameDescription.insert(GameDescription::value_type(xmlAttr_getName(attr), xmlAttr_getValue(attr))); } { StringOutputStream path(256); path << AppPath_get() << gameFile.c_str() << "/"; mGameToolsPath = path.c_str(); } ASSERT_MESSAGE(file_exists(mGameToolsPath.c_str()), "game directory not found: " << makeQuoted(mGameToolsPath.c_str())); mGameFile = gameFile; { GameDescription::iterator i = m_gameDescription.find("type"); if(i == m_gameDescription.end()) { globalErrorStream() << "Warning, 'type' attribute not found in '" << reinterpret_cast<const char*>(pDoc->URL) << "'\n"; // default mGameType = "q3"; } else { mGameType = (*i).second.c_str(); } } }
void visit(const char* name, Accelerator& accelerator) { char value[1024]; if (read_var(m_filename, "Commands", name, value )) { if(string_empty(value)) { accelerator.key = 0; accelerator.modifiers = (GdkModifierType)0; return; } int modifiers = 0; const char* last = value + string_length(value); const char* keyEnd = stringrange_find(value, last, '+'); for(const char* modifier = keyEnd; modifier != last;) { const char* next = stringrange_find(modifier + 1, last, '+'); if(next - modifier == 4 && string_equal_nocase_n(modifier, "+alt", 4)) { modifiers |= GDK_MOD1_MASK; } else if(next - modifier == 5 && string_equal_nocase_n(modifier, "+ctrl", 5) != 0) { modifiers |= GDK_CONTROL_MASK; } else if(next - modifier == 6 && string_equal_nocase_n(modifier, "+shift", 6) != 0) { modifiers |= GDK_SHIFT_MASK; } else { globalOutputStream() << "WARNING: failed to parse user command " << makeQuoted(value) << ": unknown modifier " << makeQuoted(StringRange(modifier, next)) << "\n"; } modifier = next; } accelerator.modifiers = (GdkModifierType)modifiers; // strBuff has been cleaned of it's modifiers .. switch between a regular key and a virtual one // based on length if(keyEnd - value == 1) // most often case.. deal with first { accelerator.key = std::toupper(value[0]); ++m_count; } else // special key { CopiedString keyName(StringRange(value, keyEnd)); accelerator.key = global_keys_find(keyName.c_str()); if(accelerator.key != 0) { ++m_count; } else { globalOutputStream() << "WARNING: failed to parse user command " << makeQuoted(value) << ": unknown key " << makeQuoted(keyName.c_str()) << "\n"; } } } }
void GlobalCommands_insert( const char* name, const Callback& callback, const Accelerator& accelerator ){ bool added = g_commands.insert( Commands::value_type( name, Command( callback, GlobalShortcuts_insert( name, accelerator ) ) ) ).second; ASSERT_MESSAGE( added, "command already registered: " << makeQuoted( name ) ); }
void GlobalToggles_insert( const char* name, const Callback& callback, const BoolExportCallback& exportCallback, const Accelerator& accelerator ){ bool added = g_toggles.insert( Toggles::value_type( name, Toggle( callback, GlobalShortcuts_insert( name, accelerator ), exportCallback ) ) ).second; ASSERT_MESSAGE( added, "toggle already registered: " << makeQuoted( name ) ); }
const Command& GlobalCommands_find( const char* command ){ Commands::iterator i = g_commands.find( command ); ASSERT_MESSAGE( i != g_commands.end(), "failed to lookup command " << makeQuoted( command ) ); return ( *i ).second; }
static bool EntityClass_parse( EntityClass& entityClass, Tokeniser& tokeniser ){ PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, entityClass.m_name ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "{" ) ); tokeniser.nextLine(); StringOutputStream usage( 256 ); StringOutputStream description( 256 ); CopiedString* currentDescription = 0; StringOutputStream* currentString = 0; for (;; ) { const char* key; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, key ) ); const char* last = string_findFirstSpaceOrTab( key ); CopiedString first( StringRange( key, last ) ); if ( !string_empty( last ) ) { last = string_findFirstNonSpaceOrTab( last ); } if ( currentString != 0 && string_equal( key, "\\" ) ) { tokeniser.nextLine(); *currentString << " "; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, *currentString ) ); continue; } if ( currentDescription != 0 ) { *currentDescription = description.c_str(); description.clear(); currentDescription = 0; } currentString = 0; if ( string_equal( key, "}" ) ) { tokeniser.nextLine(); break; } else if ( string_equal( key, "model" ) ) { const char* token; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) ); entityClass.fixedsize = true; StringOutputStream buffer( 256 ); buffer << PathCleaned( token ); entityClass.m_modelpath = buffer.c_str(); } else if ( string_equal( key, "editor_color" ) ) { const char* value; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) ); if ( !string_empty( value ) ) { entityClass.colorSpecified = true; bool success = string_parse_vector3( value, entityClass.color ); ASSERT_MESSAGE( success, "editor_color: parse error" ); } } else if ( string_equal( key, "editor_ragdoll" ) ) { //bool ragdoll = atoi(tokeniser.getToken()) != 0; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } else if ( string_equal( key, "editor_mins" ) ) { entityClass.sizeSpecified = true; const char* value; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) ); if ( !string_empty( value ) && !string_equal( value, "?" ) ) { entityClass.fixedsize = true; bool success = string_parse_vector3( value, entityClass.mins ); ASSERT_MESSAGE( success, "editor_mins: parse error" ); } } else if ( string_equal( key, "editor_maxs" ) ) { entityClass.sizeSpecified = true; const char* value; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) ); if ( !string_empty( value ) && !string_equal( value, "?" ) ) { entityClass.fixedsize = true; bool success = string_parse_vector3( value, entityClass.maxs ); ASSERT_MESSAGE( success, "editor_maxs: parse error" ); } } else if ( string_equal( key, "editor_usage" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, usage ) ); currentString = &usage; } else if ( string_equal_n( key, "editor_usage", 12 ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, usage ) ); currentString = &usage; } else if ( string_equal( key, "editor_rotatable" ) || string_equal( key, "editor_showangle" ) || string_equal( key, "editor_showangles" ) // typo? in prey movables.def || string_equal( key, "editor_mover" ) || string_equal( key, "editor_model" ) || string_equal( key, "editor_material" ) || string_equal( key, "editor_combatnode" ) || ( !string_empty( last ) && string_equal( first.c_str(), "editor_gui" ) ) || string_equal_n( key, "editor_copy", 11 ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } else if ( !string_empty( last ) && ( string_equal( first.c_str(), "editor_var" ) || string_equal( first.c_str(), "editor_string" ) ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "string"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_float" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "string"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_snd" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "sound"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_bool" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "boolean"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_int" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "integer"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_model" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "model"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_color" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "color"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && ( string_equal( first.c_str(), "editor_material" ) || string_equal( first.c_str(), "editor_mat" ) ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "shader"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( string_equal( key, "inherit" ) ) { entityClass.inheritanceResolved = false; ASSERT_MESSAGE( entityClass.m_parent.empty(), "only one 'inherit' supported per entityDef" ); const char* token; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) ); entityClass.m_parent.push_back( token ); } // begin quake4-specific keys else if ( string_equal( key, "editor_targetonsel" ) ) { //const char* value = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } else if ( string_equal( key, "editor_menu" ) ) { //const char* value = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } else if ( string_equal( key, "editor_ignore" ) ) { //const char* value = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } // end quake4-specific keys // begin ignore prey (unknown/unused?) entity keys else if ( string_equal( key, "editor_light" ) || string_equal( key, "editor_def def_debrisspawner" ) || string_equal( key, "editor_def def_drop" ) || string_equal( key, "editor_def def_guihand" ) || string_equal( key, "editor_def def_mine" ) ) { //const char* value = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } // end ignore prey entity keys else { CopiedString tmp( key ); if ( string_equal_n( key, "editor_", 7 ) ) { globalErrorStream() << "unsupported editor key " << makeQuoted( key ) ; } EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, key ).second; attribute.m_type = "string"; const char* value; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) ); if ( string_equal( value, "}" ) ) { // hack for quake4 powerups.def bug globalErrorStream() << "entityDef " << makeQuoted( entityClass.m_name.c_str() ) << " key " << makeQuoted( tmp.c_str() ) << " has no value\n"; break; } else { attribute.m_value = value; } } tokeniser.nextLine(); } entityClass.m_comments = usage.c_str(); if ( string_equal( entityClass.m_name.c_str(), "light" ) ) { { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "light_radius" ).second; attribute.m_type = "vector3"; attribute.m_value = "300 300 300"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "light_center" ).second; attribute.m_type = "vector3"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "noshadows" ).second; attribute.m_type = "boolean"; attribute.m_value = "0"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "nospecular" ).second; attribute.m_type = "boolean"; attribute.m_value = "0"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "nodiffuse" ).second; attribute.m_type = "boolean"; attribute.m_value = "0"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "falloff" ).second; attribute.m_type = "real"; } } return true; }
const Toggle& GlobalToggles_find( const char* name ){ Toggles::iterator i = g_toggles.find( name ); ASSERT_MESSAGE( i != g_toggles.end(), "failed to lookup toggle " << makeQuoted( name ) ); return ( *i ).second; }
~ModelResource() { if(realised()) { unrealise(); } ASSERT_MESSAGE(!realised(), "ModelResource::~ModelResource: resource reference still realised: " << makeQuoted(m_name.c_str())); }