mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 17:10:36 +00:00
fixed number editing when negative numbers are allowed
This commit is contained in:
parent
ca782dcfc9
commit
a90b7cc86d
@ -532,7 +532,12 @@ namespace dialog {
|
|||||||
ne.positive = true;
|
ne.positive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string disp(ld x) { if(ne.intval) return its((int) (x+.5)); else return fts(x); }
|
int ldtoint(ld x) {
|
||||||
|
if(x > 0) return int(x+.5);
|
||||||
|
else return int(x-.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
string disp(ld x) { if(ne.intval) return its(ldtoint(x)); else return fts(x); }
|
||||||
|
|
||||||
reaction_t reaction;
|
reaction_t reaction;
|
||||||
|
|
||||||
@ -540,7 +545,7 @@ namespace dialog {
|
|||||||
|
|
||||||
if(ne.intval) {
|
if(ne.intval) {
|
||||||
if(kind == 's') sscanf(ne.s.c_str(), "%d", ne.intval), *ne.editwhat = *ne.intval;
|
if(kind == 's') sscanf(ne.s.c_str(), "%d", ne.intval), *ne.editwhat = *ne.intval;
|
||||||
if(kind == 'v') *ne.intval = (int) (*ne.editwhat + .5), ne.s = its(*ne.intval);
|
if(kind == 'v') *ne.intval = ldtoint(*ne.editwhat), ne.s = its(*ne.intval);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(kind == 's') {
|
if(kind == 's') {
|
||||||
|
Loading…
Reference in New Issue
Block a user