mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 17:10:36 +00:00
rogueviz:: tutorial, start/main menu, and welcome message done as hooks
This commit is contained in:
parent
d523ceabfd
commit
3a8293df27
2
help.cpp
2
help.cpp
@ -961,6 +961,7 @@ void gotoHelp(const string& h) {
|
||||
pushScreen(showHelp);
|
||||
if(help == "@") {
|
||||
|
||||
/*
|
||||
#if CAP_ROGUEVIZ
|
||||
if(rogueviz::on) {
|
||||
help = rogueviz::makehelp();
|
||||
@ -968,6 +969,7 @@ void gotoHelp(const string& h) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
#if CAP_RUG
|
||||
if(rug::rugged) {
|
||||
|
4
hyper.h
4
hyper.h
@ -1888,6 +1888,7 @@ namespace tour {
|
||||
void list(slide*);
|
||||
}
|
||||
|
||||
extern hookset<void(int)> *hooks_slide;
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -2019,7 +2020,7 @@ template<class T, class U> int addHook(hookset<T>*& m, int prio, const U& hook)
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern purehookset hooks_frame, hooks_stats, clearmemory, hooks_config, hooks_tests, hooks_removecells, hooks_initgame, hooks_calcparam;
|
||||
extern purehookset hooks_frame, hooks_stats, clearmemory, hooks_config, hooks_tests, hooks_removecells, hooks_initgame, hooks_calcparam, hooks_mainmenu, hooks_startmenu;
|
||||
|
||||
template<class T, class... U> void callhooks(hookset<T> *h, U... args) {
|
||||
if(h) for(auto& p: *h) p.second(args...);
|
||||
@ -2039,6 +2040,7 @@ extern hookset<bool(int argc, char** argv)> *hooks_main;
|
||||
extern hookset<int()> *hooks_args;
|
||||
extern hookset<bool(cell*)> *hooks_mark;
|
||||
extern hookset<eLand(eLand)> *hooks_nextland;
|
||||
extern hookset<bool()> *hooks_welcome_message;
|
||||
|
||||
// hooks to extend HyperRogue with an external program
|
||||
// start compilation from another file which defines EXTRA_..., includes
|
||||
|
26
menus.cpp
26
menus.cpp
@ -183,6 +183,8 @@ void showOverview() {
|
||||
|
||||
// -- main menu --
|
||||
|
||||
purehookset hooks_mainmenu;
|
||||
|
||||
void showMainMenu() {
|
||||
gamescreen(2);
|
||||
|
||||
@ -225,10 +227,6 @@ void showMainMenu() {
|
||||
if(inv::on)
|
||||
dialog::addItem(XLAT("inventory"), 'i');
|
||||
|
||||
#if CAP_ROGUEVIZ
|
||||
dialog::addItem(XLAT("rogueviz menu"), 'u');
|
||||
#endif
|
||||
|
||||
#if ISMOBILE==1
|
||||
#if CAP_ACHIEVE
|
||||
dialog::addItem(XLAT("leaderboards/achievements"), '3');
|
||||
@ -238,6 +236,8 @@ void showMainMenu() {
|
||||
#if CAP_ANDROIDSHARE
|
||||
dialog::addItem("SHARE", 's'-96);
|
||||
#endif
|
||||
|
||||
callhooks(hooks_mainmenu);
|
||||
|
||||
if(!canmove) q = "review the scene";
|
||||
else if(turncount > 0) q = "continue game";
|
||||
@ -289,9 +289,6 @@ void showMainMenu() {
|
||||
pushScreen(leader::showMenu);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if CAP_ROGUEVIZ
|
||||
else if(uni == 'u') pushScreen(rogueviz::showMenu);
|
||||
#endif
|
||||
else if(doexiton(sym, uni)) {
|
||||
popScreenAll();
|
||||
@ -586,6 +583,8 @@ bool showHalloween() {
|
||||
|
||||
int daily_mode;
|
||||
|
||||
purehookset hooks_startmenu;
|
||||
|
||||
void showStartMenu() {
|
||||
if(!daily_mode) {
|
||||
daily_mode = hrand(10) + 1;
|
||||
@ -682,11 +681,7 @@ void showStartMenu() {
|
||||
break;
|
||||
}
|
||||
|
||||
#if CAP_ROGUEVIZ && CAP_TOUR
|
||||
dialog::addBreak(100);
|
||||
dialog::addBigItem(XLAT("RogueViz"), 'r');
|
||||
dialog::addInfo(XLAT("see the visualizations"));
|
||||
#endif
|
||||
callhooks(hooks_startmenu);
|
||||
|
||||
if(have_current_settings()) {
|
||||
dialog::addBreak(100);
|
||||
@ -793,13 +788,6 @@ void showStartMenu() {
|
||||
popScreenAll();
|
||||
pushScreen(daily::showMenu);
|
||||
}
|
||||
#endif
|
||||
#if CAP_ROGUEVIZ && CAP_TOUR
|
||||
else if(uni == 'r') {
|
||||
tour::slides = rogueviz::rvtour::rvslides;
|
||||
popScreenAll();
|
||||
tour::start();
|
||||
}
|
||||
#endif
|
||||
else if(sym == 'm') {
|
||||
popScreen();
|
||||
|
39
rogueviz.cpp
39
rogueviz.cpp
@ -2038,6 +2038,37 @@ slide rvslides[] = {
|
||||
}
|
||||
};
|
||||
|
||||
int rvtour_hooks =
|
||||
addHook(hooks_startmenu, 100, [] () {
|
||||
#if CAP_TOUR
|
||||
dialog::addBreak(100);
|
||||
dialog::addBigItem(XLAT("RogueViz"), 'r');
|
||||
dialog::addInfo(XLAT("see the visualizations"));
|
||||
#endif
|
||||
dialog::add_action([] () {
|
||||
tour::slides = rogueviz::rvtour::rvslides;
|
||||
popScreenAll();
|
||||
tour::start();
|
||||
});
|
||||
}) +
|
||||
addHook(hooks_slide, 100, [] (int mode) {
|
||||
if(currentslide == 0 && slides == default_slides) {
|
||||
slidecommand = "RogueViz presentation";
|
||||
if(mode == 1)
|
||||
help +=
|
||||
"\n\nYour version of HyperRogue is compiled with RogueViz. "
|
||||
"Press '5' to switch to the RogueViz slides. Watching the "
|
||||
"common HyperRogue tutorial first is useful too, "
|
||||
"as an introduction to hyperbolic geometry.";
|
||||
if(mode == 4) {
|
||||
slides = rogueviz::rvtour::rvslides;
|
||||
while(tour::on) restart_game(rg::tour);
|
||||
tour::start();
|
||||
}
|
||||
}
|
||||
}) +
|
||||
0;
|
||||
|
||||
}
|
||||
|
||||
auto hooks =
|
||||
@ -2053,6 +2084,14 @@ auto hooks =
|
||||
addHook(shmup::hooks_describe, 100, describe_monster) +
|
||||
addHook(shmup::hooks_turn, 100, turn) +
|
||||
addHook(shmup::hooks_kill, 100, activate) +
|
||||
addHook(hooks_mainmenu, 100, [] () {
|
||||
dialog::addItem(XLAT("rogueviz menu"), 'u');
|
||||
dialog::add_action([] () { pushScreen(rogueviz::showMenu); });
|
||||
}) +
|
||||
addHook(hooks_welcome_message, 100, [] () {
|
||||
if(rogueviz::on) addMessage(XLAT("Welcome to RogueViz!"));
|
||||
return rogueviz::on;
|
||||
}) +
|
||||
0;
|
||||
|
||||
};
|
||||
|
@ -7,7 +7,6 @@ namespace rogueviz {
|
||||
void describe(cell *c);
|
||||
void drawExtra();
|
||||
void close();
|
||||
void showMenu();
|
||||
string makehelp();
|
||||
|
||||
void init();
|
||||
|
14
system.cpp
14
system.cpp
@ -38,8 +38,11 @@ bool do_use_special_land() {
|
||||
(peace::on || tactic::on || geometry || gp::on || randomPatternsMode || yendor::on);
|
||||
}
|
||||
|
||||
hookset<bool()> *hooks_welcome_message;
|
||||
|
||||
void welcomeMessage() {
|
||||
if(tactic::trailer) return;
|
||||
if(callhandlers(false, hooks_welcome_message)) return;
|
||||
else if(tactic::trailer) return;
|
||||
#if CAP_TOUR
|
||||
else if(tour::on) return; // displayed by tour
|
||||
#endif
|
||||
@ -67,13 +70,8 @@ void welcomeMessage() {
|
||||
addMessage(XLAT("Good luck in the elliptic plane!"));
|
||||
else if(sphere)
|
||||
addMessage(XLAT("Welcome to Spherogue!"));
|
||||
#if CAP_ROGUEVIZ
|
||||
else if(rogueviz::on)
|
||||
addMessage(XLAT("Welcome to RogueViz!"));
|
||||
#endif
|
||||
else {
|
||||
addMessage(XLAT("Welcome to HyperRogue!"));
|
||||
}
|
||||
else
|
||||
addMessage(XLAT("Welcome to HyperRogue!"));
|
||||
|
||||
if(do_use_special_land() || firstland != laIce) if(!daily::on) {
|
||||
auto lv = land_validity(specialland);
|
||||
|
17
tour.cpp
17
tour.cpp
@ -48,6 +48,8 @@ function<bool(eLand)> showland;
|
||||
|
||||
string slidecommand;
|
||||
|
||||
hookset<void(int)> *hooks_slide;
|
||||
|
||||
void presentation(presmode mode) {
|
||||
|
||||
cheater = 0;
|
||||
@ -62,6 +64,7 @@ void presentation(presmode mode) {
|
||||
SHOWLAND(true);
|
||||
|
||||
slides[currentslide].action(mode);
|
||||
callhooks(hooks_slide, mode);
|
||||
}
|
||||
|
||||
void slidehelp() {
|
||||
@ -363,20 +366,6 @@ slide default_slides[] = {
|
||||
else clearMessages();
|
||||
}
|
||||
SHOWLAND( l == laIce );
|
||||
#if CAP_ROGUEVIZ
|
||||
slidecommand = "RogueViz presentation";
|
||||
if(mode == 1)
|
||||
help +=
|
||||
"\n\nYour version of HyperRogue is compiled with RogueViz. "
|
||||
"Press '5' to switch to the RogueViz slides. Watching the "
|
||||
"common HyperRogue tutorial first is useful too, "
|
||||
"as an introduction to hyperbolic geometry.";
|
||||
if(mode == 4) {
|
||||
slides = rogueviz::rvtour::rvslides;
|
||||
while(tour::on) restart_game(rg::tour);
|
||||
tour::start();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
},
|
||||
{"Basics of gameplay", 11, LEGAL_ANY,
|
||||
|
Loading…
Reference in New Issue
Block a user