diff --git a/dialogs.cpp b/dialogs.cpp index f838e97a..22678a24 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -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; diff --git a/hyper.h b/hyper.h index a3ac0806..ce170878 100644 --- a/hyper.h +++ b/hyper.h @@ -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 { diff --git a/util.cpp b/util.cpp index 6f645974..e80034df 100644 --- a/util.cpp +++ b/util.cpp @@ -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);