X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FInterpreter.h;h=e72d4da202d43a99ae0bf8a1490c49ff7570ffbf;hb=1aa61eca26f5b4a4cb856a39e802f5899548b691;hp=9ba5924a8ab85173e4967c167cc6a62ac6139149;hpb=05112fcfdbd0c452c80b6786bf6121d6f63b852a;p=l2e.git diff --git a/src/loader/Interpreter.h b/src/loader/Interpreter.h index 9ba5924..e72d4da 100644 --- a/src/loader/Interpreter.h +++ b/src/loader/Interpreter.h @@ -9,10 +9,10 @@ #define LOADER_INTERPRETER_H_ #include "../geometry/Vector.h" +#include "../graphics/Color.h" #include "../graphics/ComplexAnimation.h" #include -#include #include #include #include @@ -21,11 +21,23 @@ namespace battle { class Hero; class Monster; + class PartyLayout; class Stats; } +namespace common { + class Ikari; + class Item; + class Spell; + class TargetingMode; +} + namespace graphics { class Animation; + class Font; + class Frame; + class Gauge; + struct MenuProperties; class SimpleAnimation; class Sprite; } @@ -47,7 +59,7 @@ public: public: Interpreter(const ParsedSource &source) : source(source) { } - ~Interpreter() { } + ~Interpreter(); private: Interpreter(const Interpreter &); Interpreter &operator =(const Interpreter &); @@ -55,39 +67,156 @@ private: public: void ReadSource(); +public: + graphics::Animation *GetAnimation(const std::string &name); + bool GetBoolean(const std::string &name) const; + const graphics::Color &GetColor(const std::string &name) const; + graphics::Font *GetFont(const std::string &name); + graphics::Frame *GetFrame(const std::string &name); + graphics::Gauge *GetGauge(const std::string &name); + battle::Hero *GetHero(const std::string &name); + common::Ikari *GetIkari(const std::string &name); + common::Item *GetItem(const std::string &name); + graphics::MenuProperties *GetMenuProperties(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); + const char *GetPath(const std::string &name) const; + common::Spell *GetSpell(const std::string &name); + graphics::Sprite *GetSprite(const std::string &name); + const char *GetString(const std::string &name) const; + common::TargetingMode *GetTargetingMode(const std::string &name); + geometry::Vector GetVector(const std::string &name) const; + +public: + const std::vector &Booleans() const { return booleans; } + const std::vector &Colors() const { return colors; } + const std::vector &ComplexAnimations() const { return complexAnimations; } + const std::vector &Fonts() const { return fonts; } + const std::vector &Frames() const { return frames; } + const std::vector &Gauges() const { return gauges; } + const std::vector &Heroes() const { return heroes; } + const std::vector &Ikaris() const { return ikaris; } + const std::vector &Images() const { return images; } + const std::vector &Items() const { return items; } + const std::vector &MenuProperties() const { return menuProperties; } + 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 &Spells() const { return spells; } + const std::vector &Sprites() const { return sprites; } + const std::vector &Strings() const { return strings; } + const std::vector &TargetingModes() const { return targetingModes; } + 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 &); + graphics::Color GetColor(const Value &); bool GetBoolean(const Value &); + graphics::Font *GetFont(const Value &); + graphics::Frame *GetFrame(const Value &); + graphics::Gauge *GetGauge(const Value &); + battle::Hero *GetHero(const Value &); + common::Ikari *GetIkari(const Value &); SDL_Surface *GetImage(const Value &); + common::Item *GetItem(const Value &); + graphics::MenuProperties *GetMenuProperties(const Value &); + battle::Monster *GetMonster(const Value &); int GetNumber(const Value &); + battle::PartyLayout *GetPartyLayout(const Value &); const PropertyList *GetPropertyList(const Value &); + const std::vector &GetPropertyListArray(const Value &); + const char *GetPath(const Value &); + common::Spell *GetSpell(const Value &); graphics::Sprite *GetSprite(const Value &); const char *GetString(const Value &); + common::TargetingMode *GetTargetingMode(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 ReadFont(graphics::Font &, const PropertyList &); + void ReadFrame(graphics::Frame &, const PropertyList &); + void ReadGauge(graphics::Gauge &, const PropertyList &); void ReadHero(battle::Hero &, const PropertyList &); + void ReadIkari(common::Ikari &, const PropertyList &); + void ReadItem(common::Item &, const PropertyList &); + void ReadMenuProperties(graphics::MenuProperties &, const PropertyList &); void ReadMonster(battle::Monster &, const PropertyList &); + void ReadPartyLayout(battle::PartyLayout &, const PropertyList &); void ReadSimpleAnimation(graphics::SimpleAnimation &, const PropertyList &); + void ReadSpell(common::Spell &, const PropertyList &); void ReadSprite(graphics::Sprite &, const PropertyList &); void ReadStats(battle::Stats &, const PropertyList &); + void ReadTargetingMode(common::TargetingMode &, 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, + COLOR, + COMPLEX_ANIMATION, + FONT, + FRAME, + GAUGE, + HERO, + IKARI, + IMAGE, + ITEM, + MENU_PROPERTIES, + MONSTER, + NUMBER, + PARTY_LAYOUT, + PATH, + PROPERTY_LIST_ARRAY, + SIMPLE_ANIMATION, + SPELL, + SPRITE, + STRING, + TARGETING_MODE, + 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::map imageCache; + + std::vector booleans; + std::vector colors; + std::vector complexAnimations; + std::vector fonts; + std::vector frames; + std::vector gauges; + std::vector heroes; + std::vector ikaris; + std::vector images; + std::vector items; + std::vector menuProperties; + std::vector monsters; + std::vector numbers; + std::vector partyLayouts; + std::vector propertyLists; + std::vector > propertyListArrays; + std::vector simpleAnimations; + std::vector spells; + std::vector sprites; + std::vector strings; + std::vector targetingModes; + std::vector > valueArrays; + std::vector > vectors; };