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

Number edit with reaction configurable via a function

This commit is contained in:
Zeno Rogue 2017-09-01 22:06:36 +02:00
parent 0f892c9468
commit e80304d445

View File

@ -532,6 +532,10 @@ namespace dialog {
string disp(ld x) { if(ne.intval) return its((int) (x+.5)); else return fts(x); } string disp(ld x) { if(ne.intval) return its((int) (x+.5)); else return fts(x); }
typedef function<void()> reaction_t;
reaction_t reaction;
void affect(char kind) { void affect(char kind) {
if(ne.intval) { if(ne.intval) {
@ -547,6 +551,8 @@ namespace dialog {
} }
if(kind == 'v') ne.s = fts(*ne.editwhat); if(kind == 'v') ne.s = fts(*ne.editwhat);
} }
if(reaction) reaction();
#if CAP_AUDIO #if CAP_AUDIO
if(ne.intval == &musicvolume) { if(ne.intval == &musicvolume) {
@ -794,6 +800,7 @@ namespace dialog {
dialogflags = (cmode & (sm::SIDE | sm::A3)); dialogflags = (cmode & (sm::SIDE | sm::A3));
cmode |= sm::NUMBER; cmode |= sm::NUMBER;
pushScreen(drawNumberDialog); pushScreen(drawNumberDialog);
reaction = reaction_t();
} }
void editNumber(int& x, int vmin, int vmax, int step, int dft, string title, string help) { void editNumber(int& x, int vmin, int vmax, int step, int dft, string title, string help) {