added 'string mode' to script parser; added Keyword and related classes

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@85 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-11-21 14:35:14 +00:00
parent b6f1a9aac7
commit 7148d90bcb
14 changed files with 221 additions and 36 deletions
+11
View File
@@ -170,6 +170,14 @@ class ScriptString : public ScriptValue {
throw ScriptError(_("Not a number: '") + value + _("'"));
}
}
virtual operator Color() const {
UInt r,g,b;
if (wxSscanf(value.c_str(),_("rgb(%u,%u,%u)"),&r,&g,&b)) {
return Color(r, g, b);
} else {
throw ScriptError(_("Not a color: '") + value + _("'"));
}
}
virtual int itemCount() const { return (int)value.size(); }
virtual ScriptValueP getMember(const String& name) const {
// get member returns characters
@@ -198,6 +206,9 @@ class ScriptColor : public ScriptValue {
virtual ScriptType type() const { return SCRIPT_COLOR; }
virtual String typeName() const { return _("color"); }
virtual operator Color() const { return value; }
virtual operator String() const {
return String::Format(_("rgb(%u,%u,%u)"), value.Red(), value.Green(), value.Blue());
}
private:
Color value;
};