1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-11 18:00:34 +00:00

nicer support for multiple slideshows

This commit is contained in:
Zeno Rogue 2020-09-11 11:21:52 +02:00
parent 9cc4d74da0
commit 804e426c2a
2 changed files with 23 additions and 12 deletions

View File

@ -1235,11 +1235,9 @@ auto hooks =
addHook(hooks_o_key, 100, o_key) + addHook(hooks_o_key, 100, o_key) +
#if CAP_RVSLIDES #if CAP_RVSLIDES
addHook(tour::ss::hooks_extra_slideshows, 100, [] (bool view) { addHook(tour::ss::hooks_extra_slideshows, 100, [] (slideshow_callback cb) {
if(!view) return 1; if(rvslides.empty()) rvtour::gen_rvtour();
dialog::addBoolItem(XLAT("RogueViz Tour"), tour::ss::wts == &rvtour::rvslides[0], 'r'); cb(XLAT("RogueViz Tour"), &rvtour::rvslides[0], 'r');
dialog::add_action([] { tour::ss::wts = rvtour::gen_rvtour(); popScreen(); });
return 0;
}) + }) +
#endif #endif

View File

@ -384,14 +384,24 @@ EX namespace ss {
EX string current_folder; EX string current_folder;
string slidechars = "abcdefghijklmnopqrsvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789!@#$%^&*("; string slidechars = "abcdefghijklmnopqrsvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789!@#$%^&*(";
#if HDR
using slideshow_callback = function<void(string, slide*, char)>;
#endif
EX hookset<void(slideshow_callback)> hooks_extra_slideshows;
EX void for_all_slideshows(const slideshow_callback& cb) {
cb(XLAT("Guided Tour"), default_slides, 't');
callhooks(hooks_extra_slideshows, cb);
}
EX hookset<int(bool)> hooks_extra_slideshows;
EX void slideshow_menu() { EX void slideshow_menu() {
dialog::init(XLAT("slideshows"), forecolor, 150, 100); dialog::init(XLAT("slideshows"), forecolor, 150, 100);
dialog::addBoolItem(XLAT("Guided Tour"), wts == default_slides, 't'); for_all_slideshows([] (string title, slide *sl, char ch) {
dialog::add_action([] { wts = default_slides; popScreen(); }); dialog::addBoolItem(title, wts == sl, ch);
callhooks(hooks_extra_slideshows, true); dialog::add_action([sl] { wts = sl; popScreen(); });
});
dialog::addBack(); dialog::addBack();
dialog::display(); dialog::display();
} }
@ -445,8 +455,11 @@ EX namespace ss {
}); });
} }
dialog::addBreak(50); dialog::addBreak(50);
bool b = false; int cnt = 0;
if(callhandlers(0, hooks_extra_slideshows, b)) {
for_all_slideshows([&] (string title, slide *sl, char ch) { cnt++; });
if(cnt > 1) {
dialog::addItem(XLAT("change slideshow"), '1'); dialog::addItem(XLAT("change slideshow"), '1');
dialog::add_action_push(slideshow_menu); dialog::add_action_push(slideshow_menu);
} }