X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FInterpreter.h;h=3f53b3f492fdb6f6e196cc0cff54ea094acb2940;hb=dbf125bd2ef4f68af92aa0872e8d8a6abaf4ee00;hp=9ba5924a8ab85173e4967c167cc6a62ac6139149;hpb=05112fcfdbd0c452c80b6786bf6121d6f63b852a;p=l2e.git diff --git a/src/loader/Interpreter.h b/src/loader/Interpreter.h index 9ba5924..3f53b3f 100644 --- a/src/loader/Interpreter.h +++ b/src/loader/Interpreter.h @@ -12,7 +12,6 @@ #include "../graphics/ComplexAnimation.h" #include -#include #include #include #include @@ -21,6 +20,7 @@ namespace battle { class Hero; class Monster; + class PartyLayout; class Stats; } @@ -47,7 +47,7 @@ public: public: Interpreter(const ParsedSource &source) : source(source) { } - ~Interpreter() { } + ~Interpreter(); private: Interpreter(const Interpreter &); Interpreter &operator =(const Interpreter &); @@ -55,39 +55,96 @@ private: public: void ReadSource(); +public: + graphics::Animation *GetAnimation(const std::string &name); + bool GetBoolean(const std::string &name) const; + battle::Hero *GetHero(const std::string &name); + battle::Monster *GetMonster(const std::string &name); + int GetNumber(const std::string &name) const; + battle::PartyLayout *GetPartyLayout(const std::string &name); + graphics::Sprite *GetSprite(const std::string &name); + const char *GetString(const std::string &name) const; + geometry::Vector GetVector(const std::string &name) const; + +public: + const std::vector &Booleans() const { return booleans; } + const std::vector &ComplexAnimations() const { return complexAnimations; } + const std::vector &Heroes() const { return heroes; } + const std::vector &Images() const { return images; } + const std::vector &Monsters() const { return monsters; } + const std::vector &Numbers() const { return numbers; } + const std::vector &PartyLayouts() const { return partyLayouts; } + const std::vector &SimpleAnimations() const { return simpleAnimations; } + const std::vector &Sprites() const { return sprites; } + const std::vector &Strings() const { return strings; } + const std::vector > &Vectors() const { return vectors; } + private: void ReadDefinition(const Definition &); void ReadLiteral(const Definition &); void ReadObject(const Definition &); graphics::Animation *GetAnimation(const Value &); - const std::vector &GetValueArray(const Value &); - const std::vector &GetPropertyListArray(const Value &); bool GetBoolean(const Value &); SDL_Surface *GetImage(const Value &); int GetNumber(const Value &); + battle::PartyLayout *GetPartyLayout(const Value &); const PropertyList *GetPropertyList(const Value &); + const std::vector &GetPropertyListArray(const Value &); graphics::Sprite *GetSprite(const Value &); const char *GetString(const Value &); + const std::vector &GetValueArray(const Value &); geometry::Vector GetVector(const Value &); void ReadComplexAnimation(graphics::ComplexAnimation &, const PropertyList &); void ReadComplexAnimationFrame(graphics::ComplexAnimation::FrameProp &, const PropertyList &); void ReadHero(battle::Hero &, const PropertyList &); void ReadMonster(battle::Monster &, const PropertyList &); + void ReadPartyLayout(battle::PartyLayout &, const PropertyList &); void ReadSimpleAnimation(graphics::SimpleAnimation &, const PropertyList &); void ReadSprite(graphics::Sprite &, const PropertyList &); void ReadStats(battle::Stats &, const PropertyList &); private: const ParsedSource &source; - std::set parsedDefinitions; - - std::map animations; - std::map heroes; - std::map monsters; - std::map numbers; - std::map sprites; + enum Type { + BOOLEAN, + COMPLEX_ANIMATION, + HERO, + IMAGE, + MONSTER, + NUMBER, + PARTY_LAYOUT, + PROPERTY_LIST_ARRAY, + SIMPLE_ANIMATION, + SPRITE, + STRING, + VECTOR, + VALUE_ARRAY, + }; + struct ParsedDefinition { + ParsedDefinition(const Definition *dfn, Type type, int index) + : dfn(dfn), type(type), index(index) { } + const Definition *dfn; + Type type; + int index; + }; + std::map parsedDefinitions; + + std::vector booleans; + std::vector complexAnimations; + std::vector heroes; + std::vector images; + std::vector monsters; + std::vector numbers; + std::vector partyLayouts; + std::vector propertyLists; + std::vector > propertyListArrays; + std::vector simpleAnimations; + std::vector sprites; + std::vector strings; + std::vector > valueArrays; + std::vector > vectors; };