1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-12 02:10:34 +00:00

parsing expressions allowed for integers too

This commit is contained in:
Zeno Rogue 2018-09-23 02:39:53 +02:00
parent 34921e983e
commit ad3355f500

View File

@ -601,11 +601,6 @@ namespace dialog {
void affect(char kind) {
if(ne.intval) {
if(kind == 's') sscanf(ne.s.c_str(), "%d", ne.intval), *ne.editwhat = *ne.intval;
if(kind == 'v') *ne.intval = ldtoint(*ne.editwhat), ne.s = its(*ne.intval);
}
else {
if(kind == 's') {
exp_parser ep;
ep.s = ne.s;
@ -613,8 +608,11 @@ namespace dialog {
if(!ep.ok()) return;
if(ne.sc.positive && x <= 0) return;
*ne.editwhat = x;
if(ne.intval) *ne.intval = ldtoint(*ne.editwhat);
}
if(kind == 'v') ne.s = disp(*ne.editwhat);
if(kind == 'v') {
if(ne.intval) *ne.intval = ldtoint(*ne.editwhat);
ne.s = disp(*ne.editwhat);
}
if(reaction) reaction();
@ -732,7 +730,7 @@ namespace dialog {
keyhandler = [] (int sym, int uni) {
handleNavigation(sym, uni);
if((uni >= '0' && uni <= '9') || (uni == '.' && !ne.intval) || among(uni, '+', '-', '*', '/', '^', '(', ')') || (uni >= 'a' && uni <= 'z')) {
if((uni >= '0' && uni <= '9') || among(uni, '.', '+', '-', '*', '/', '^', '(', ')') || (uni >= 'a' && uni <= 'z')) {
ne.s += uni;
affect('s');
}