ETHEntityProperties::ETHEntityProperties(const str_type::string& filePath, const Platform::FileManagerPtr& fileManager) { ETHEntityMaterial::Reset(); Reset(); TiXmlDocument doc(filePath); str_type::string content; fileManager->GetUTF16FileString(filePath, content); if (!doc.LoadFile(content, TIXML_ENCODING_LEGACY)) { ETH_STREAM_DECL(ss) << GS_L("Couldn't load file: ") << filePath; ETHResourceProvider::Log(ss.str(), Platform::Logger::ERROR); return; } TiXmlHandle hDoc(&doc); TiXmlHandle hRoot(0); TiXmlElement *pElem = hDoc.FirstChildElement().Element(); if (!pElem) { ETH_STREAM_DECL(ss) << GS_L("The current file seems to be invalid: ") << filePath; ETHResourceProvider::Log(ss.str(), Platform::Logger::ERROR); return; } hRoot = TiXmlHandle(pElem); entityName = Platform::GetFileName(filePath); if (ReadFromXMLFile(hRoot.FirstChildElement().Element())) { successfullyLoaded = true; } }
bool ETHParticleSystem::ReadFromFile(const str_type::string& fileName, const Platform::FileManagerPtr& fileManager) { TiXmlDocument doc(fileName); str_type::string content; fileManager->GetUTF16FileString(fileName, content); if (!doc.LoadFile(content, TIXML_ENCODING_LEGACY)) return false; TiXmlHandle hDoc(&doc); TiXmlHandle hRoot(0); TiXmlElement *pElem = hDoc.FirstChildElement().Element(); if (!pElem) return false; hRoot = TiXmlHandle(pElem); return ReadFromXMLFile(hRoot.FirstChildElement().Element()); }
bool ETHScene::LoadFromFile(const str_type::string& fileName) { Platform::FileManagerPtr fileManager = m_provider->GetVideo()->GetFileManager(); // load the scene from a file { Platform::FileBuffer file; fileManager->GetFileBuffer(fileName, file); if (!file) { ETH_STREAM_DECL(ss) << GS_L("ETHScene::Open: file not found (") << fileName << GS_L(")"); m_provider->Log(ss.str(), Platform::FileLogger::ERROR); return false; } } m_minSceneHeight = 0.0f; m_maxSceneHeight = m_provider->GetVideo()->GetScreenSizeF().y; // Read the header and check if the file is valid TiXmlDocument doc(fileName); str_type::string content; fileManager->GetUTF16FileString(fileName, content); if (!doc.LoadFile(content, TIXML_ENCODING_LEGACY)) { ETH_STREAM_DECL(ss) << GS_L("ETHScene::Open: file found, but parsing failed (") << fileName << GS_L(")"); m_provider->Log(ss.str(), Platform::FileLogger::ERROR); return false; } TiXmlHandle hDoc(&doc); TiXmlHandle hRoot(0); TiXmlElement *pElement = hDoc.FirstChildElement().Element(); if (!pElement) { ETH_STREAM_DECL(ss) << GS_L("ETHScene::Open: couldn't find root element (") << fileName << GS_L(")"); m_provider->Log(ss.str(), Platform::FileLogger::ERROR); return false; } return ReadFromXMLFile(pElement); }