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

rewritten the o-key functionality to let the user choose from several applicable options

This commit is contained in:
Zeno Rogue 2020-05-15 15:53:29 +02:00
parent 437722fe58
commit ed6cd3cec6
8 changed files with 46 additions and 37 deletions

View File

@ -258,9 +258,8 @@ auto sbhook = addHook(hooks_args, 100, [] {
}
else return 1;
return 0;
}) + addHook(hooks_o_key, 91, [] {
if(in) return named_dialog(XLAT("select a puzzle"), show_menu);
else return named_functionality();
}) + addHook(hooks_o_key, 91, [] (o_funcs& v) {
if(in) v.push_back(named_dialog(XLAT("select a puzzle"), show_menu));
});
#endif

View File

@ -970,41 +970,57 @@ struct named_functionality {
inline named_functionality named_dialog(string x, reaction_t dialog) { return named_functionality(x, [dialog] () { pushScreen(dialog); }); }
#endif
EX hookset<named_functionality()> hooks_o_key;
#if HDR
using o_funcs = vector<named_functionality>;
#endif
EX hookset<void(o_funcs&)> hooks_o_key;
EX named_functionality get_o_key() {
auto res = callhandlers(named_functionality(), hooks_o_key);
if (res != named_functionality()) return res;
vector<named_functionality> res;
callhooks(hooks_o_key, res);
if(in_full_game())
res.push_back(named_dialog(XLAT("world overview"), showOverview));
#if CAP_DAILY
if(daily::on)
return named_functionality(XLAT("Strange Challenge"), [] () {
res.push_back(named_functionality(XLAT("Strange Challenge"), [] () {
achievement_final(false);
pushScreen(daily::showMenu);
});
}));
#endif
if(viewdists)
return named_functionality(XLAT("experiment with geometry"), runGeometryExperiments);
res.push_back(named_functionality(XLAT("experiment with geometry"), runGeometryExperiments));
if(tactic::on)
return named_dialog(XLAT("Pure Tactics mode"), tactic::showMenu);
res.push_back(named_dialog(XLAT("Pure Tactics mode"), tactic::showMenu));
if(yendor::on)
return named_dialog(XLAT("Yendor Challenge"), yendor::showMenu);
res.push_back(named_dialog(XLAT("Yendor Challenge"), yendor::showMenu));
if(peace::on)
return named_dialog(XLAT("peaceful mode"), peace::showMenu);
res.push_back(named_dialog(XLAT("peaceful mode"), peace::showMenu));
dialog::infix = "";
if(in_full_game())
return named_dialog(XLAT("world overview"), showOverview);
if((geometry != gNormal || NONSTDVAR) && !daily::on)
res.push_back(named_functionality(XLAT("experiment with geometry"), runGeometryExperiments));
if(geometry != gNormal || NONSTDVAR)
return named_functionality(XLAT("experiment with geometry"), runGeometryExperiments);
if(res.empty()) return named_dialog(XLAT("world overview"), showOverview);
return named_dialog(XLAT("world overview"), showOverview);
if(isize(res) == 1) return res[0];
return named_dialog(res[0].first + "/...", [res] {
dialog::init();
char id = 'o';
for(auto& r: res) {
dialog::addItem(r.first, id++);
dialog::add_action([r] { popScreen(); r.second(); });
}
dialog::display();
});
}
EX int messagelogpos;

View File

@ -1228,9 +1228,8 @@ EX void configure_race() {
}
auto hooks1 =
addHook(hooks_o_key, 90, [] {
if(racing::on) { set_race_configurer(); return named_dialog(XLAT("racing menu"), raceconfigurer); }
else return named_functionality();
addHook(hooks_o_key, 90, [] (o_funcs& v) {
if(racing::on) { set_race_configurer(); v.push_back(named_dialog(XLAT("racing menu"), raceconfigurer)); }
});
map<string, map<eLand, int> > scoreboard;

View File

@ -499,9 +499,8 @@ namespace flocking {
dialog::display();
}
named_functionality o_key() {
if(vizid == &flock_id) return named_dialog("flocking", show);
return named_functionality();
void o_key(o_funcs& v) {
if(vizid == &flock_id) v.push_back(named_dialog("flocking", show));
}
auto hooks =

View File

@ -230,12 +230,11 @@ bool draw_ptriangle(cell *c, const transmatrix& V) {
bool cylanim = false;
named_functionality o_key() {
if(on) return named_functionality("ring size", [] {
void o_key(o_funcs& v) {
if(on) v.push_back(named_functionality("ring size", [] {
dialog::editNumber(cscale, 0, 1, .01, .1, "", "");
dialog::reaction = reset;
});
return named_functionality();
}));
}
auto hchook = addHook(hooks_drawcell, 100, draw_ptriangle)

View File

@ -1219,9 +1219,8 @@ bool default_help() {
return true;
}
named_functionality o_key() {
if(vizid) return named_dialog(XLAT("rogueviz menu"), rogueviz::showMenu);
return named_functionality();
void o_key(o_funcs& v) {
if(vizid) v.push_back(named_dialog(XLAT("rogueviz menu"), rogueviz::showMenu));
}
auto hooks =

View File

@ -193,9 +193,8 @@ void show() {
dialog::display();
}
named_functionality o_key() {
if(snow_lambda) return named_dialog("snowballs", show);
return named_functionality();
void o_key(o_funcs& v) {
if(snow_lambda) v.push_back(named_dialog("snowballs", show));
}
auto hchook = addHook(hooks_drawcell, 100, draw_snow)

View File

@ -259,9 +259,8 @@ void show() {
dialog::display();
}
named_functionality o_key() {
if(on) return named_dialog("sunflowers", show);
return named_functionality();
void o_key(o_funcs& v) {
if(on) v.push_back(named_dialog("sunflowers", show));
}
auto hook = 0