Commit 96de208f authored by coppro's avatar coppro

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.
parent bc7518da
...@@ -78,6 +78,8 @@ magicseteditor_SOURCES += ./src/gui/symbol/select_editor.cpp ...@@ -78,6 +78,8 @@ magicseteditor_SOURCES += ./src/gui/symbol/select_editor.cpp
magicseteditor_SOURCES += ./src/gui/symbol/editor.cpp magicseteditor_SOURCES += ./src/gui/symbol/editor.cpp
magicseteditor_SOURCES += ./src/gui/symbol/basic_shape_editor.cpp magicseteditor_SOURCES += ./src/gui/symbol/basic_shape_editor.cpp
magicseteditor_SOURCES += ./src/gui/symbol/window.cpp magicseteditor_SOURCES += ./src/gui/symbol/window.cpp
magicseteditor_SOURCES += ./src/gui/symbol/symmetry_editor.cpp
magicseteditor_SOURCES += ./src/gui/symbol/selection.cpp
magicseteditor_SOURCES += ./src/gui/about_window.cpp magicseteditor_SOURCES += ./src/gui/about_window.cpp
magicseteditor_SOURCES += ./src/gui/new_window.cpp magicseteditor_SOURCES += ./src/gui/new_window.cpp
magicseteditor_SOURCES += ./src/gui/drop_down_list.cpp magicseteditor_SOURCES += ./src/gui/drop_down_list.cpp
......
mse version: 0.3.4 mse version: 0.3.4
short name: Magic short name: Magic
full name: Magic the Gathering full name: Magic the Gathering
icon: card-back.png icon: card-back.png
...@@ -138,32 +138,50 @@ init script: ...@@ -138,32 +138,50 @@ init script:
if count >= 2 then "yes" if count >= 2 then "yes"
else "no" else "no"
} }
is_null_cost := {
input == "" or input == "0"
};
is_color := {
name := color_name();
contains(object.casting_cost, match:input) or (chosen(choice: name, object.card_color) and is_null_cost(object.casting_cost))
};
monocolor_sort := {
if is_color(object:input, "W") then "A"
else if is_color(object:input, "U") then "B"
else if is_color(object:input, "B") then "C"
else if is_color(object:input, "R") then "D"
else if is_color(object:input, "G") then "E"
else false
};
sort_index := { sort_index := {
if card.casting_cost_2 !="" and card.card_color != card.card_color_2 then "H" # splits that aren't the same color on both sides if input.casting_cost_2 != "" and input.card_color != input.card_color_2 then "H" # multicolor splits
else if is_land (card.card_color) then (if card.rarity != "basic land" then "J" else "K") # lands, basic and non-basic else if is_land (input.card_color) then (if input.rarity != "basic land" then "J" else "K") # lands, both basic and non-basic
else if contains(card.casting_cost,match:"/") then "G" # hybrid cards, hybrid artifacts else if contains(input.casting_cost, match:"/") then "G" # generic multicolor cards
else if is_multicolor_cost(card.casting_cost) == "yes" then "F" # multicolor cards, multicolor artifacts else if is_multicolor_cost(input.casting_cost) == "yes" then "F" # multicolors (including artifacts)
else if contains(card.casting_cost,match:"W") then "A" # white cards, white artifacts else if is_multicolor(input.card_color) and is_null_cost(input.casting_cost) then "F" # costless multicolor cards
else if contains(card.casting_cost,match:"U") then "B" # blue cards, blue artifacts else if is_hybrid (input.card_color) and is_null_cost(input.casting_cost) then "G" # costless hybrid cards
else if contains(card.casting_cost,match:"B") then "C" # black cards, black artifacts else if monocolor_sort() != false then monocolor_sort() # regular monocolor cards
else if contains(card.casting_cost,match:"R") then "D" # red cards, red artifacts };
else if contains(card.casting_cost,match:"G") then "E" # green cards, green artifacts rarity_sort := {
else if is_multicolor(card.card_color) and card.casting_cost == "0" then "F" # free multicolor cards if set.special_rarity_sort == "normally" or input.rarity != "special" then sort_index()
else if is_multicolor(card.card_color) and card.casting_cost == "" then "F" # costless multicolor cards else "Z" + sort_index()
else if is_hybrid (card.card_color) and card.casting_cost == "0" then "G" # free hybrid cards };
else if is_hybrid (card.card_color) and card.casting_cost == "" then "G" # costless hybrid cards collation_set := {
else if chosen(choice:"white", card.card_color) and card.casting_cost== "0" then "A" # free white cards if set.special_rarity_sort != "separate numbering" then filter := { true }
else if chosen(choice:"white", card.card_color) and card.casting_cost == "" then "A" # costless white cards else if card.rarity == "special" then filter := { input.rarity == "special" }
else if chosen(choice:"blue", card.card_color) and card.casting_cost == "0" then "B" # free blue cards else filter := {input.rarity != "special"}
else if chosen(choice:"blue", card.card_color) and card.casting_cost == "" then "B" # costless blue cards filter_list (set, filter: filter)
else if chosen(choice:"black", card.card_color) and card.casting_cost == "0" then "C" # free black cards };
else if chosen(choice:"black", card.card_color) and card.casting_cost == "" then "C" # costless black cards
else if chosen(choice:"red", card.card_color) and card.casting_cost == "0" then "D" # free red cards card_number := {
else if chosen(choice:"red", card.card_color) and card.casting_cost == "" then "D" # costless red cards sort_set := sort_list (collation_set(), order_by: {rarity_sort() + input.name} )
else if chosen(choice:"green", card.card_color) and card.casting_cost == "0" then "E" # free green cards position (
else if chosen(choice:"green", card.card_color) and card.casting_cost == "" then "E" # costless green cards of: card
else "I" # colorless, artifacts in: sort_set
) + 1
+ "/" +
number_of_items(in: sort_set)
}; };
# The color of a card # The color of a card
...@@ -243,7 +261,7 @@ init script: ...@@ -243,7 +261,7 @@ init script:
|[ ][^ .,]*$ # still typing... |[ ][^ .,]*$ # still typing...
|[ ]( or | and | in | less | more | to ) # or next word is ... |[ ]( or | and | in | less | more | to ) # or next word is ...
) )
) )
| <param-mana><match></param-mana> # keyword argument that is declared as mana | <param-mana><match></param-mana> # keyword argument that is declared as mana
| <param-cost>[ ]*<match></param-cost> # keyword argument that is declared as cost | <param-cost>[ ]*<match></param-cost> # keyword argument that is declared as cost
| <param-cost><match>, # keyword argument that is declared as cost | <param-cost><match>, # keyword argument that is declared as cost
...@@ -382,7 +400,7 @@ init script: ...@@ -382,7 +400,7 @@ init script:
"(?ix) # case insensitive, ignore whitespace "(?ix) # case insensitive, ignore whitespace
(^|[[:space:]\"(]) # start of a word (^|[[:space:]\"(]) # start of a word
( (^)<match>(A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|Æ) ( (^)<match>(A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|Æ)
) )
"; ";
# Used in FPM and Future Sight # Used in FPM and Future Sight
artist_line_filter := artist_line_filter :=
...@@ -523,6 +541,14 @@ set field: ...@@ -523,6 +541,14 @@ set field:
choice: no choice: no
description: Use gradients on multicolor cards by default, you can always change it be clicking on the card border. description: Use gradients on multicolor cards by default, you can always change it be clicking on the card border.
initial: no initial: no
set field:
type: choice
name: special rarity sort
description: Determines how cards with special rarity are sorted.
choice: normally
choice: last
choice: separate numbering
initial: last
############################# Default style ############################# Default style
...@@ -670,7 +696,6 @@ card field: ...@@ -670,7 +696,6 @@ card field:
name: casting cost name: casting cost
icon: stats/casting_cost.png icon: stats/casting_cost.png
script: mana_filter(value) script: mana_filter(value)
move cursor with sort: true
card list visible: true card list visible: true
card list column: 2 card list column: 2
card list alignment: right card list alignment: right
...@@ -802,13 +827,9 @@ card field: ...@@ -802,13 +827,9 @@ card field:
name: card number name: card number
save value: false save value: false
script: script:
position( card_number()
of: card sort script:
in: set rarity_sort(card) + card.name
order_by: { sort_index() + card.name }
) + 1
+ "/" +
number_of_items(in: set)
card list visible: true card list visible: true
card list column: 10 card list column: 10
card list width: 50 card list width: 50
...@@ -901,7 +922,6 @@ card field: ...@@ -901,7 +922,6 @@ card field:
name: casting cost 2 name: casting cost 2
icon: stats/casting_cost.png icon: stats/casting_cost.png
script: mana_filter(value) script: mana_filter(value)
move cursor with sort: true
card list alignment: right card list alignment: right
card list width: 50 card list width: 50
card list name: CC card list name: CC
......
...@@ -55,6 +55,7 @@ IMPLEMENT_REFLECTION(Field) { ...@@ -55,6 +55,7 @@ IMPLEMENT_REFLECTION(Field) {
REFLECT(card_list_visible); REFLECT(card_list_visible);
REFLECT(card_list_allow); REFLECT(card_list_allow);
REFLECT(card_list_name); REFLECT(card_list_name);
REFLECT(sort_script);
REFLECT_IF_READING if(card_list_name.empty()) card_list_name = name; REFLECT_IF_READING if(card_list_name.empty()) card_list_name = name;
REFLECT_N("card_list_alignment", card_list_align); REFLECT_N("card_list_alignment", card_list_align);
REFLECT(tab_index); REFLECT(tab_index);
...@@ -215,7 +216,8 @@ bool Value::equals(const Value* that) { ...@@ -215,7 +216,8 @@ bool Value::equals(const Value* that) {
} }
void init_object(const FieldP& field, ValueP& value) { 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&) { template <> ValueP read_new<Value>(Reader&) {
throw InternalError(_("IndexMap contains nullptr ValueP the application should have crashed already")); throw InternalError(_("IndexMap contains nullptr ValueP the application should have crashed already"));
......
...@@ -54,6 +54,7 @@ class Field : public IntrusivePtrVirtualBase { ...@@ -54,6 +54,7 @@ class Field : public IntrusivePtrVirtualBase {
bool card_list_allow; ///< Is this field allowed to appear in the card list? 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. String card_list_name; ///< Alternate name to use in card list.
Alignment card_list_align; ///< Alignment of the card list colummn. 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 int tab_index; ///< Tab index in editor
Dependencies dependent_scripts; ///< Scripts that depend on values of this field Dependencies dependent_scripts; ///< Scripts that depend on values of this field
...@@ -67,7 +68,9 @@ class Field : public IntrusivePtrVirtualBase { ...@@ -67,7 +68,9 @@ class Field : public IntrusivePtrVirtualBase {
virtual String typeName() const = 0; virtual String typeName() const = 0;
/// Add the given dependency to the dependet_scripts list for the variables this field depends on /// 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: private:
DECLARE_REFLECTION_VIRTUAL(); DECLARE_REFLECTION_VIRTUAL();
...@@ -183,6 +186,7 @@ class Value : public IntrusivePtrVirtualBase { ...@@ -183,6 +186,7 @@ class Value : public IntrusivePtrVirtualBase {
const FieldP fieldP; ///< Field this value is for, should have the right type! 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) 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 /// Get a copy of this value
virtual ValueP clone() const = 0; virtual ValueP clone() const = 0;
...@@ -190,7 +194,11 @@ class Value : public IntrusivePtrVirtualBase { ...@@ -190,7 +194,11 @@ class Value : public IntrusivePtrVirtualBase {
/// Convert this value to a string for use in tables /// Convert this value to a string for use in tables
virtual String toString() const = 0; virtual String toString() const = 0;
/// Apply scripts to this value, return true if the value has changed /// 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 /// This value has been updated by an action
/** Does nothing for most Values, only FakeValues can update underlying data */ /** Does nothing for most Values, only FakeValues can update underlying data */
virtual void onAction(Action& a, bool undone) {} virtual void onAction(Action& a, bool undone) {}
...@@ -199,6 +207,11 @@ class Value : public IntrusivePtrVirtualBase { ...@@ -199,6 +207,11 @@ class Value : public IntrusivePtrVirtualBase {
* In that case, afterwards this becomes equal to that if they use the same underlying object. * In that case, afterwards this becomes equal to that if they use the same underlying object.
*/ */
virtual bool equals(const Value* that); virtual bool equals(const Value* that);
/// Get the sort key for this value.
inline String getSortKey () const {
return sortValue == script_nil ? *sortValue : toString();
}
private: private:
DECLARE_REFLECTION_VIRTUAL(); DECLARE_REFLECTION_VIRTUAL();
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <data/field/choice.hpp> #include <data/field/choice.hpp>
#include <util/io/package.hpp> #include <util/io/package.hpp>
#include <wx/spinctrl.h>
#include <wx/imaglist.h>
DECLARE_TYPEOF_COLLECTION(ChoiceField::ChoiceP); DECLARE_TYPEOF_COLLECTION(ChoiceField::ChoiceP);
DECLARE_TYPEOF(map<String COMMA ScriptableImage>); DECLARE_TYPEOF(map<String COMMA ScriptableImage>);
......
...@@ -65,6 +65,7 @@ class BlankImage : public GeneratedImage { ...@@ -65,6 +65,7 @@ class BlankImage : public GeneratedImage {
public: public:
virtual Image generate(const Options&) const; virtual Image generate(const Options&) const;
virtual bool operator == (const GeneratedImage& that) const; virtual bool operator == (const GeneratedImage& that) const;
virtual bool threadSafe() const { return false; };
}; };
// ----------------------------------------------------------------------------- : LinearBlendImage // ----------------------------------------------------------------------------- : LinearBlendImage
......
...@@ -176,7 +176,7 @@ bool CardListBase::compareItems(void* a, void* b) const { ...@@ -176,7 +176,7 @@ bool CardListBase::compareItems(void* a, void* b) const {
ValueP va = reinterpret_cast<Card*>(a)->data[sort_field]; ValueP va = reinterpret_cast<Card*>(a)->data[sort_field];
ValueP vb = reinterpret_cast<Card*>(b)->data[sort_field]; ValueP vb = reinterpret_cast<Card*>(b)->data[sort_field];
if (!va || !vb) return va < vb; // got to do something, compare pointers if (!va || !vb) return va < vb; // got to do something, compare pointers
return smart_less( va->toString() , vb->toString() ); return smart_less( va->getSortKey(), vb->getSortKey() );
} }
void CardListBase::rebuild() { void CardListBase::rebuild() {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <data/symbol.hpp> #include <data/symbol.hpp>
#include <wx/imaglist.h>
class SymbolPartsSelection; class SymbolPartsSelection;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <gui/symbol/editor.hpp> #include <gui/symbol/editor.hpp>
#include <wx/spinctrl.h>
class SymmetryMoveAction; class SymmetryMoveAction;
......
...@@ -50,7 +50,7 @@ typedef shared_ptr<wxMemoryDC> MemoryDCP; ...@@ -50,7 +50,7 @@ typedef shared_ptr<wxMemoryDC> MemoryDCP;
// Return a temporary DC with the same size as the parameter // Return a temporary DC with the same size as the parameter
MemoryDCP getTempDC(DC& dc) { MemoryDCP getTempDC(DC& dc) {
wxSize s = dc.GetSize(); wxSize s = dc.GetSize();
Bitmap buffer(s.GetWidth(), s.GetHeight(), 1); Bitmap buffer(s.GetWidth(), s.GetHeight(), 24);
MemoryDCP newDC(new wxMemoryDC); MemoryDCP newDC(new wxMemoryDC);
newDC->SelectObject(buffer); newDC->SelectObject(buffer);
clearDC(*newDC, *wxBLACK_BRUSH); clearDC(*newDC, *wxBLACK_BRUSH);
...@@ -161,10 +161,10 @@ void SymbolViewer::combineSymbolPart(DC& dc, const SymbolPart& part, bool& paint ...@@ -161,10 +161,10 @@ void SymbolViewer::combineSymbolPart(DC& dc, const SymbolPart& part, bool& paint
// Matrix2D rot(cos(a),-sin(a), sin(a),cos(a)); // Matrix2D rot(cos(a),-sin(a), sin(a),cos(a));
// //
// ref * rot // ref * rot
// /cos b sin b\ /cos a -sin a\ // /cos b sin b\ /cos a -sin a\;
// = \sin b -cos b/ \sin a cos a/ // = \sin b -cos b/ \sin a cos a/;s
// = /cos(a+b) sin(a+b)\ // = /cos(a+b) sin(a+b)\;
// \sin(a+b) -cos(a+b)/ // \sin(a+b) -cos(a+b)/;
Matrix2D rot(cos(a+b),sin(a+b), sin(a+b),-cos(a+b)); Matrix2D rot(cos(a+b),sin(a+b), sin(a+b),-cos(a+b));
multiply.mx = rot.mx * old_m; multiply.mx = rot.mx * old_m;
multiply.my = rot.my * old_m; multiply.my = rot.my * old_m;
......
...@@ -67,7 +67,7 @@ class SymbolViewer : public SymbolView { ...@@ -67,7 +67,7 @@ class SymbolViewer : public SymbolView {
int in_symmetry; int in_symmetry;
/// Combine a symbol part with the dc /// Combine a symbol part with the dc
void SymbolViewer::combineSymbolPart(DC& dc, const SymbolPart& part, bool& paintedSomething, bool& buffersFilled, bool allow_overlap, MemoryDCP& borderDC, MemoryDCP& interiorDC); void combineSymbolPart(DC& dc, const SymbolPart& part, bool& paintedSomething, bool& buffersFilled, bool allow_overlap, MemoryDCP& borderDC, MemoryDCP& interiorDC);
/// Combines a symbol part with what is currently drawn, the border and interior are drawn separatly /// Combines a symbol part with what is currently drawn, the border and interior are drawn separatly
/** directB/directI are true if the border/interior is the screen dc, false if it /** directB/directI are true if the border/interior is the screen dc, false if it
......
...@@ -229,7 +229,7 @@ void SetScriptManager::updateStyles(Context& ctx, const IndexMap<FieldP,StyleP>& ...@@ -229,7 +229,7 @@ void SetScriptManager::updateStyles(Context& ctx, const IndexMap<FieldP,StyleP>&
s->tellListeners(only_content_dependent); s->tellListeners(only_content_dependent);
} }
} catch (const ScriptError& e) { } catch (const ScriptError& e) {
throw ScriptError(e.what() + _("\n while updating styles for '") + s->fieldP->name + _("'")); handle_error(ScriptError(e.what() + _("\n while updating styles for '") + s->fieldP->name + _("'")));
} }
} }
} }
...@@ -267,7 +267,7 @@ void SetScriptManager::updateAll() { ...@@ -267,7 +267,7 @@ void SetScriptManager::updateAll() {
try { try {
v->update(ctx); v->update(ctx);
} catch (const ScriptError& e) { } catch (const ScriptError& e) {
throw ScriptError(e.what() + _("\n while updating set value '") + v->fieldP->name + _("'")); handle_error(ScriptError(e.what() + _("\n while updating set value '") + v->fieldP->name + _("'")));
} }
} }
// update card data of all cards // update card data of all cards
...@@ -277,7 +277,7 @@ void SetScriptManager::updateAll() { ...@@ -277,7 +277,7 @@ void SetScriptManager::updateAll() {
try { try {
v->update(ctx); v->update(ctx);
} catch (const ScriptError& e) { } catch (const ScriptError& e) {
throw ScriptError(e.what() + _("\n while updating card value '") + v->fieldP->name + _("'")); handle_error(ScriptError(e.what() + _("\n while updating card value '") + v->fieldP->name + _("'")));
} }
} }
} }
...@@ -311,7 +311,7 @@ void SetScriptManager::updateToUpdate(const ToUpdate& u, deque<ToUpdate>& to_upd ...@@ -311,7 +311,7 @@ void SetScriptManager::updateToUpdate(const ToUpdate& u, deque<ToUpdate>& to_upd
try { try {
changes = u.value->update(ctx); changes = u.value->update(ctx);
} catch (const ScriptError& e) { } catch (const ScriptError& e) {
throw ScriptError(e.what() + _("\n while updating value '") + u.value->fieldP->name + _("'")); handle_error(ScriptError(e.what() + _("\n while updating value '") + u.value->fieldP->name + _("'")));
} }
if (changes) { if (changes) {
// changed, send event // changed, send event
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment