1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 09:30:35 +00:00

fixed number editing when negative numbers are allowed

This commit is contained in:
Zeno Rogue 2017-11-06 21:18:12 +01:00
parent ca782dcfc9
commit a90b7cc86d

View File

@ -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') {