mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 21:27:01 -04:00
Added 'filter' support to position function; Made sure sort script can depend on the value of the field itself.
Cleaned up some things, why is a blank image not thread safe? git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@548 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+12
-12
@@ -68,9 +68,7 @@ class Field : public IntrusivePtrVirtualBase {
|
||||
virtual String typeName() const = 0;
|
||||
|
||||
/// Add the given dependency to the dependet_scripts list for the variables this field depends on
|
||||
inline virtual void initDependencies(Context& ctx, const Dependency& dep) const {
|
||||
sort_script.initDependencies(ctx, dep);
|
||||
}
|
||||
virtual void initDependencies(Context& ctx, const Dependency& dep) const;
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
@@ -186,7 +184,7 @@ class Value : public IntrusivePtrVirtualBase {
|
||||
|
||||
const FieldP fieldP; ///< Field this value is for, should have the right type!
|
||||
Age last_script_update; ///< When where the scripts last updated? (by calling update)
|
||||
ScriptValueP sortValue; ///< How this should be sorted.
|
||||
String sort_value; ///< How this should be sorted.
|
||||
|
||||
/// Get a copy of this value
|
||||
virtual ValueP clone() const = 0;
|
||||
@@ -194,11 +192,7 @@ class Value : public IntrusivePtrVirtualBase {
|
||||
/// Convert this value to a string for use in tables
|
||||
virtual String toString() const = 0;
|
||||
/// Apply scripts to this value, return true if the value has changed
|
||||
inline virtual bool update(Context& ctx) {
|
||||
sortValue = fieldP->sort_script.invoke(ctx);
|
||||
last_script_update.update();
|
||||
return false;
|
||||
}
|
||||
virtual bool update(Context& ctx);
|
||||
/// This value has been updated by an action
|
||||
/** Does nothing for most Values, only FakeValues can update underlying data */
|
||||
virtual void onAction(Action& a, bool undone) {}
|
||||
@@ -208,11 +202,17 @@ class Value : public IntrusivePtrVirtualBase {
|
||||
*/
|
||||
virtual bool equals(const Value* that);
|
||||
|
||||
/// Get the sort key for this value.
|
||||
inline String getSortKey () const {
|
||||
return sortValue == script_nil ? *sortValue : toString();
|
||||
/// Get the key to use for sorting this value
|
||||
inline String getSortKey() const {
|
||||
return fieldP->sort_script ? sort_value : toString();
|
||||
}
|
||||
|
||||
protected:
|
||||
/// update() split into two functions;.
|
||||
/** Derived classes should put their stuff in between if they need the age in scripts */
|
||||
void updateAge();
|
||||
void updateSortValue(Context& ctx);
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user