mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-06-29 08:22:51 +00:00
rewritten the o-key functionality to let the user choose from several applicable options
This commit is contained in:
parent
437722fe58
commit
ed6cd3cec6
@ -258,9 +258,8 @@ auto sbhook = addHook(hooks_args, 100, [] {
|
|||||||
}
|
}
|
||||||
else return 1;
|
else return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}) + addHook(hooks_o_key, 91, [] {
|
}) + addHook(hooks_o_key, 91, [] (o_funcs& v) {
|
||||||
if(in) return named_dialog(XLAT("select a puzzle"), show_menu);
|
if(in) v.push_back(named_dialog(XLAT("select a puzzle"), show_menu));
|
||||||
else return named_functionality();
|
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
44
menus.cpp
44
menus.cpp
@ -970,41 +970,57 @@ struct named_functionality {
|
|||||||
inline named_functionality named_dialog(string x, reaction_t dialog) { return named_functionality(x, [dialog] () { pushScreen(dialog); }); }
|
inline named_functionality named_dialog(string x, reaction_t dialog) { return named_functionality(x, [dialog] () { pushScreen(dialog); }); }
|
||||||
#endif
|
#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() {
|
EX named_functionality get_o_key() {
|
||||||
auto res = callhandlers(named_functionality(), hooks_o_key);
|
vector<named_functionality> res;
|
||||||
if (res != named_functionality()) return res;
|
callhooks(hooks_o_key, res);
|
||||||
|
|
||||||
|
if(in_full_game())
|
||||||
|
res.push_back(named_dialog(XLAT("world overview"), showOverview));
|
||||||
|
|
||||||
#if CAP_DAILY
|
#if CAP_DAILY
|
||||||
if(daily::on)
|
if(daily::on)
|
||||||
return named_functionality(XLAT("Strange Challenge"), [] () {
|
res.push_back(named_functionality(XLAT("Strange Challenge"), [] () {
|
||||||
achievement_final(false);
|
achievement_final(false);
|
||||||
pushScreen(daily::showMenu);
|
pushScreen(daily::showMenu);
|
||||||
});
|
}));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(viewdists)
|
if(viewdists)
|
||||||
return named_functionality(XLAT("experiment with geometry"), runGeometryExperiments);
|
res.push_back(named_functionality(XLAT("experiment with geometry"), runGeometryExperiments));
|
||||||
|
|
||||||
if(tactic::on)
|
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)
|
if(yendor::on)
|
||||||
return named_dialog(XLAT("Yendor Challenge"), yendor::showMenu);
|
res.push_back(named_dialog(XLAT("Yendor Challenge"), yendor::showMenu));
|
||||||
|
|
||||||
if(peace::on)
|
if(peace::on)
|
||||||
return named_dialog(XLAT("peaceful mode"), peace::showMenu);
|
res.push_back(named_dialog(XLAT("peaceful mode"), peace::showMenu));
|
||||||
|
|
||||||
dialog::infix = "";
|
dialog::infix = "";
|
||||||
|
|
||||||
if(in_full_game())
|
if((geometry != gNormal || NONSTDVAR) && !daily::on)
|
||||||
return named_dialog(XLAT("world overview"), showOverview);
|
res.push_back(named_functionality(XLAT("experiment with geometry"), runGeometryExperiments));
|
||||||
|
|
||||||
if(geometry != gNormal || NONSTDVAR)
|
if(res.empty()) return named_dialog(XLAT("world overview"), showOverview);
|
||||||
return named_functionality(XLAT("experiment with geometry"), runGeometryExperiments);
|
|
||||||
|
|
||||||
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;
|
EX int messagelogpos;
|
||||||
|
@ -1228,9 +1228,8 @@ EX void configure_race() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto hooks1 =
|
auto hooks1 =
|
||||||
addHook(hooks_o_key, 90, [] {
|
addHook(hooks_o_key, 90, [] (o_funcs& v) {
|
||||||
if(racing::on) { set_race_configurer(); return named_dialog(XLAT("racing menu"), raceconfigurer); }
|
if(racing::on) { set_race_configurer(); v.push_back(named_dialog(XLAT("racing menu"), raceconfigurer)); }
|
||||||
else return named_functionality();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
map<string, map<eLand, int> > scoreboard;
|
map<string, map<eLand, int> > scoreboard;
|
||||||
|
@ -499,9 +499,8 @@ namespace flocking {
|
|||||||
dialog::display();
|
dialog::display();
|
||||||
}
|
}
|
||||||
|
|
||||||
named_functionality o_key() {
|
void o_key(o_funcs& v) {
|
||||||
if(vizid == &flock_id) return named_dialog("flocking", show);
|
if(vizid == &flock_id) v.push_back(named_dialog("flocking", show));
|
||||||
return named_functionality();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hooks =
|
auto hooks =
|
||||||
|
@ -230,12 +230,11 @@ bool draw_ptriangle(cell *c, const transmatrix& V) {
|
|||||||
|
|
||||||
bool cylanim = false;
|
bool cylanim = false;
|
||||||
|
|
||||||
named_functionality o_key() {
|
void o_key(o_funcs& v) {
|
||||||
if(on) return named_functionality("ring size", [] {
|
if(on) v.push_back(named_functionality("ring size", [] {
|
||||||
dialog::editNumber(cscale, 0, 1, .01, .1, "", "");
|
dialog::editNumber(cscale, 0, 1, .01, .1, "", "");
|
||||||
dialog::reaction = reset;
|
dialog::reaction = reset;
|
||||||
});
|
}));
|
||||||
return named_functionality();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hchook = addHook(hooks_drawcell, 100, draw_ptriangle)
|
auto hchook = addHook(hooks_drawcell, 100, draw_ptriangle)
|
||||||
|
@ -1219,9 +1219,8 @@ bool default_help() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
named_functionality o_key() {
|
void o_key(o_funcs& v) {
|
||||||
if(vizid) return named_dialog(XLAT("rogueviz menu"), rogueviz::showMenu);
|
if(vizid) v.push_back(named_dialog(XLAT("rogueviz menu"), rogueviz::showMenu));
|
||||||
return named_functionality();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hooks =
|
auto hooks =
|
||||||
|
@ -193,9 +193,8 @@ void show() {
|
|||||||
dialog::display();
|
dialog::display();
|
||||||
}
|
}
|
||||||
|
|
||||||
named_functionality o_key() {
|
void o_key(o_funcs& v) {
|
||||||
if(snow_lambda) return named_dialog("snowballs", show);
|
if(snow_lambda) v.push_back(named_dialog("snowballs", show));
|
||||||
return named_functionality();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hchook = addHook(hooks_drawcell, 100, draw_snow)
|
auto hchook = addHook(hooks_drawcell, 100, draw_snow)
|
||||||
|
@ -259,9 +259,8 @@ void show() {
|
|||||||
dialog::display();
|
dialog::display();
|
||||||
}
|
}
|
||||||
|
|
||||||
named_functionality o_key() {
|
void o_key(o_funcs& v) {
|
||||||
if(on) return named_dialog("sunflowers", show);
|
if(on) v.push_back(named_dialog("sunflowers", show));
|
||||||
return named_functionality();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hook = 0
|
auto hook = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user