Moved spec_sort to separate file, added more advanced options;

Split 'sort' script function into 'sort_text' and 'sort_list';
Double clicking card in stats panel switches to cards panel

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@587 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-08-01 18:34:24 +00:00
parent db50b48073
commit a112f885ca
10 changed files with 437 additions and 156 deletions
+48
View File
@@ -0,0 +1,48 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_UTIL_SPEC_SORT
#define HEADER_UTIL_SPEC_SORT
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
// ----------------------------------------------------------------------------- : spec_sort
/// Sort a string using a sort specification
/** The specificatio can contain:
* - a = all 'a's go here
* - fun(A) = different behaviour
* - [abc] = mixed(abc)
* - <abc> = once(abc)
* - \? = an escaped ?
*
* 'Functions' are:
* - ordered(abc) = 'a', 'b' and 'c' go here, in that order
* - mixed(abc) = 'a', 'b' and 'c' go here, in the same order as in the input
* - once(abc) = 'a', 'b' and 'c' go here in that order, and only zero or one time.
* - cycle(abc) = 'a', 'b' and 'c' go here, in the shortest order
* consider the specified characters as a clockwise circle
* then returns the input in the order that:
* 1. takes the shortest clockwise path over this circle.
* 2. has _('holes') early, a hole means a character that is in the specification
* but not in the input
* 3. prefer the one that comes the earliest in the expression (a in this case)
* - compound(abc) = the connect sting "abc" goes gere
* - pattern(.. sort) = sort the things matching the pattern using 'sort' and replace them in the pattern
*
* example:
* spec_sort("XYZ<0123456789>cycle(WUBRG)",..) // used by magic
* "W1G") -> "1GW" // could be "W...G" or "...GW", second is shorter
* "GRBUWWUG") -> "WWUUBRGG" // no difference by rule 1,2, could be "WUBRG", "UBRGW", etc.
* // becomes _("WUBRG") by rule 3
* "WUR") -> "RWU" // by rule 1 could be "R WU" or "WU R", "RWU" has an earlier hole
*/
String spec_sort(const String& spec, String input);
// ----------------------------------------------------------------------------- : EOF
#endif