mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Added support for named colors, e.g. "white" and "black";
Added missing keys to locale. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@716 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -195,7 +195,12 @@ class ScriptString : public ScriptValue {
|
||||
if (wxSscanf(value.c_str(),_("rgb(%u,%u,%u)"),&r,&g,&b)) {
|
||||
return Color(r, g, b);
|
||||
} else {
|
||||
throw ScriptError(_ERROR_3_("can't convert value", value, typeName(), _TYPE_("color")));
|
||||
// color from database?
|
||||
Color c(value);
|
||||
if (!c.Ok()) {
|
||||
throw ScriptError(_ERROR_3_("can't convert value", value, typeName(), _TYPE_("color")));
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
virtual int itemCount() const { return (int)value.size(); }
|
||||
@@ -226,6 +231,7 @@ class ScriptColor : public ScriptValue {
|
||||
virtual ScriptType type() const { return SCRIPT_COLOR; }
|
||||
virtual String typeName() const { return _TYPE_("color"); }
|
||||
virtual operator Color() const { return value; }
|
||||
virtual operator int() const { return (value.Red() + value.Blue() + value.Green()) / 3; }
|
||||
virtual operator String() const {
|
||||
return String::Format(_("rgb(%u,%u,%u)"), value.Red(), value.Green(), value.Blue());
|
||||
}
|
||||
|
||||
@@ -329,6 +329,9 @@ template <> void Reader::handle(Color& col) {
|
||||
UInt r,g,b;
|
||||
if (wxSscanf(getValue().c_str(),_("rgb(%u,%u,%u)"),&r,&g,&b)) {
|
||||
col.Set(r, g, b);
|
||||
} else {
|
||||
col = Color(previous_value);
|
||||
if (!col.Ok()) col = *wxBLACK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user