using common::Spell;
using common::TargetingMode;
using graphics::Animation;
+using graphics::Color;
using graphics::Font;
using graphics::Frame;
using graphics::Gauge;
}
}
+const Color &Interpreter::GetColor(const std::string &name) const {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == COLOR) {
+ return colors[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Color");
+ }
+ } else {
+ throw Error("access to undefined Color " + name);
+ }
+}
+
Font *Interpreter::GetFont(const std::string &name) {
map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
if (i != parsedDefinitions.end()) {
parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, BOOLEAN, booleans.size() - 1)));
break;
case Literal::COLOR:
- throw Error("unhandled literal: color");
+ colors.push_back(Color(dfn.GetLiteral()->GetRed(), dfn.GetLiteral()->GetGreen(), dfn.GetLiteral()->GetBlue(), dfn.GetLiteral()->GetAlpha()));
+ parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, COLOR, colors.size() - 1)));
break;
case Literal::NUMBER:
numbers.push_back(dfn.GetLiteral()->GetNumber());
}
}
+Color Interpreter::GetColor(const Value &v) {
+ if (v.IsLiteral()) {
+ return Color(v.GetLiteral().GetRed(), v.GetLiteral().GetGreen(), v.GetLiteral().GetBlue(), v.GetLiteral().GetAlpha());
+ } else {
+ ReadDefinition(source.GetDefinition(v.GetIdentifier()));
+ return GetColor(v.GetIdentifier());
+ }
+}
+
Font *Interpreter::GetFont(const Value &v) {
if (v.IsLiteral()) {
Font *f(new Font);