]> 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 aea5fbe85712433c963cf5f1aeb8016f59fdbc0b..8d5c1e31aadf7ca70ad042501baa2317d074fbd3 100644 (file)
@@ -8,7 +8,9 @@
 #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>
 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;
 }
@@ -32,6 +47,7 @@ namespace graphics {
 namespace loader {
 
 class Definition;
+class Literal;
 class ParsedSource;
 class PropertyList;
 class Value;
@@ -53,65 +69,48 @@ private:
 
 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;
+       };
 
-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);
+       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;
-       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;
+               ParsedDefinition(const Definition *dfn, int type, int id)
+               : dfn(dfn), type(type), id(id) { }
                const Definition *dfn;
-               DynamicType type;
-               int index;
+               int type;
+               int id;
        };
        std::map<std::string, ParsedDefinition> parsedDefinitions;
 
-       std::vector<graphics::Animation *> animations;
-       std::vector<battle::Hero *> heroes;
-       std::vector<SDL_Surface *> images;
-       std::vector<battle::Monster *> monsters;
-       std::vector<int> numbers;
-       std::vector<graphics::Sprite *> sprites;
+       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<int, std::vector<void *> > values;
 
 };