1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

added dialog::extra_options, and extra options in number dialogs now use this feature

This commit is contained in:
Zeno Rogue 2018-08-01 03:59:20 +02:00
parent d005e549be
commit 1e15992a22
4 changed files with 54 additions and 66 deletions

View File

@ -690,6 +690,15 @@ void showGraphConfig() {
dialog::reaction = [] () {
doOvergenerate();
};
dialog::extra_options = [] () {
if(allowChangeRange()) {
dialog::addSelItem("generation range bonus", its(genrange_bonus), 'o');
dialog::add_action([] () { genrange_bonus = sightrange_bonus; doOvergenerate(); });
dialog::addSelItem("game range bonus", its(gamerange_bonus), 'O');
dialog::add_action([] () { gamerange_bonus = sightrange_bonus; doOvergenerate(); });
}
else dialog::addInfo("note: enable the cheat mode for additional options");
};
}
if(xuni == 'k') {
@ -720,8 +729,13 @@ void showGraphConfig() {
// if(xuni == 'b') vid.antialias ^= AA_LINEWIDTH;
if(xuni == 'w' && vid.usingGL)
if(xuni == 'w' && vid.usingGL) {
dialog::editNumber(vid.linewidth, 0, 10, 0.1, 1, XLAT("line width"), "");
dialog::extra_options = [] () {
dialog::addBoolItem("finer lines at the boundary", vid.antialias & AA_LINEWIDTH, 'o');
dialog::add_action([] () { vid.antialias ^= AA_LINEWIDTH; });
};
}
if(xuni == 'c') {
dialog::editNumber(vid.mobilecompasssize, 0, 100, 10, 20, XLAT("compass size"), "");
@ -956,6 +970,15 @@ void projectionDialog() {
// "to the eye. "
"See also the conformal mode (in the special modes menu) "
"for more models."));
dialog::extra_options = [] () {
dialog::addBreak(100);
dialog::addSelItem(sphere ? "stereographic" : "Poincaré model", "1", 'p');
dialog::add_action([] () { *dialog::ne.editwhat = 1; vid.scale = 1; dialog::ne.s = "1"; });
dialog::addSelItem(sphere ? "gnomonic" : "Klein model", "0", 'k');
dialog::add_action([] () { *dialog::ne.editwhat = 0; vid.scale = 1; dialog::ne.s = "0"; });
dialog::addItem(sphere ? "towards orthographic" : "towards Gans model", 'o');
dialog::add_action([] () { double d = exp(shiftmul/10); vid.alpha *= d; vid.scale *= d; dialog::ne.s = dialog::disp(vid.alpha); });
};
}
string explain3D(ld *param) {
@ -1181,8 +1204,19 @@ void show3D() {
dialog::editNumber(geom3::depth, 0, 5, .1, 1, XLAT("Ground level below the plane"), "");
else if(uni == 'a')
projectionDialog();
else if(uni == 'w')
else if(uni == 'w') {
dialog::editNumber(geom3::wall_height, 0, 1, .1, .3, XLAT("Height of walls"), "");
dialog::extra_options = [] () {
dialog::addBoolItem("auto-adjust in Goldberg grids", geom3::gp_autoscale_heights, 'o');
dialog::add_action([] () {
geom3::gp_autoscale_heights = !geom3::gp_autoscale_heights;
buildpolys();
#if CAP_GL
resetGL();
#endif
});
};
}
else if(uni == 'l')
dialog::editNumber(geom3::lake_top, 0, 1, .1, .25, XLAT("Level of water surface"), "");
else if(uni == 'k')

View File

@ -738,6 +738,15 @@ namespace conformal {
"lands which have a special direction. Note that if finding this special direction is a part of the puzzle, "
"it works only in the cheat mode.");
dialog::dialogflags |= sm::CENTER;
dialog::extra_options = [] () {
dialog::addBreak(100);
dialog::addBoolItem("line animation only", conformal::do_rotate == 0, 'n');
dialog::add_action([] () { conformal::do_rotate = 0; });
dialog::addBoolItem("gravity lands", conformal::do_rotate == 1, 'g');
dialog::add_action([] () { conformal::do_rotate = 1; });
dialog::addBoolItem("all directional lands", conformal::do_rotate == 2, 'd');
dialog::add_action([] () { conformal::do_rotate = 2; });
};
}
else if(doexiton(sym, uni)) popScreen();
};

View File

@ -567,6 +567,8 @@ namespace dialog {
displayColorButton(dcenter, vid.yres/2+vid.fsize * 6, XLAT("select this color") + " : " + itsh(color), ' ', 8, 0, color >> ash);
if(extra_options) extra_options();
keyhandler = handleKeyColor;
}
@ -575,6 +577,7 @@ namespace dialog {
dialogflags = 0;
pushScreen(drawColorDialog);
reaction = reaction_t();
extra_options = reaction_t();
}
numberEditor ne;
@ -605,6 +608,8 @@ namespace dialog {
reaction_t reaction;
reaction_t extra_options;
void affect(char kind) {
if(ne.intval) {
@ -730,35 +735,7 @@ namespace dialog {
// if(scal) lastItem().scale = 30;
}
if(ne.editwhat == &vid.alpha) {
addBreak(100);
addSelItem(sphere ? "stereographic" : "Poincaré model", "1", 'p');
addSelItem(sphere ? "gnomonic" : "Klein model", "0", 'k');
addItem(sphere ? "towards orthographic" : "towards Gans model", 'o');
}
if(ne.editwhat == &conformal::rotation) {
addBreak(100);
addBoolItem("line animation only", conformal::do_rotate == 0, 'n');
addBoolItem("gravity lands", conformal::do_rotate == 1, 'g');
addBoolItem("all directional lands", conformal::do_rotate == 2, 'd');
}
if(ne.editwhat == &ne.intbuf && ne.intval == &sightrange_bonus && allowChangeRange()) {
addSelItem("generation range bonus", its(genrange_bonus), 'o');
addSelItem("game range bonus", its(gamerange_bonus), 'O');
}
if(ne.editwhat == &vid.stretch && sphere && pmodel == mdBandEquiarea) {
addBoolItem("Gall-Peters", vid.stretch == 2, 'o');
add_action([] { vid.stretch = 2; });
}
if(ne.editwhat == &vid.linewidth)
addBoolItem("finer lines at the boundary", vid.antialias & AA_LINEWIDTH, 'o');
if(ne.editwhat == &geom3::wall_height)
addBoolItem("auto-adjust in Goldberg grids", geom3::gp_autoscale_heights, 'o');
if(extra_options) extra_options();
display();
@ -804,40 +781,6 @@ namespace dialog {
ne.inverse_scale(d * (ne.scale(ne.vmax) - ne.scale(ne.vmin)) + ne.scale(ne.vmin));
affect('v');
}
else if(uni == 'n' && ne.editwhat == &conformal::rotation)
conformal::do_rotate = 0;
else if(uni == 'g' && ne.editwhat == &conformal::rotation)
conformal::do_rotate = 1;
else if(uni == 'd' && ne.editwhat == &conformal::rotation)
conformal::do_rotate = 2;
else if(uni == 'o' && ne.editwhat == &ne.intbuf && ne.intval == &sightrange_bonus && allowChangeRange()) {
genrange_bonus = sightrange_bonus;
doOvergenerate();
}
else if(uni == 'o' && ne.editwhat == &geom3::wall_height) {
geom3::gp_autoscale_heights = !geom3::gp_autoscale_heights;
buildpolys();
#if CAP_GL
resetGL();
#endif
}
else if(uni == 'O' && ne.editwhat == &ne.intbuf && ne.intval == &sightrange_bonus && allowChangeRange()) {
gamerange_bonus = sightrange_bonus;
}
else if(uni == 'o' && ne.editwhat == &vid.linewidth)
vid.antialias ^= AA_LINEWIDTH;
else if(uni == 'p' && ne.editwhat == &vid.alpha) {
*ne.editwhat = 1; vid.scale = 1; ne.s = "1";
}
else if(uni == 'k' && ne.editwhat == &vid.alpha) {
*ne.editwhat = 0; vid.scale = 1; ne.s = "0";
}
else if((uni == 'i' || uni == 'I' || uni == 'o' || uni == 'O') && ne.editwhat == &vid.alpha) {
double d = exp(shiftmul/10);
vid.alpha *= d;
vid.scale *= d;
ne.s = disp(vid.alpha);
}
else if(doexiton(sym, uni)) popScreen();
};
}
@ -908,6 +851,7 @@ namespace dialog {
cmode |= sm::NUMBER;
pushScreen(drawNumberDialog);
reaction = reaction_t();
extra_options = reaction_t();
numberdark = 0;
}

View File

@ -1514,13 +1514,14 @@ namespace dialog {
extern vector<item> items;
extern reaction_t reaction;
extern reaction_t reaction, extra_options;
item& lastItem();
extern unsigned int *palette;
string keyname(int k);
string disp(ld x);
void addSelItem(string body, string value, int key);
void addBoolItem(string body, bool value, int key);
void addBigItem(string body, int key);