void flush() { if(realised()) { ModelCache_flush(m_path.c_str(), m_name.c_str()); } }
void setNode(scene::Node* node) { ModelCache::iterator i = ModelCache_find(m_path.c_str(), m_name.c_str()); if(i != g_modelCache.end()) { (*i).value = NodeSmartReference(*node); } setModel(NodeSmartReference(*node)); connectMap(); }
void realise() { ASSERT_MESSAGE(m_unrealised != 0, "ModelResource::realise: already realised"); if(--m_unrealised == 0) { m_path = rootPath(m_originalName.c_str()); m_name = path_make_relative(m_originalName.c_str(), m_path.c_str()); //globalOutputStream() << "ModelResource::realise: " << m_path.c_str() << m_name.c_str() << "\n"; m_observers.realise(); } }
ModelResource(const CopiedString& name) : m_model(g_nullModel), m_originalName(name), m_type(path_get_extension(name.c_str())), m_loader(0), m_modified(0), m_unrealised(1) { m_loader = ModelLoader_forType(m_type.c_str()); if(g_realised) { realise(); } }
void evaluate(StringBuffer& output) { StringBuffer variable; bool in_variable = false; for(const char* i = m_string.c_str(); *i != '\0'; ++i) { if(!in_variable) { switch(*i) { case '[': in_variable = true; break; default: output.push_back(*i); break; } } else { switch(*i) { case ']': in_variable = false; output.push_string(build_get_variable(variable.c_str())); variable.clear(); break; default: variable.push_back(*i); break; } } } }
bool save() { if(!mapSaved()) { 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())) { mapSave(); return true; } } } return false; }
void Scene_copyClosestFaceTexture(SelectionTest& test) { CopiedString shader; if(Scene_BrushGetClosestFaceTexture(GlobalSceneGraph(), test, shader, g_faceTextureClipboard.m_projection, g_faceTextureClipboard.m_flags)) { TextureBrowser_SetSelectedShader(g_TextureBrowser, shader.c_str()); } }
virtual ArchiveTextFile* openTextFile(const char* name) { files_t::iterator i = m_files.find(name); if(i != m_files.end()) { return StoredArchiveTextFile::create(name, m_name.c_str(), i->second.m_position, i->second.m_stream_size); } return 0; }
virtual ArchiveTextFile* openTextFile(const char* name) { UnixPath path(m_root.c_str()); path.push_filename(name); DirectoryArchiveTextFile* file = new DirectoryArchiveTextFile(name, path.c_str()); if(!file->failed()) { return file; } file->release(); return 0; }
virtual void forEachFile(VisitorFunc visitor, const char* root) { std::vector<Directory*> dirs; UnixPath path(m_root.c_str()); path.push(root); dirs.push_back(directory_open(path.c_str())); while(!dirs.empty() && directory_good(dirs.back())) { const char* name = directory_read_and_increment(dirs.back()); if(name == 0) { directory_close(dirs.back()); dirs.pop_back(); path.pop(); } else if(!string_equal(name, ".") && !string_equal(name, "..")) { path.push_filename(name); bool is_directory = file_is_directory(path.c_str()); if(!is_directory) visitor.file(path_make_relative(path.c_str(), m_root.c_str())); path.pop(); if(is_directory) { path.push(name); if(!visitor.directory(path_make_relative(path.c_str(), m_root.c_str()), dirs.size())) dirs.push_back(directory_open(path.c_str())); else path.pop(); } } } }
void loadCached() { if(g_modelCache_enabled) { // cache lookup ModelCache::iterator i = ModelCache_find(m_path.c_str(), m_name.c_str()); if(i == g_modelCache.end()) { i = ModelCache_insert( m_path.c_str(), m_name.c_str(), Model_load(m_loader, m_path.c_str(), m_name.c_str(), m_type.c_str()) ); } setModel((*i).value); } else { setModel(Model_load(m_loader, m_path.c_str(), m_name.c_str(), m_type.c_str())); } }
const char *getLastModelFolderPath(){ if ( g_strLastModelFolder.empty() ) { GlobalPreferenceSystem().registerPreference( "LastModelFolder", make_property_string( g_strLastModelFolder ) ); if ( g_strLastModelFolder.empty() ) { StringOutputStream buffer( 1024 ); buffer << g_qeglobals.m_userGamePath.c_str() << "models/"; if ( !file_readable( buffer.c_str() ) ) { // just go to fsmain buffer.clear(); buffer << g_qeglobals.m_userGamePath.c_str() << "/"; } g_strLastModelFolder = buffer.c_str(); } } return g_strLastModelFolder.c_str(); }
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 setIsModel(bool newValue) { if(newValue && !m_isModel) { detachTraverse(); attachModel(); m_nameKeys.setKeyIsName(Static<KeyIsName>::instance().m_keyIsName); m_model.modelChanged(m_modelKey.c_str()); } else if(!newValue && m_isModel) { detachModel(); attachTraverse(); m_nameKeys.setKeyIsName(keyIsNameDoom3Doom3Group); } m_isModel = newValue; updateTransform(); }
XMLElementParser& pushElement(const XMLElement& element) { if(string_equal(element.name(), m_elementName.c_str())) { Version dataVersion(version_parse(element.attribute("version"))); if(version_compatible(m_version, dataVersion)) { m_compatible = true; return m_parser; } else { return m_skip; } } else { //ERROR_MESSAGE("parse error: invalid element \"" << element.name() << "\""); return *this; } }
virtual bool containsFile(const char* name) { UnixPath path(m_root.c_str()); path.push_filename(name); return file_readable(path.c_str()); }
const char* c_str() const { return m_string.c_str(); }
const char* CPluginSlot::getMenuName() { return m_menu_name.c_str(); }
~ModelResource() { if(realised()) { unrealise(); } ASSERT_MESSAGE(!realised(), "ModelResource::~ModelResource: resource reference still realised: " << makeQuoted(m_name.c_str())); }
const char* getName() { return m_extension.c_str(); }
hash_type operator()(const CopiedString& path) const { return path_hash(path.c_str()); }
bool operator()(const CopiedString& path, const CopiedString& other) const { return path_equal(path.c_str(), other.c_str()); }
void updateIsModel() { setIsModel(!string_empty(m_modelKey.c_str()) && !string_equal(m_modelKey.c_str(), m_name.c_str())); }
std::time_t modified() const { StringOutputStream fullpath(256); fullpath << m_path.c_str() << m_name.c_str(); return file_modified(fullpath.c_str()); }
ModelPicoAPI* constructAPI(ModelPicoDependencies& dependencies) { return new ModelPicoAPI(m_extension.c_str(), m_module); }
bool isModified() const { return ((!string_empty(m_path.c_str()) // had or has an absolute path && m_modified != modified()) // AND disk timestamp changed || !path_equal(rootPath(m_originalName.c_str()), m_path.c_str())); // OR absolute vfs-root changed }
bool operator()(const CopiedString& self, const CopiedString& other) const { return string_compare_nocase_upper(self.c_str(), other.c_str()) > 0; }