#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;
}
namespace loader {
class Definition;
+class Literal;
class ParsedSource;
class PropertyList;
class Value;
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<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;
};