#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 <stdexcept>
#include <string>
#include <vector>
+#include <SDL.h>
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;
class Interpreter {
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 &);
- void ReadMonster(battle::Monster &, 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 &);
+
+ SDL_Surface *GetImage(const std::string &);
private:
const ParsedSource &source;
- std::vector<battle::Monster> monsters;
+ 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<int, std::vector<void *> > values;
};