4 * Created on: Aug 26, 2012
8 #ifndef LOADER_INTERPRETER_H_
9 #define LOADER_INTERPRETER_H_
11 #include "../geometry/Vector.h"
12 #include "../graphics/ComplexAnimation.h"
29 class SimpleAnimation;
43 class Error: public std::runtime_error {
45 Error(const std::string &msg) : std::runtime_error("interpreter error: " + msg) { }
49 Interpreter(const ParsedSource &source) : source(source) { }
52 Interpreter(const Interpreter &);
53 Interpreter &operator =(const Interpreter &);
59 graphics::Animation *GetAnimation(const std::string &name);
60 battle::Hero *GetHero(const std::string &name);
61 battle::Monster *GetMonster(const std::string &name);
62 int GetNumber(const std::string &name) const;
63 graphics::Sprite *GetSprite(const std::string &name);
66 void ReadDefinition(const Definition &);
67 void ReadLiteral(const Definition &);
68 void ReadObject(const Definition &);
70 graphics::Animation *GetAnimation(const Value &);
71 const std::vector<Value *> &GetValueArray(const Value &);
72 const std::vector<PropertyList *> &GetPropertyListArray(const Value &);
73 bool GetBoolean(const Value &);
74 SDL_Surface *GetImage(const Value &);
75 int GetNumber(const Value &);
76 const PropertyList *GetPropertyList(const Value &);
77 graphics::Sprite *GetSprite(const Value &);
78 const char *GetString(const Value &);
79 geometry::Vector<int> GetVector(const Value &);
81 void ReadComplexAnimation(graphics::ComplexAnimation &, const PropertyList &);
82 void ReadComplexAnimationFrame(graphics::ComplexAnimation::FrameProp &, const PropertyList &);
83 void ReadHero(battle::Hero &, const PropertyList &);
84 void ReadMonster(battle::Monster &, const PropertyList &);
85 void ReadSimpleAnimation(graphics::SimpleAnimation &, const PropertyList &);
86 void ReadSprite(graphics::Sprite &, const PropertyList &);
87 void ReadStats(battle::Stats &, const PropertyList &);
90 const ParsedSource &source;
91 std::set<std::string> parsedDefinitions;
93 std::map<std::string, graphics::Animation *> animations;
94 std::map<std::string, battle::Hero *> heroes;
95 std::map<std::string, battle::Monster *> monsters;
96 std::map<std::string, int> numbers;
97 std::map<std::string, graphics::Sprite *> sprites;
103 #endif /* LOADER_INTERPRETER_H_ */