mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Added new sort options for special rarity
Added "sort script" field BUG: Dependencies are not correctly updated for collection sorting, so card numbers don't update properly. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@546 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+3
-1
@@ -55,6 +55,7 @@ IMPLEMENT_REFLECTION(Field) {
|
||||
REFLECT(card_list_visible);
|
||||
REFLECT(card_list_allow);
|
||||
REFLECT(card_list_name);
|
||||
REFLECT(sort_script);
|
||||
REFLECT_IF_READING if(card_list_name.empty()) card_list_name = name;
|
||||
REFLECT_N("card_list_alignment", card_list_align);
|
||||
REFLECT(tab_index);
|
||||
@@ -215,7 +216,8 @@ bool Value::equals(const Value* that) {
|
||||
}
|
||||
|
||||
void init_object(const FieldP& field, ValueP& value) {
|
||||
if (!value) value = field->newValue(field);
|
||||
if (!value)
|
||||
value = field->newValue(field);
|
||||
}
|
||||
template <> ValueP read_new<Value>(Reader&) {
|
||||
throw InternalError(_("IndexMap contains nullptr ValueP the application should have crashed already"));
|
||||
|
||||
+15
-2
@@ -54,6 +54,7 @@ class Field : public IntrusivePtrVirtualBase {
|
||||
bool card_list_allow; ///< Is this field allowed to appear in the card list?
|
||||
String card_list_name; ///< Alternate name to use in card list.
|
||||
Alignment card_list_align; ///< Alignment of the card list colummn.
|
||||
OptionalScript sort_script; ///< The script to use when sorting this, if not the value.
|
||||
int tab_index; ///< Tab index in editor
|
||||
Dependencies dependent_scripts; ///< Scripts that depend on values of this field
|
||||
|
||||
@@ -67,7 +68,9 @@ 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
|
||||
virtual void initDependencies(Context&, const Dependency&) const {}
|
||||
inline virtual void initDependencies(Context& ctx, const Dependency& dep) const {
|
||||
sort_script.initDependencies(ctx, dep);
|
||||
}
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
@@ -183,6 +186,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.
|
||||
|
||||
/// Get a copy of this value
|
||||
virtual ValueP clone() const = 0;
|
||||
@@ -190,7 +194,11 @@ 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
|
||||
virtual bool update(Context&) { last_script_update.update(); return false; }
|
||||
inline virtual bool update(Context& ctx) {
|
||||
sortValue = fieldP->sort_script.invoke(ctx);
|
||||
last_script_update.update();
|
||||
return false;
|
||||
}
|
||||
/// 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) {}
|
||||
@@ -199,6 +207,11 @@ class Value : public IntrusivePtrVirtualBase {
|
||||
* In that case, afterwards this becomes equal to that if they use the same underlying object.
|
||||
*/
|
||||
virtual bool equals(const Value* that);
|
||||
|
||||
/// Get the sort key for this value.
|
||||
inline String getSortKey () const {
|
||||
return sortValue == script_nil ? *sortValue : toString();
|
||||
}
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include <data/field/choice.hpp>
|
||||
#include <util/io/package.hpp>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/imaglist.h>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(ChoiceField::ChoiceP);
|
||||
DECLARE_TYPEOF(map<String COMMA ScriptableImage>);
|
||||
|
||||
Reference in New Issue
Block a user