mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Cleaned up Set::Styling/Card::Styling by spliting that functionality into a 'DelayedIndexMaps' class;
Added 'right' and 'bottom' properties to style as an alternative way of specifying width/height; Added content_width, content_height and content_lines properties that give feedback on text rendering; Always show warnings when showing errors and vice-versa, this prevents script errors from appearing before the reader/parse error that caused them; Finally some preliminairy work on export templates git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@428 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -34,6 +34,11 @@ void store(const ScriptValueP& val, Alignment& var);
|
||||
|
||||
// ----------------------------------------------------------------------------- : OptionalScript
|
||||
|
||||
template <typename T>
|
||||
inline void change(T& v, const T& new_v) { v = new_v; }
|
||||
template <typename T>
|
||||
inline void change(Defaultable<T>& v, const Defaultable<T>& new_v) { v.assignDontChangeDefault(new_v()); }
|
||||
|
||||
/// An optional script
|
||||
class OptionalScript {
|
||||
public:
|
||||
@@ -57,7 +62,7 @@ class OptionalScript {
|
||||
ctx.setVariable(_("value"), to_script(value));
|
||||
store(ctx.eval(*script), new_value);
|
||||
if (value != new_value) {
|
||||
value = new_value;
|
||||
change(value, new_value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -66,9 +71,8 @@ class OptionalScript {
|
||||
/// Invoke the script on a value if it is in the default state
|
||||
template <typename T>
|
||||
bool invokeOnDefault(Context& ctx, Defaultable<T>& value) const {
|
||||
if (value.isDefault() && invokeOn(ctx, value)) {
|
||||
value.makeDefault(); // restore defaultness
|
||||
return true;
|
||||
if (value.isDefault()) {
|
||||
return invokeOn(ctx, value);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user