X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FInterpreter.h;h=a32b3cad6d4c8a90cd8401f25c868955c2dd23fc;hb=4634bd26d24a163b7128df7dd5183fcb2cdc8031;hp=c2fc25f84b6a1b6cb09edf1492e046f1e13c50d2;hpb=107b78b720db69ad402c09c0b1d9beb3b88a1952;p=l2e.git diff --git a/src/loader/Interpreter.h b/src/loader/Interpreter.h index c2fc25f..a32b3ca 100644 --- a/src/loader/Interpreter.h +++ b/src/loader/Interpreter.h @@ -8,13 +8,25 @@ #ifndef LOADER_INTERPRETER_H_ #define LOADER_INTERPRETER_H_ +#include "../geometry/Vector.h" +#include "../graphics/ComplexAnimation.h" + #include #include #include #include +#include namespace battle { + class Hero; class Monster; + class Stats; +} + +namespace graphics { + class Animation; + class SimpleAnimation; + class Sprite; } namespace loader { @@ -22,6 +34,7 @@ namespace loader { class Definition; class ParsedSource; class PropertyList; +class Value; class Interpreter { @@ -33,7 +46,7 @@ public: public: Interpreter(const ParsedSource &source) : source(source) { } - ~Interpreter() { } + ~Interpreter(); private: Interpreter(const Interpreter &); Interpreter &operator =(const Interpreter &); @@ -41,15 +54,64 @@ private: public: void ReadSource(); +public: + graphics::Animation *GetAnimation(const std::string &name); + battle::Hero *GetHero(const std::string &name); + battle::Monster *GetMonster(const std::string &name); + int GetNumber(const std::string &name) const; + graphics::Sprite *GetSprite(const std::string &name); + 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 &); + const PropertyList *GetPropertyList(const Value &); + graphics::Sprite *GetSprite(const Value &); + const char *GetString(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 ReadSimpleAnimation(graphics::SimpleAnimation &, const PropertyList &); + void ReadSprite(graphics::Sprite &, const PropertyList &); + void ReadStats(battle::Stats &, const PropertyList &); private: const ParsedSource &source; + enum DynamicType { + ANIMATION, + COMPLEX_ANIMATION, + HERO, + MONSTER, + NUMBER, + SIMPLE_ANIMATION, + SPRITE, + }; + struct ParsedDefinition { + ParsedDefinition(const Definition *dfn, DynamicType type, int index) + : dfn(dfn), type(type), index(index) { } + bool IsCompatible(DynamicType with) const; + const Definition *dfn; + DynamicType type; + int index; + }; + std::map parsedDefinitions; + + std::vector animations; + std::vector heroes; + std::vector images; std::vector monsters; + std::vector numbers; + std::vector sprites; };