mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Choice rendering now uses "style.image()" instead of "style.choice_images[value]";
Added script functions for working with multiple choice values; Added in_context support for filter_rule; Optimized toUpper/toLower because they are slow on windows (they use thread local storage and mutexes) git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@427 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -46,13 +46,13 @@ class Defaultable {
|
||||
is_default = false;
|
||||
return value;
|
||||
}
|
||||
/// Get access to the value, for changing it, don't change the defaultness
|
||||
inline T& mutateDontChangeDefault() { return value; }
|
||||
|
||||
/// Is this value in the default state?
|
||||
inline bool isDefault() const { return is_default; }
|
||||
/// Set the defaultness to true
|
||||
inline void makeDefault() { is_default = true; }
|
||||
/// Set the defaultness to false
|
||||
inline void unsetDefault() { is_default = false; }
|
||||
/// Set the defaultness to d
|
||||
inline void makeDefault(bool d = true) { is_default = d; }
|
||||
|
||||
/// Compare the values, ignore defaultness
|
||||
/** used by scriptable to check for changes */
|
||||
|
||||
+27
-3
@@ -41,6 +41,30 @@ void writeUTF8(wxTextOutputStream& stream, const String& str) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Char functions
|
||||
|
||||
#ifdef CHAR_FUNCTIONS_ARE_SLOW
|
||||
|
||||
Char toLower(Char c) {
|
||||
if (c <= 128) {
|
||||
if (c >= _('A') && c <= _('Z')) return c + (_('a') - _('A'));
|
||||
else return c;
|
||||
} else {
|
||||
return IF_UNICODE( towlower(c) , tolower(c) );
|
||||
}
|
||||
}
|
||||
|
||||
Char toUpper(Char c) {
|
||||
if (c <= 128) {
|
||||
if (c >= _('a') && c <= _('z')) return c + (_('A') - _('a'));
|
||||
else return c;
|
||||
} else {
|
||||
return IF_UNICODE( towupper(c) , toupper(c) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------- : String utilities
|
||||
|
||||
String trim(const String& s){
|
||||
@@ -180,7 +204,6 @@ bool smart_less(const String& as, const String& bs) {
|
||||
bool eq = true; // so far is everything equal?
|
||||
FOR_EACH_2_CONST(a, as, b, bs) {
|
||||
bool na = isDigit(a), nb = isDigit(b);
|
||||
Char la = toLower(a), lb = toLower(b);
|
||||
if (na && nb) {
|
||||
// compare numbers
|
||||
in_num = true;
|
||||
@@ -198,8 +221,9 @@ bool smart_less(const String& as, const String& bs) {
|
||||
return lt;
|
||||
} else {
|
||||
// compare characters
|
||||
if (la < lb) return true;
|
||||
if (la > lb) return false;
|
||||
Char la = toLower(a), lb = toLower(b);
|
||||
if (la < lb) return true;
|
||||
if (la > lb) return false;
|
||||
}
|
||||
in_num = na && nb;
|
||||
}
|
||||
|
||||
+12
-2
@@ -88,8 +88,18 @@ inline bool isUpper(Char c) { return IF_UNICODE( iswupper(c) , isupper(c) ); }
|
||||
inline bool isLower(Char c) { return IF_UNICODE( iswlower(c) , islower(c) ); }
|
||||
inline bool isPunct(Char c) { return IF_UNICODE( iswpunct(c) , ispunct(c) ); }
|
||||
// Character conversions
|
||||
inline Char toUpper(Char c) { return IF_UNICODE( towupper(c) , toupper(c) ); }
|
||||
inline Char toLower(Char c) { return IF_UNICODE( towlower(c) , tolower(c) ); }
|
||||
#ifdef _MSC_VER
|
||||
#define CHAR_FUNCTIONS_ARE_SLOW
|
||||
#endif
|
||||
#ifdef CHAR_FUNCTIONS_ARE_SLOW
|
||||
// These functions are slow as hell on msvc.
|
||||
// If also in other compilers, they can also use these routines.
|
||||
Char toLower(Char c);
|
||||
Char toUpper(Char c);
|
||||
#else
|
||||
inline Char toLower(Char c) { return IF_UNICODE( towlower(c) , tolower(c) ); }
|
||||
inline Char toUpper(Char c) { return IF_UNICODE( towupper(c) , toupper(c) ); }
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------- : String utilities
|
||||
|
||||
|
||||
Reference in New Issue
Block a user