mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
- Added SetWindow::setControlStatusText function for setting the status text of child controls, since wx lacks a feature for doing it automatically.
- RandomPackPanel's spin controls are cleaned up when the set is reloaded
- to_int script function now converts empty string: to_int("") == 0
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1042 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -104,8 +104,11 @@ SCRIPT_FUNCTION(to_int) {
|
||||
result = (c.Red() + c.Blue() + c.Green()) / 3;
|
||||
} else if (t == SCRIPT_STRING) {
|
||||
long l;
|
||||
if (input->toString().ToLong(&l)) {
|
||||
String str = input->toString();
|
||||
if (str.ToLong(&l)) {
|
||||
result = l;
|
||||
} else if (str.empty()) {
|
||||
result = 0;
|
||||
} else {
|
||||
return new_intrusive1<ScriptDelayedError>(_ERROR_3_("can't convert value", input->toString(), input->typeName(), _TYPE_("integer")));
|
||||
}
|
||||
@@ -137,6 +140,8 @@ SCRIPT_FUNCTION(to_number) {
|
||||
SCRIPT_RETURN( (c.Red() + c.Blue() + c.Green()) / 3 );
|
||||
} else if (t == SCRIPT_DOUBLE) {
|
||||
SCRIPT_RETURN((double)*input);
|
||||
} else if (t == SCRIPT_NIL) {
|
||||
SCRIPT_RETURN(0);
|
||||
} else {
|
||||
String s = input->toString();
|
||||
long l; double d;
|
||||
@@ -144,6 +149,8 @@ SCRIPT_FUNCTION(to_number) {
|
||||
SCRIPT_RETURN((int)l);
|
||||
} else if (s.ToDouble(&d)) {
|
||||
SCRIPT_RETURN((double)d);
|
||||
} else if (s.empty()) {
|
||||
SCRIPT_RETURN(0);
|
||||
} else {
|
||||
return delayError(_ERROR_2_("can't convert", input->typeName(), _TYPE_("double")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user