Cat::Cat(const Filesystem::AbsolutePath & filename): ObjectNonAttack( 0, 0 ), state( IDLE1 ){ path = filename; setMaxHealth( 1 ); setHealth( 1 ); TokenReader tr; try{ Token * head; head = tr.readTokenFromFile(path.path()); if ( *head != "cat" ){ throw LoadException(__FILE__, __LINE__, "File does not begin with 'Cat'" ); } while ( head->hasTokens() ){ Token * next = head->readToken(); if ( *next == "animation" ){ Animation * animation = new Animation( next, 0 ); animations[ animation->getName() ] = animation; } } if ( animations.size() == 0 ){ throw LoadException(__FILE__, __LINE__, "No animation given" ); } } catch (const TokenException & ex){ // Global::debug(0) << "Could not read "<< filename.path() <<": "<< ex.getReason()<<endl; throw LoadException(__FILE__, __LINE__, ex, "Could not open file " + filename.path()); } current_animation = animations[ "idle1" ]; meow = Sound(Storage::instance().find(Filesystem::RelativePath("misc/cat/meow.wav")).path()); }
static void parseGridList(Util::ReferenceCount<Gui::GridSelect> list, std::map<int, unsigned int> & cursorLocations, const Token * token){ if ( *token != "grid-list" ){ throw LoadException(__FILE__, __LINE__, "Not a Grid Select List"); } TokenView view = token->view(); while (view.hasMore()){ try{ const Token * tok; view >> tok; int x=0,y=0; std::string layout; if (parseBaseList(list, cursorLocations, tok)){ } else if (tok->match("grid-size", x, y)){ list->setGridSize(x, y); } else if (tok->match("layout", layout)){ if (layout == "static"){ list->setLayout(Gui::GridSelect::Static); } else if (layout == "infinite-vertical"){ list->setLayout(Gui::GridSelect::InfiniteVertical); } else if (layout == "infinite-horizontal"){ list->setLayout(Gui::GridSelect::InfiniteHorizontal); } } else { Global::debug(0) << "Unknown Grid List property: " << tok->getName() << std::endl; } } catch ( const TokenException & ex ) { throw LoadException(__FILE__, __LINE__, ex, "Grid Select parse error"); } } }
void TrussMaterialLibrary::loadFromXML ( const QDomElement& projElem ) /*throw (LoadException)*/ { XMLSerializableObject::loadFromXML( projElem ); clean(); /** * Create materials ********************/ QDomNodeList trussMaterials = projElem.elementsByTagName( "TrussMaterial" ); for ( int i = 0; i < trussMaterials.count(); ++i ) { QDomNode material = trussMaterials.item( i ); if ( ! material.isElement() ) throw LoadException(); QDomElement materialElem = material.toElement(); TrussMaterial& newMaterial = createMaterial( 0, 0, 0, "" ); newMaterial.loadFromXML( materialElem ); } /** * Set selected material ************************/ if ( ! projElem.hasAttribute( "selectedMaterial" ) ) throw LoadException(); QString mUUID = projElem.attribute( "selectedMaterial" ); TrussMaterial* m = getMaterial( mUUID ); if ( m ) selectMaterial( *m ); }
static void parseSimpleList(Util::ReferenceCount<Gui::SimpleSelect> list, std::map<int, unsigned int> & cursorLocations, const Token * token){ if ( *token != "simple-list" ){ throw LoadException(__FILE__, __LINE__, "Not a Simple Select List"); } TokenView view = token->view(); while (view.hasMore()){ try{ const Token * tok; view >> tok; int offset=0; std::string layout; int viewable = 0; if (parseBaseList(list, cursorLocations, tok)){ } else if (tok->match("viewable", viewable)){ list->setViewable(viewable); } else if (tok->match("layout", layout)){ if (layout == "horizontal"){ list->setLayout(Gui::SimpleSelect::Horizontal); } else if (layout == "vertical"){ list->setLayout(Gui::SimpleSelect::Vertical); } } else if (tok->match("scroll-offset", offset)){ list->setScrollOffset(offset); } else { Global::debug(0) << "Unknown Simple List property: " << tok->getName() << std::endl; } } catch ( const TokenException & ex ) { throw LoadException(__FILE__, __LINE__, ex, "Simple Select parse error"); } } }
/** * Load a few moves. * @throws LoadException for bad load */ void LevelLoading::nextLoadAction() { if (m_paused) { return; } if (m_loadedMoves.empty()) { m_access->room()->beginFall(false); m_access->room()->finishRound(false); } else { for (int i = 0; i < m_loadSpeed && !m_loadedMoves.empty(); ++i) { try { char symbol = m_loadedMoves[0]; m_loadedMoves.erase(0, 1); m_access->room()->loadMove(symbol); } catch (LoadException &e) { throw LoadException(ExInfo(e.info()) .addInfo("remain", m_loadedMoves)); } } } }
void Object::setFile( const std::string &filename, const std::string &groupname ) { if (!edje_object_file_set( o, filename.c_str (), groupname.c_str () )) { throw LoadException (filename, groupname, edje_object_load_error_get(o)); } }
static Util::ReferenceCount<playerInfo> getPlayer(const Filesystem::AbsolutePath & file){ Global::debug(1, PAINTOWN_DEBUG_CONTEXT) << "Checking " << file.path() << std::endl; if (Storage::instance().exists(file)){ Global::debug(1, PAINTOWN_DEBUG_CONTEXT) << "Adding " << file.path() << std::endl; return Util::ReferenceCount<playerInfo>(new playerInfo(Util::ReferenceCount<Paintown::DisplayCharacter>(new Paintown::DisplayCharacter(file)), file)); } throw LoadException(__FILE__, __LINE__, "File '" + file.path() + "' not found."); }
void Variable::load(DataStream &stream, Variable *&value) { try { u8 t = 0; stream >> t; switch (t) { case kVT_null: value = Variable_null::instance(); value->grab(); return ; case kVT_bool: value = vnnew Variable_bool(); break; case kVT_int32: value = vnnew Variable_int32(); break; case kVT_int64: value = vnnew Variable_int64(); break; case kVT_float: value = vnnew Variable_float32(); break; case kVT_double: value = vnnew Variable_float64(); break; case kVT_string: value = vnnew Variable_string(); break; case kVT_reference: value = vnnew Variable_reference(); break; case kVT_array: value = vnnew Variable_array(); break; case kVT_object: value = vnnew Variable_object(); break; default: value = 0; throw LoadException(); } value->_load(stream); } catch (DataStream::Exception &e) { VN_SAFE_DROP(value); throw e; } }
void TrussMaterial::loadFromXML ( const QDomElement& materialElem ) /*throw (LoadException)*/ { XMLSerializableObject::loadFromXML( materialElem ); /** * Set name **************/ if ( ! materialElem.hasAttribute( "name" ) ) throw LoadException(); QString name = materialElem.attribute( "name" ); setMaterialName( name ); /** * Set working stress ***************************/ if ( ! materialElem.hasAttribute( "workingStress" ) ) throw LoadException(); bool ok; double stress = materialElem.attribute( "workingStress" ).toDouble( &ok ); if ( !ok ) throw LoadException(); setWorkingStress( stress ); /** * Set elasticity module ***************************/ if ( ! materialElem.hasAttribute( "elasticityModule" ) ) throw LoadException(); double elast = materialElem.attribute( "elasticityModule" ).toDouble( &ok ); if ( !ok ) throw LoadException(); setElasticityModule( elast ); /** * Set density ******************/ if ( ! materialElem.hasAttribute( "density" ) ) throw LoadException(); double dens = materialElem.attribute( "density" ).toDouble( &ok ); if ( !ok ) throw LoadException(); setDensity( dens ); }
void importObject(const Token * token){ if ( *token != "object-script" ){ throw LoadException(__FILE__, __LINE__, "Not an object script."); } std::string module, function; bool hasPosition = false; int x=0, y=0; std::vector<const Token *> animations; TokenView view = token->view(); while (view.hasMore()){ try{ const Token * tok; view >> tok; if (*tok == "module"){ tok->view() >> module; } else if (*tok == "function"){ tok->view() >> function; } else if (*tok == "position"){
void Core::loadAssets(std::string fileName) { LOG(info) << "Core.loadAssets()"; Assimp::Importer importer; const aiScene* scene = importer.ReadFile(fileName, aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType); /*| aiProcess_PreTransformVertices);*/ if (!scene) { throw LoadException(importer.GetErrorString()); } this->scene = new Scene(scene); if (this->scene == nullptr) throw Exception("Fail to create instance of Scene."); renderer->setScene(this->scene); LOG(info) << "Core.loadAssets() done"; }
LoadException::LoadException(){ LoadException(""); }