diff --git a/src/data/field/choice.cpp b/src/data/field/choice.cpp index b3030503..1a6ebbd6 100644 --- a/src/data/field/choice.cpp +++ b/src/data/field/choice.cpp @@ -171,6 +171,7 @@ IMPLEMENT_REFLECTION_ENUM(ChoiceRenderStyle) { } IMPLEMENT_REFLECTION(ChoiceStyle) { + tag.addAlias(300, _("card list colors"), _("colors card list")); REFLECT_BASE(Style); REFLECT(popup_style); REFLECT(render_style); diff --git a/src/data/stylesheet.cpp b/src/data/stylesheet.cpp index 9a95beab..09a1bf10 100644 --- a/src/data/stylesheet.cpp +++ b/src/data/stylesheet.cpp @@ -38,11 +38,11 @@ InputStreamP StyleSheet::openIconFile() { } IMPLEMENT_REFLECTION(StyleSheet) { // < 0.3.0 didn't use card_ prefix - tag.addAlias(300, _("width"), _("card_width")); - tag.addAlias(300, _("height"), _("card_height")); - tag.addAlias(300, _("dpi"), _("card_dpi")); - tag.addAlias(300, _("background"), _("card_background")); - tag.addAlias(300, _("info_style"), _("set_info_style")); + tag.addAlias(300, _("width"), _("card width")); + tag.addAlias(300, _("height"), _("card height")); + tag.addAlias(300, _("dpi"), _("card dpi")); + tag.addAlias(300, _("background"), _("card background")); + tag.addAlias(300, _("info style"), _("set info style")); tag.addAlias(300, _("align"), _("alignment")); REFLECT(game); diff --git a/src/main.cpp b/src/main.cpp index 5cbac4d2..e3356749 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,6 +37,7 @@ IMPLEMENT_APP(MSE) bool MSE::OnInit() { try { + SetAppName(_("Magic Set Editor")); wxInitAllImageHandlers(); init_file_formats(); settings.read(); diff --git a/src/script/context.cpp b/src/script/context.cpp index b932d802..4012146b 100644 --- a/src/script/context.cpp +++ b/src/script/context.cpp @@ -72,7 +72,7 @@ ScriptValueP Context::eval(const Script& script, bool useScope) { // Get a variable case I_GET_VAR: { ScriptValueP value = variables[i.data].value; - if (!value) throw ScriptError(_("Variable not set: ") + variableToString(i.data)); + if (!value) throw ScriptError(_("Variable not set: ") + variable_to_string(i.data)); stack.push_back(value); break; } @@ -163,7 +163,7 @@ ScriptValueP Context::eval(const Script& script, bool useScope) { } void Context::setVariable(const String& name, const ScriptValueP& value) { - setVariable(stringToVariable(name), value); + setVariable(string_to_variable(name), value); } void Context::setVariable(int name, const ScriptValueP& value) { @@ -178,13 +178,13 @@ void Context::setVariable(int name, const ScriptValueP& value) { } ScriptValueP Context::getVariable(const String& name) { - ScriptValueP value = variables[stringToVariable(name)].value; + ScriptValueP value = variables[string_to_variable(name)].value; if (!value) throw ScriptError(_("Variable not set: ") + name); return value; } ScriptValueP Context::getVariableOpt(const String& name) { - return variables[stringToVariable(name)].value; + return variables[string_to_variable(name)].value; } diff --git a/src/script/context.hpp b/src/script/context.hpp index 3520f14f..159a48c2 100644 --- a/src/script/context.hpp +++ b/src/script/context.hpp @@ -69,7 +69,7 @@ class Context { Variable value; ///< Old value of that variable. }; private: - /// Variables, indexed by integer naem (using stringToVariable) + /// Variables, indexed by integer naem (using string_to_variable) VectorIntMap variables; /// Shadowed variable bindings vector shadowed; diff --git a/src/script/dependency.cpp b/src/script/dependency.cpp index abae1819..2ec35759 100644 --- a/src/script/dependency.cpp +++ b/src/script/dependency.cpp @@ -64,6 +64,20 @@ ScriptValueP unified(const ScriptValueP& a, const ScriptValueP& b) { else return new_intrusive2(a,b); } +/// Behaves like script_nil, but with a name +class ScriptMissingVariable : public ScriptValue { + public: + ScriptMissingVariable(const String& name) : name(name) {} + virtual ScriptType type() const { return SCRIPT_NIL; } + virtual String typeName() const { return _("missing variable '") + name + _("'"); } + virtual operator String() const { return wxEmptyString; } + virtual operator double() const { return 0.0; } + virtual operator int() const { return 0; } + virtual ScriptValueP eval(Context&) const { return script_nil; } // nil() == nil + private: + String name; ///< Name of the variable +}; + // ----------------------------------------------------------------------------- : Jump record // Utility class: a jump that has been postponed @@ -245,7 +259,7 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script) // Get a variable (almost as normal) case I_GET_VAR: { ScriptValueP value = variables[i.data].value; - if (!value) value = script_nil; // no errors here + if (!value) value = new_intrusive1(variable_to_string(i.data)); // no errors here stack.push_back(value); break; } diff --git a/src/script/parser.cpp b/src/script/parser.cpp index 9bc3360b..155e7013 100644 --- a/src/script/parser.cpp +++ b/src/script/parser.cpp @@ -355,7 +355,7 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec) { script.addInstruction(I_LOOP, 0xFFFF); // loop expectToken(input, _("do")); // do script.addInstruction(I_SET_VAR, - stringToVariable(name.value)); // set name + string_to_variable(name.value));// set name script.addInstruction(I_POP); // pop parseOper(input, script, PREC_SET, I_BINARY, I_ADD);// CCC; add script.addInstruction(I_JUMP, lblStart); // jump lbl_start @@ -373,7 +373,7 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec) { script.addInstruction(I_LOOP, 0xFFFF); // loop expectToken(input, _("do")); // do script.addInstruction(I_SET_VAR, - stringToVariable(name.value)); // set name + string_to_variable(name.value));// set name script.addInstruction(I_POP); // pop parseOper(input, script, PREC_SET, I_BINARY, I_ADD);// DDD; add script.addInstruction(I_JUMP, lblStart); // jump lbl_start @@ -391,7 +391,7 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec) { script.addInstruction(I_TERNARY, I_RGB); } else { // variable - unsigned int var = stringToVariable(token.value); + unsigned int var = string_to_variable(token.value); script.addInstruction(I_GET_VAR, var); } } else if (token == TOK_INT) { @@ -475,13 +475,13 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc while (t != _(")")) { if (input.peek(2) == _(":")) { // name: ... - arguments.push_back(stringToVariable(t.value)); + arguments.push_back(string_to_variable(t.value)); input.read(); // skip the name input.read(); // and the : parseOper(input, script, PREC_SEQ); } else { // implicit "input" argument - arguments.push_back(stringToVariable(_("input"))); + arguments.push_back(string_to_variable(_("input"))); parseOper(input, script, PREC_SEQ); } t = input.peek(); diff --git a/src/script/script.cpp b/src/script/script.cpp index 632f4a67..c1bbce7e 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -17,7 +17,7 @@ Variables variables; DECLARE_TYPEOF(Variables); /// Return a unique name for a variable to allow for faster loopups -unsigned int stringToVariable(const String& s) { +unsigned int string_to_variable(const String& s) { map::iterator it = variables.find(s); if (it == variables.end()) { unsigned int v = (unsigned int)variables.size(); @@ -31,7 +31,7 @@ unsigned int stringToVariable(const String& s) { /// Get the name of a vaiable /** Warning: this function is slow, it should only be used for error messages and such. */ -String variableToString(unsigned int v) { +String variable_to_string(unsigned int v) { FOR_EACH(vi, variables) { if (vi.second == v) return vi.first; } @@ -159,7 +159,7 @@ String Script::dumpInstr(unsigned int pos, Instruction i) const { ret += "\t" + lexical_cast(i.data); break; case I_GET_VAR: case I_SET_VAR: case I_NOP: // variable - ret += "\t" + variableToString(i.data) + "\t$" + lexical_cast(i.data); + ret += "\t" + variable_to_string(i.data) + "\t$" + lexical_cast(i.data); break; } return ret; diff --git a/src/script/script.hpp b/src/script/script.hpp index 37b7479a..8dceee54 100644 --- a/src/script/script.hpp +++ b/src/script/script.hpp @@ -93,12 +93,12 @@ struct Instruction { // ----------------------------------------------------------------------------- : Variables /// Return a unique name for a variable to allow for faster loopups -unsigned int stringToVariable(const String& s); +unsigned int string_to_variable(const String& s); /// Get the name of a vaiable /** Warning: this function is slow, it should only be used for error messages and such. */ -String variableToString(unsigned int v); +String variable_to_string(unsigned int v); // ----------------------------------------------------------------------------- : Script