Exemplo n.º 1
0
 void flush()
 {
   if(realised())
   {
     ModelCache_flush(m_path.c_str(), m_name.c_str());
   }
 }
Exemplo n.º 2
0
  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();
  }
Exemplo n.º 3
0
  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();
    }
  }
Exemplo n.º 4
0
  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();
    }
  }
Exemplo n.º 5
0
 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;
       }
     }
   }
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
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());
  }
}
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
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;
 }
Exemplo n.º 10
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();
        }
      }
    }
  }
Exemplo n.º 11
0
  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()));
    }
  }
Exemplo n.º 12
0
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();
}
Exemplo n.º 13
0
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();
    }
  }
}
Exemplo n.º 14
0
  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();
  }
Exemplo n.º 15
0
 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;
   }
 }
Exemplo n.º 16
0
 virtual bool containsFile(const char* name)
 {
   UnixPath path(m_root.c_str());
   path.push_filename(name);
   return file_readable(path.c_str());
 }
Exemplo n.º 17
0
 const char* c_str() const
 {
   return m_string.c_str();
 }
Exemplo n.º 18
0
const char* CPluginSlot::getMenuName()
{
  return m_menu_name.c_str();
}
Exemplo n.º 19
0
 ~ModelResource()
 {
   if(realised())
   {
     unrealise();
   }
   ASSERT_MESSAGE(!realised(), "ModelResource::~ModelResource: resource reference still realised: " << makeQuoted(m_name.c_str()));
 }
Exemplo n.º 20
0
 const char* getName()
 {
   return m_extension.c_str();
 }
Exemplo n.º 21
0
 hash_type operator()(const CopiedString& path) const
 {
   return path_hash(path.c_str());
 }
Exemplo n.º 22
0
 bool operator()(const CopiedString& path, const CopiedString& other) const
 {
   return path_equal(path.c_str(), other.c_str());
 }
Exemplo n.º 23
0
 void updateIsModel()
 {
   setIsModel(!string_empty(m_modelKey.c_str()) && !string_equal(m_modelKey.c_str(), m_name.c_str()));
 }
Exemplo n.º 24
0
 std::time_t modified() const
 {
   StringOutputStream fullpath(256);
   fullpath << m_path.c_str() << m_name.c_str();
   return file_modified(fullpath.c_str());
 }
Exemplo n.º 25
0
 ModelPicoAPI* constructAPI(ModelPicoDependencies& dependencies)
 {
   return new ModelPicoAPI(m_extension.c_str(), m_module);
 }
Exemplo n.º 26
0
 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
 }
Exemplo n.º 27
0
 bool operator()(const CopiedString& self, const CopiedString& other) const
 {
   return string_compare_nocase_upper(self.c_str(), other.c_str()) > 0;
 }