X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FInterpreter.h;h=8d5c1e31aadf7ca70ad042501baa2317d074fbd3;hb=401785f03e9d56fb28d9e29cdb74dbbf5664c342;hp=aea5fbe85712433c963cf5f1aeb8016f59fdbc0b;hpb=8cd1fa19b3697a78579ae254933bdcf7345ba9ff;p=l2e.git diff --git a/src/loader/Interpreter.h b/src/loader/Interpreter.h index aea5fbe..8d5c1e3 100644 --- a/src/loader/Interpreter.h +++ b/src/loader/Interpreter.h @@ -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 @@ -20,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; } @@ -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 &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; - 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 parsedDefinitions; - std::vector animations; - std::vector heroes; - std::vector images; - std::vector monsters; - std::vector numbers; - std::vector sprites; + 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 > values; };