#include "../graphics/Font.h"
#include "../graphics/Frame.h"
#include "../graphics/Gauge.h"
+#include "../graphics/Menu.h"
#include "../graphics/SimpleAnimation.h"
#include "../graphics/Sprite.h"
for (vector<Item *>::const_iterator i(items.begin()), end(items.end()); i != end; ++i) {
delete *i;
}
+ for (vector<graphics::MenuProperties *>::const_iterator i(menuProperties.begin()), end(menuProperties.end()); i != end; ++i) {
+ delete *i;
+ }
for (vector<Monster *>::const_iterator i(monsters.begin()), end(monsters.end()); i != end; ++i) {
delete *i;
}
}
}
+graphics::MenuProperties *Interpreter::GetMenuProperties(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == MENU_PROPERTIES) {
+ return menuProperties[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to MenuProperties");
+ }
+ } else {
+ throw Error("access to undefined MenuProperties " + name);
+ }
+}
+
Monster *Interpreter::GetMonster(const std::string &name) {
map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
if (i != parsedDefinitions.end()) {
}
}
+graphics::MenuProperties *Interpreter::GetMenuProperties(const Value &v) {
+ if (v.IsLiteral()) {
+ graphics::MenuProperties *m(new graphics::MenuProperties);
+ ReadMenuProperties(*m, *v.GetLiteral().GetProperties());
+ return m;
+ } else {
+ ReadDefinition(source.GetDefinition(v.GetIdentifier()));
+ return GetMenuProperties(v.GetIdentifier());
+ }
+}
+
+Monster *Interpreter::GetMonster(const Value &v) {
+ if (v.IsLiteral()) {
+ Monster *m(new Monster);
+ ReadMonster(*m, *v.GetLiteral().GetProperties());
+ return m;
+ } else {
+ ReadDefinition(source.GetDefinition(v.GetIdentifier()));
+ return GetMonster(v.GetIdentifier());
+ }
+}
+
int Interpreter::GetNumber(const Value &v) {
if (v.IsLiteral()) {
return v.GetLiteral().GetNumber();
items.push_back(item);
ReadItem(*item, *dfn.GetProperties());
parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, ITEM, index)));
+ } else if (dfn.TypeName() == "MenuProperties") {
+ graphics::MenuProperties *mprops(new graphics::MenuProperties);
+ int index(menuProperties.size());
+ menuProperties.push_back(mprops);
+ ReadMenuProperties(*mprops, *dfn.GetProperties());
+ parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, MENU_PROPERTIES, index)));
} else if (dfn.TypeName() == "Monster") {
Monster *monster(new Monster);
int index(monsters.size());
}
}
+void Interpreter::ReadMenuProperties(graphics::MenuProperties &mprops, const PropertyList &props) {
+ for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
+ if (i->first == "font") {
+ mprops.font = GetFont(*i->second);
+ } else if (i->first == "disabledFont") {
+ mprops.disabledFont = GetFont(*i->second);
+ } else if (i->first == "cursor") {
+ mprops.cursor = GetSprite(*i->second);
+ } else if (i->first == "charsPerEntry") {
+ mprops.charsPerEntry = GetNumber(*i->second);
+ } else if (i->first == "rows") {
+ mprops.rows = GetNumber(*i->second);
+ } else if (i->first == "rowGap") {
+ mprops.rowGap = GetNumber(*i->second);
+ } else if (i->first == "iconSpace") {
+ mprops.iconSpace = GetNumber(*i->second);
+ } else if (i->first == "cols") {
+ mprops.cols = GetNumber(*i->second);
+ } else if (i->first == "colGap") {
+ mprops.colGap = GetNumber(*i->second);
+ } else if (i->first == "delimiter") {
+ mprops.delimiter = *GetString(*i->second);
+ } else if (i->first == "charsPerNumber") {
+ mprops.charsPerNumber = GetNumber(*i->second);
+ } else if (i->first == "charsPerAdditionalText") {
+ mprops.charsPerAdditionalText = GetNumber(*i->second);
+ } else if (i->first == "additionalTextGap") {
+ mprops.additionalTextGap = GetNumber(*i->second);
+ } else {
+ throw Error("unknown MenuProperties property: " + i->first);
+ }
+ }
+}
+
void Interpreter::ReadMonster(Monster &m, const PropertyList &props) {
for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
if (i->first == "name") {
class Font;
class Frame;
class Gauge;
+ struct MenuProperties;
class SimpleAnimation;
class Sprite;
}
battle::Hero *GetHero(const std::string &name);
common::Ikari *GetIkari(const std::string &name);
common::Item *GetItem(const std::string &name);
+ graphics::MenuProperties *GetMenuProperties(const std::string &name);
battle::Monster *GetMonster(const std::string &name);
int GetNumber(const std::string &name) const;
battle::PartyLayout *GetPartyLayout(const std::string &name);
const std::vector<common::Ikari *> &Ikaris() const { return ikaris; }
const std::vector<SDL_Surface *> &Images() const { return images; }
const std::vector<common::Item *> &Items() const { return items; }
+ const std::vector<graphics::MenuProperties *> &MenuProperties() const { return menuProperties; }
const std::vector<battle::Monster *> &Monsters() const { return monsters; }
const std::vector<int> &Numbers() const { return numbers; }
const std::vector<battle::PartyLayout *> &PartyLayouts() const { return partyLayouts; }
common::Ikari *GetIkari(const Value &);
SDL_Surface *GetImage(const Value &);
common::Item *GetItem(const Value &);
+ graphics::MenuProperties *GetMenuProperties(const Value &);
+ battle::Monster *GetMonster(const Value &);
int GetNumber(const Value &);
battle::PartyLayout *GetPartyLayout(const Value &);
const PropertyList *GetPropertyList(const Value &);
void ReadHero(battle::Hero &, const PropertyList &);
void ReadIkari(common::Ikari &, const PropertyList &);
void ReadItem(common::Item &, const PropertyList &);
+ void ReadMenuProperties(graphics::MenuProperties &, const PropertyList &);
void ReadMonster(battle::Monster &, const PropertyList &);
void ReadPartyLayout(battle::PartyLayout &, const PropertyList &);
void ReadSimpleAnimation(graphics::SimpleAnimation &, const PropertyList &);
IKARI,
IMAGE,
ITEM,
+ MENU_PROPERTIES,
MONSTER,
NUMBER,
PARTY_LAYOUT,
std::vector<common::Ikari *> ikaris;
std::vector<SDL_Surface *> images;
std::vector<common::Item *> items;
+ std::vector<graphics::MenuProperties *> menuProperties;
std::vector<battle::Monster *> monsters;
std::vector<int> numbers;
std::vector<battle::PartyLayout *> partyLayouts;
selan.AddSpell(valorSpell);
battleRes.spellMenuHeadline = intp.GetString("spellMenuHeadline");
- battleRes.spellMenuPrototype = Menu<const Spell *>(intp.GetFont("normalFont"), intp.GetFont("disabledFont"), intp.GetSprite("handCursor"), 9, 6, 8, 0, 2, 32, 2, ':');
+ battleRes.spellMenuPrototype = Menu<const Spell *>(*intp.GetMenuProperties("spellMenuPrototype"));
battleRes.weaponMenuIcon = intp.GetSprite("swordIcon");
battleRes.armorMenuIcon = intp.GetSprite("armorIcon");
battleRes.inventory = &inventory;
battleRes.itemMenuHeadline = intp.GetString("itemMenuHeadline");
- battleRes.itemMenuPrototype = Menu<const common::Item *>(intp.GetFont("normalFont"), intp.GetFont("disabledFont"), intp.GetSprite("handCursor"), 15, 6, 8, 16, 1, 32, 2, ':');
+ battleRes.itemMenuPrototype = Menu<const common::Item *>(*intp.GetMenuProperties("itemMenuPrototype"));
maxim.SetWeapon(intp.GetItem("zircoSwordItem"));
maxim.SetArmor(intp.GetItem("zirconArmorItem"));
battleRes.ikariMenuHeadline = intp.GetString("ikariMenuHeadline");
battleRes.noEquipmentText = intp.GetString("noEquipmentText");
- battleRes.ikariMenuPrototype = Menu<const Item *>(intp.GetFont("normalFont"), intp.GetFont("disabledFont"), intp.GetSprite("handCursor"), 12, 6, intp.GetFont("normalFont")->CharHeight() / 2, intp.GetFont("normalFont")->CharWidth(), 1, intp.GetFont("normalFont")->CharWidth() * 2, 0, ':', 12, intp.GetFont("normalFont")->CharWidth());
+ battleRes.ikariMenuPrototype = Menu<const Item *>(*intp.GetMenuProperties("ikariMenuPrototype"));
battleRes.escapeText = intp.GetString("escapeText");
BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
}
export String spellMenuHeadline "Please choose a spell."
+export MenuProperties spellMenuPrototype {
+ font: normalFont,
+ disabledFont: disabledFont,
+ cursor: handCursor,
+ charsPerEntry: 9,
+ rows: 6,
+ rowGap: 8,
+ iconSpace: 0,
+ cols: 2,
+ colGap: 32,
+ charsPerNumber: 2,
+ delimiter: ":"
+}
+
export String itemMenuHeadline "Please choose an item."
+export MenuProperties itemMenuPrototype {
+ font: normalFont,
+ disabledFont: disabledFont,
+ cursor: handCursor,
+ charsPerEntry: 15,
+ rows: 6,
+ rowGap: 8,
+ iconSpace: 16,
+ cols: 1,
+ colGap: 32,
+ charsPerNumber: 2,
+ delimiter: ":"
+}
+
export String ikariMenuHeadline "Please choose equipment."
+export MenuProperties ikariMenuPrototype {
+ font: normalFont,
+ disabledFont: disabledFont,
+ cursor: handCursor,
+ charsPerEntry: 12,
+ rows: 6,
+ rowGap: 8,
+ iconSpace: 16,
+ cols: 1,
+ colGap: 32,
+ charsPerAdditionalText: 12,
+ additionalTextGap: 16
+}
export String noEquipmentText "No equip"
+
export String escapeText "Escapes."