X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FInterpreter.h;h=8d5c1e31aadf7ca70ad042501baa2317d074fbd3;hb=401785f03e9d56fb28d9e29cdb74dbbf5664c342;hp=2748c63bdadfa44e80539fca52d9517cb4636822;hpb=ebd72885587d606677e35129e418dbe6321082d1;p=l2e.git diff --git a/src/loader/Interpreter.h b/src/loader/Interpreter.h index 2748c63..8d5c1e3 100644 --- a/src/loader/Interpreter.h +++ b/src/loader/Interpreter.h @@ -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 -#include #include #include #include @@ -21,11 +22,24 @@ 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,54 +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; + }; -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 &PostponedDefinitions() { return postponedDefinitions; } 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 &); + 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 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 parsedDefinitions; + + bool CanLink(const Value &) const; + void Postpone(int type, int id, std::ptrdiff_t offset, const std::string &identifier, int linkedType); + std::vector postponedDefinitions; + + std::map imageCache; - std::map animations; - std::map heroes; - std::map monsters; - std::map numbers; - std::map sprites; + std::map > values; };