}
} else {
char *src(reinterpret_cast<char *>(GetObject(fd.TypeId(), *i->second)));
+ if (fd.TypeId() == TypeDescription::GetTypeId("Image")) {
+ src = reinterpret_cast<char *>(GetImage(src));
+ }
if (fd.IsReferenced()) {
std::memcpy(dest, &src, sizeof(char *));
} else {
}
+SDL_Surface *Interpreter::GetImage(const string &path) {
+ map<string, SDL_Surface *>::const_iterator result(imageCache.find(path));
+ if (result != imageCache.end()) {
+ return result->second;
+ } else {
+ SDL_Surface *image(IMG_Load(path.c_str()));
+ imageCache.insert(make_pair(path, image));
+ return image;
+ }
+}
+
+
bool Interpreter::CanLink(const Value &v) const {
return v.IsLiteral() || source.IsDefined(v.GetIdentifier());
}
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;
struct ParsedDefinition {