number editor now accepts hex numbers, and uses hex as default when editing Tortoises

This commit is contained in:
Zeno Rogue 2019-01-18 21:04:29 +01:00
parent 35043b5528
commit 730e7b5b99
3 changed files with 12 additions and 1 deletions

View File

@ -600,7 +600,10 @@ namespace dialog {
else return int(x-.5);
}
string disp(ld x) { if(ne.intval) return its(ldtoint(x)); else if(ne.vmax-ne.vmin < 1) return fts4(x); else return fts(x); }
string disp(ld x) {
if(dialogflags & sm::HEXEDIT) return "0x" + itsh(x);
else if(ne.intval) return its(ldtoint(x));
else if(ne.vmax-ne.vmin < 1) return fts4(x); else return fts(x); }
reaction_t reaction;
reaction_t reaction_final;
@ -615,6 +618,11 @@ namespace dialog {
anims::deanimate(*ne.editwhat);
}
void use_hexeditor() {
dialogflags |= sm::HEXEDIT;
ne.s = disp(*ne.editwhat);
}
void apply_edit() {
exp_parser ep;
ep.s = ne.s;

View File

@ -1822,6 +1822,7 @@ namespace dialog {
void editNumber(ld& x, ld vmin, ld vmax, ld step, ld dft, string title, string help);
void editNumber(int& x, int vmin, int vmax, int step, int dft, string title, string help);
void use_hexeditor();
inline void scaleLog() { ne.sc = logarithmic; }
inline void scaleSinh() { ne.sc = asinhic; }
void bound_low(ld val);
@ -2287,6 +2288,7 @@ namespace sm {
static const int MAYDARK = 16384;
static const int DIALOG_STRICT_X = 32768; // do not interpret dialog clicks outside of the X region
static const int EXPANSION = (1<<16);
static const int HEXEDIT = (1<<17);
};
namespace linepatterns {

View File

@ -221,6 +221,7 @@ cld exp_parser::parse(int prio) {
else if(number == "") at = -1;
else if(number == "s") res = ticks / 1000.;
else if(number == "ms") res = ticks;
else if(number[0] == '0' && number[1] == 'x') res = strtoll(number.c_str()+2, NULL, 16);
else if(number == "mousex") res = mousex;
else if(number == "mousey") res = mousey;
else if(number == "mousez") res = cld(mousex - current_display->xcenter, mousey - current_display->ycenter) / cld(current_display->radius, 0);