mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Type name of ScriptObjects is now reported as the actual object type (card/set/value/etc.);
Back trace is slightly smarter Removed move_cursor_with_sort git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@542 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -229,6 +229,12 @@ help:
|
||||
drag to move line: Alt + drag to move curve; double click to add a point on this line
|
||||
drag to move point: Click and drag to move control point; double click to remove the point
|
||||
|
||||
rotation: Rotational symmetry (wheel)
|
||||
reflection: Reflectional symmetry (mirror)
|
||||
add symmetry: Add symmetries to the symbol
|
||||
remove symmetry: Remove this symmetry
|
||||
copies: Number of reflections (including the original)
|
||||
|
||||
# Card select
|
||||
filename format: (Use {card.name} for the name of the card ; The filetype is determined based on the extension)
|
||||
|
||||
@@ -270,6 +276,8 @@ tool:
|
||||
|
||||
rotation: Rotation
|
||||
reflection: Reflection
|
||||
add symmetry: Add
|
||||
remove symmetry: Remove
|
||||
|
||||
line segment: Line
|
||||
curve segment: Curve
|
||||
@@ -341,6 +349,8 @@ tooltip:
|
||||
|
||||
rotation: Rotational symmetry (wheel)
|
||||
reflection: Reflectional symmetry (mirror)
|
||||
add symmetry: Add symmetry to selected parts
|
||||
remove symmetry: Remove this symmetry
|
||||
|
||||
line segment: To straigt line
|
||||
curve segment: To curve
|
||||
@@ -540,6 +550,14 @@ action:
|
||||
delete point: Delete point
|
||||
delete points: Delete points
|
||||
|
||||
# Symmetry
|
||||
add symmetry: Add symmetry
|
||||
remove symmetry: Remove symmetry
|
||||
move symmetry center: Move symmetry center
|
||||
move symmetry handle: Change symmetry orientation
|
||||
change symmetry type: Change symmetry type
|
||||
change symmetry copies: Number of reflections
|
||||
|
||||
|
||||
############################################################## Error messages
|
||||
error:
|
||||
@@ -601,6 +619,7 @@ error:
|
||||
type:
|
||||
function: function
|
||||
collection: collection
|
||||
collection of: collection of %ss
|
||||
object: object
|
||||
real: real number
|
||||
integer: integer number
|
||||
@@ -610,6 +629,15 @@ type:
|
||||
image: image
|
||||
nil: nothing
|
||||
|
||||
# Object types
|
||||
game: game
|
||||
set: set
|
||||
stylesheet: stylesheet
|
||||
card: card
|
||||
field: field
|
||||
style: style
|
||||
value: value
|
||||
|
||||
# Symbol editor shapes
|
||||
shape: shape
|
||||
shapes: shapes
|
||||
|
||||
@@ -83,6 +83,10 @@ class Card : public IntrusivePtrVirtualBase {
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
inline String type_name(const Card&) {
|
||||
return _TYPE_("card");
|
||||
}
|
||||
|
||||
void mark_dependency_member(const Card& value, const String& name, const Dependency& dep);
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -79,6 +79,10 @@ inline void update_index(FieldP& f, size_t index) {
|
||||
f->index = index;
|
||||
}
|
||||
|
||||
inline String type_name(const Field&) {
|
||||
return _TYPE_("field");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Style
|
||||
|
||||
/// Style information needed to display a Value in a Field.
|
||||
@@ -148,6 +152,10 @@ inline const FieldP& get_key (const StyleP& s) { return s->fieldP; }
|
||||
inline const String& get_key_name(const StyleP& s) { return s->fieldP->name; }
|
||||
template <> StyleP read_new<Style>(Reader&);
|
||||
|
||||
inline String type_name(const Style&) {
|
||||
return _TYPE_("style");
|
||||
}
|
||||
|
||||
void mark_dependency_member(const Style& style, const String& name, const Dependency& dep);
|
||||
|
||||
// ----------------------------------------------------------------------------- : StyleListener
|
||||
@@ -201,6 +209,10 @@ inline const FieldP& get_key (const ValueP& v) { return v->fieldP; }
|
||||
inline const String& get_key_name(const ValueP& v) { return v->fieldP->name; }
|
||||
template <> ValueP read_new<Value>(Reader&);
|
||||
|
||||
inline String type_name(const Value&) {
|
||||
return _TYPE_("value");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Utilities
|
||||
|
||||
#define DECLARE_FIELD_TYPE(Type) \
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// ----------------------------------------------------------------------------- : TextField
|
||||
|
||||
TextField::TextField()
|
||||
: multi_line(false), move_cursor_with_sort(false)
|
||||
: multi_line(false)
|
||||
, default_name(_("Default"))
|
||||
{}
|
||||
|
||||
@@ -35,7 +35,6 @@ IMPLEMENT_REFLECTION(TextField) {
|
||||
REFLECT(multi_line);
|
||||
REFLECT(script);
|
||||
REFLECT_N("default", default_script);
|
||||
REFLECT(move_cursor_with_sort);
|
||||
REFLECT(default_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ class TextField : public Field {
|
||||
OptionalScript script; ///< Script to apply to all values
|
||||
OptionalScript default_script; ///< Script that generates the default value
|
||||
bool multi_line; ///< Are newlines allowed in the text?
|
||||
bool move_cursor_with_sort; ///< When the text is reordered by a script should the cursor position be updated?
|
||||
String default_name; ///< Name of "default" value
|
||||
|
||||
virtual void initDependencies(Context&, const Dependency&) const;
|
||||
|
||||
@@ -72,5 +72,9 @@ class Game : public Packaged {
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
inline String type_name(const Game&) {
|
||||
return _TYPE_("game");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
@@ -125,6 +125,9 @@ class Set : public Packaged {
|
||||
map<ScriptValueP,OrderCacheP> order_cache;
|
||||
};
|
||||
|
||||
inline String type_name(const Set&) {
|
||||
return _TYPE_("set");
|
||||
}
|
||||
inline int item_count(const Set& set) {
|
||||
return (int)set.cards.size();
|
||||
}
|
||||
|
||||
@@ -70,5 +70,9 @@ class StyleSheet : public Packaged {
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
inline String type_name(const StyleSheet&) {
|
||||
return _TYPE_("stylesheet");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
+1
-13
@@ -131,19 +131,7 @@ ScriptValueP Context::eval(const Script& script, bool useScope) {
|
||||
const Instruction* instr_bt = script.backtraceSkip(instr - i.data - 2, i.data);
|
||||
// have we have reached the name
|
||||
if (instr_bt) {
|
||||
if (instr_bt->instr == I_GET_VAR) {
|
||||
throw ScriptError(e.what() + _("\n in function: ") + variable_to_string(instr_bt->data));
|
||||
} else if (instr_bt->instr == I_MEMBER_C) {
|
||||
throw ScriptError(e.what() + _("\n in function: ??\?.") + script.constants[instr_bt->data]->operator String());
|
||||
} else if (instr_bt->instr == I_BINARY && instr_bt->instr2 == I_MEMBER) {
|
||||
throw ScriptError(e.what() + _("\n in function: ??\?[??\?]"));
|
||||
} else if (instr_bt->instr == I_BINARY && instr_bt->instr2 == I_ADD) {
|
||||
throw ScriptError(e.what() + _("\n in function: ??? + ???"));
|
||||
} else if (instr_bt->instr == I_NOP || instr_bt->instr == I_CALL) {
|
||||
throw ScriptError(e.what() + _("\n in function: ??\?(??\?)"));
|
||||
} else {
|
||||
throw ScriptError(e.what() + _("\n in function: ??\?"));
|
||||
}
|
||||
throw ScriptError(e.what() + _("\n in function: ") + script.instructionName(instr_bt));
|
||||
} else {
|
||||
throw e; // rethrow
|
||||
}
|
||||
|
||||
+30
-1
@@ -184,9 +184,13 @@ String Script::dumpInstr(unsigned int pos, Instruction i) const {
|
||||
// ----------------------------------------------------------------------------- : Backtracing
|
||||
|
||||
const Instruction* Script::backtraceSkip(const Instruction* instr, int to_skip) const {
|
||||
unsigned int initial = instr - &instructions[0];
|
||||
for (;instr >= &instructions[0] &&
|
||||
(to_skip || // we have something to skip
|
||||
instr >= &instructions[1] && (instr-1)->instr == I_JUMP // always look inside a jump
|
||||
instr >= &instructions[1] && (
|
||||
(instr-1)->instr == I_JUMP // always look inside a jump
|
||||
|| (instr-1)->instr == I_NOP // and skip nops
|
||||
)
|
||||
) ; --instr) {
|
||||
// skip an instruction
|
||||
switch (instr->instr) {
|
||||
@@ -205,6 +209,10 @@ const Instruction* Script::backtraceSkip(const Instruction* instr, int to_skip)
|
||||
to_skip += 2 * instr->data - 1;
|
||||
break;
|
||||
case I_JUMP: {
|
||||
if (instr->data > initial) {
|
||||
// we were in an else branch all along, ignore this jump
|
||||
return instr + 1;
|
||||
}
|
||||
// there will be a way not to take this jump
|
||||
// the part in between will have no significant stack effect
|
||||
unsigned int after_jump = instr + 1 - &instructions[0];
|
||||
@@ -248,3 +256,24 @@ const Instruction* Script::backtraceSkip(const Instruction* instr, int to_skip)
|
||||
}
|
||||
return instr >= &instructions[0] ? instr : nullptr;
|
||||
}
|
||||
|
||||
String Script::instructionName(const Instruction* instr) const {
|
||||
if (instr < &instructions[0] || instr >= &instructions[instructions.size()]) return _("??\?");
|
||||
if (instr->instr == I_GET_VAR) {
|
||||
return variable_to_string(instr->data);
|
||||
} else if (instr->instr == I_MEMBER_C) {
|
||||
return instructionName(backtraceSkip(instr - 1, 0))
|
||||
+ _(".")
|
||||
+ constants[instr->data]->toString();
|
||||
} else if (instr->instr == I_BINARY && instr->instr2 == I_MEMBER) {
|
||||
throw _("??\?[...]");
|
||||
} else if (instr->instr == I_BINARY && instr->instr2 == I_ADD) {
|
||||
return _("??? + ???");
|
||||
} else if (instr->instr == I_NOP) {
|
||||
return _("??\?(...)");
|
||||
} else if (instr->instr == I_CALL) {
|
||||
return instructionName(backtraceSkip(instr - 1, instr->data)) + _("(...)");
|
||||
} else {
|
||||
return _("??\?");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +162,8 @@ class Script : public ScriptValue {
|
||||
* If the backtrace fails, returns nullptr
|
||||
*/
|
||||
const Instruction* backtraceSkip(const Instruction* instr, int to_skip) const;
|
||||
/// Find the name of an instruction
|
||||
String instructionName(const Instruction* instr) const;
|
||||
|
||||
friend class Context;
|
||||
};
|
||||
|
||||
+11
-3
@@ -31,6 +31,14 @@ ScriptValueP make_iterator(const T& v) {
|
||||
template <typename T>
|
||||
void mark_dependency_member(const T& value, const String& name, const Dependency& dep) {}
|
||||
|
||||
/// Type name of an object, for error messages
|
||||
template <typename T> inline String type_name(const T&) {
|
||||
return _TYPE_("object");
|
||||
}
|
||||
template <typename K, typename V> inline String type_name(const pair<K,V>& p) {
|
||||
return type_name(p.second); // for maps
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Errors
|
||||
|
||||
/// A delayed error message.
|
||||
@@ -104,7 +112,7 @@ class ScriptCollection : public ScriptValue {
|
||||
public:
|
||||
inline ScriptCollection(const Collection* v) : value(v) {}
|
||||
virtual ScriptType type() const { return SCRIPT_COLLECTION; }
|
||||
virtual String typeName() const { return _TYPE_("collection"); }
|
||||
virtual String typeName() const { return format_string(_TYPE_("collection"), type_name(*value->begin())); }
|
||||
virtual ScriptValueP getMember(const String& name) const {
|
||||
long index;
|
||||
if (name.ToLong(&index) && index >= 0 && (size_t)index < value->size()) {
|
||||
@@ -152,7 +160,7 @@ class ScriptMap : public ScriptValue {
|
||||
public:
|
||||
inline ScriptMap(const Collection* v) : value(v) {}
|
||||
virtual ScriptType type() const { return SCRIPT_COLLECTION; }
|
||||
virtual String typeName() const { return _TYPE_("collection"); }
|
||||
virtual String typeName() const { return format_string(_TYPE_("collection"), type_name(value->begin())); }
|
||||
virtual ScriptValueP getMember(const String& name) const {
|
||||
return get_member(*value, name);
|
||||
}
|
||||
@@ -195,7 +203,7 @@ class ScriptObject : public ScriptValue {
|
||||
public:
|
||||
inline ScriptObject(const T& v) : value(v) {}
|
||||
virtual ScriptType type() const { return SCRIPT_OBJECT; }
|
||||
virtual String typeName() const { return _TYPE_("object"); }
|
||||
virtual String typeName() const { return type_name(*value); }
|
||||
virtual operator String() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator String(); }
|
||||
virtual operator double() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator double(); }
|
||||
virtual operator int() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator int(); }
|
||||
|
||||
Reference in New Issue
Block a user