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

Use callhandlers() instead of manual loop in menus.cpp. NFCI.

This commit is contained in:
Arthur O'Dwyer 2020-04-11 20:44:10 -04:00
parent 83f5412916
commit 961a8919c6

View File

@ -947,18 +947,22 @@ EX void showStartMenu() {
// -- overview --
#if HDR
typedef pair<string, reaction_t> named_functionality;
struct named_functionality {
std::string first;
reaction_t second;
explicit named_functionality() = default;
explicit named_functionality(std::string s, reaction_t r) : first(std::move(s)), second(std::move(r)) {}
friend bool operator==(const named_functionality& a, const named_functionality& b) { return a.first == b.first; }
friend bool operator!=(const named_functionality& a, const named_functionality& b) { return a.first != b.first; }
};
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;
EX named_functionality get_o_key() {
if(hooks_o_key) for(auto& h: *hooks_o_key) {
auto res = h.second();
if(res.first != "") return res;
}
auto res = callhandlers(named_functionality(), hooks_o_key);
if (res != named_functionality()) return res;
#if CAP_DAILY
if(daily::on)