]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Interpreter.h
split reading of literal from reading its defined name
[l2e.git] / src / loader / Interpreter.h
index 9ba5924a8ab85173e4967c167cc6a62ac6139149..8d5c1e31aadf7ca70ad042501baa2317d074fbd3 100644 (file)
@@ -8,11 +8,12 @@
 #ifndef LOADER_INTERPRETER_H_
 #define LOADER_INTERPRETER_H_
 
+#include "TypeDescription.h"
 #include "../geometry/Vector.h"
+#include "../graphics/Color.h"
 #include "../graphics/ComplexAnimation.h"
 
 #include <map>
-#include <set>
 #include <stdexcept>
 #include <string>
 #include <vector>
 namespace battle {
        class Hero;
        class Monster;
+       class PartyLayout;
+       struct Resources;
        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;
 }
@@ -33,6 +47,7 @@ namespace graphics {
 namespace loader {
 
 class Definition;
+class Literal;
 class ParsedSource;
 class PropertyList;
 class Value;
@@ -47,47 +62,55 @@ public:
 
 public:
        Interpreter(const ParsedSource &source) : source(source) { }
-       ~Interpreter() { }
+       ~Interpreter();
 private:
        Interpreter(const Interpreter &);
        Interpreter &operator =(const Interpreter &);
 
 public:
        void ReadSource();
+       void *GetObject(int typeId, const std::string &name);
+
+       static void CreateTypeDescriptions();
+       struct PostponedDefinition {
+               PostponedDefinition(int type, int id, std::ptrdiff_t offset, const char *identifier, int linkedType)
+               : type(type), id(id), offset(offset), identifier(identifier), linkedType(linkedType) { }
+               int type;
+               int id;
+               std::ptrdiff_t offset;
+               const char *identifier;
+               int linkedType;
+       };
+
+       const std::vector<PostponedDefinition> &PostponedDefinitions() { return postponedDefinitions; }
 
 private:
        void ReadDefinition(const Definition &);
        void ReadLiteral(const Definition &);
        void ReadObject(const Definition &);
 
-       graphics::Animation *GetAnimation(const Value &);
-       const std::vector<Value *> &GetValueArray(const Value &);
-       const std::vector<PropertyList *> &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<int> 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 &);
+       void ReadLiteral(int typeId, int id, char *dest, const Literal &);
+       void *GetObject(int typeId, const Value &value);
+       void ReadObject(int typeId, int id, char *dest, const PropertyList &);
 
 private:
        const ParsedSource &source;
-       std::set<std::string> parsedDefinitions;
+       struct ParsedDefinition {
+               ParsedDefinition(const Definition *dfn, int type, int id)
+               : dfn(dfn), type(type), id(id) { }
+               const Definition *dfn;
+               int type;
+               int id;
+       };
+       std::map<std::string, ParsedDefinition> parsedDefinitions;
+
+       bool CanLink(const Value &) const;
+       void Postpone(int type, int id, std::ptrdiff_t offset, const std::string &identifier, int linkedType);
+       std::vector<PostponedDefinition> postponedDefinitions;
+
+       std::map<std::string, SDL_Surface *> imageCache;
 
-       std::map<std::string, graphics::Animation *> animations;
-       std::map<std::string, battle::Hero *> heroes;
-       std::map<std::string, battle::Monster *> monsters;
-       std::map<std::string, int> numbers;
-       std::map<std::string, graphics::Sprite *> sprites;
+       std::map<int, std::vector<void *> > values;
 
 };