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

rogueviz:: help done via hooks

This commit is contained in:
Zeno Rogue 2018-07-09 20:09:56 +02:00
parent 26b4e1a7ab
commit 6303b8033b
5 changed files with 45 additions and 48 deletions

View File

@ -759,6 +759,8 @@ void appendHelp(string s) {
unsigned char lastval; unsigned char lastval;
int windtotal; int windtotal;
hookset<void(cell*)> *hooks_mouseover;
void describeMouseover() { void describeMouseover() {
DEBB(DF_GRAPH, (debugfile,"describeMouseover\n")); DEBB(DF_GRAPH, (debugfile,"describeMouseover\n"));
@ -900,9 +902,7 @@ void describeMouseover() {
} }
} }
#if CAP_ROGUEVIZ callhooks(hooks_mouseover, c);
rogueviz::describe(c);
#endif
if(mousey < vid.fsize * 3/2) getcstat = SDLK_F1; if(mousey < vid.fsize * 3/2) getcstat = SDLK_F1;
} }
@ -955,29 +955,24 @@ void showHelp() {
}; };
} }
hookset<bool()> *hooks_default_help;
void gotoHelp(const string& h) { void gotoHelp(const string& h) {
help = h; help = h;
help_extensions.clear(); help_extensions.clear();
pushScreen(showHelp); pushScreen(showHelp);
if(help == "@") { if(help == "@") {
/* if(callhandlers(false, hooks_default_help)) return;
#if CAP_ROGUEVIZ
if(rogueviz::on) {
help = rogueviz::makehelp();
help_extensions.push_back(help_extension{'u', XLAT("RogueViz menu"), [] () { popScreen(); pushScreen(rogueviz::showMenu); }});
return;
}
#endif
*/
#if CAP_RUG #if CAP_RUG
if(rug::rugged) { if(rug::rugged) {
help = rug::makehelp(); help = rug::makehelp();
help_extensions.push_back(help_extension{'m', XLAT("Hypersian Rug menu"), [] () { popScreen(); rug::select(); }}); help_extensions.push_back(help_extension{'m', XLAT("Hypersian Rug menu"), [] () { popScreen(); rug::select(); }});
help_extensions.push_back(help_extension{'h', XLAT("HyperRogue help"), [] () { buildHelpText(); }}); help_extensions.push_back(help_extension{'h', XLAT("HyperRogue help"), [] () { buildHelpText(); }});
return; return;
} }
#endif #endif
buildHelpText(); buildHelpText();

View File

@ -2040,7 +2040,8 @@ extern hookset<bool(int argc, char** argv)> *hooks_main;
extern hookset<int()> *hooks_args; extern hookset<int()> *hooks_args;
extern hookset<bool(cell*)> *hooks_mark; extern hookset<bool(cell*)> *hooks_mark;
extern hookset<eLand(eLand)> *hooks_nextland; extern hookset<eLand(eLand)> *hooks_nextland;
extern hookset<bool()> *hooks_welcome_message; extern hookset<bool()> *hooks_welcome_message, *hooks_default_help;
extern hookset<void(cell*)> *hooks_mouseover;
// hooks to extend HyperRogue with an external program // hooks to extend HyperRogue with an external program
// start compilation from another file which defines EXTRA_..., includes // start compilation from another file which defines EXTRA_..., includes

View File

@ -714,8 +714,9 @@ void sominit(int initto) {
} }
} }
void describe(cell *c) { void describe_cell(cell *c) {
if(cmode & sm::HELP) return; if(cmode & sm::HELP) return;
if(kind != kKohonen) return;
neuron *n = getNeuronSlow(c); neuron *n = getNeuronSlow(c);
if(!n) return; if(!n) return;
help += "cell number: " + its(neuronId(*n)) + " (" + its(n->allsamples) + ")\n"; help += "cell number: " + its(neuronId(*n)) + " (" + its(n->allsamples) + ")\n";
@ -1373,7 +1374,8 @@ int readArgs() {
auto hooks = addHook(hooks_args, 100, readArgs); auto hooks = addHook(hooks_args, 100, readArgs);
#endif #endif
auto hooks2 = addHook(hooks_frame, 50, levelline::draw); auto hooks2 = addHook(hooks_frame, 50, levelline::draw)
+ addHook(hooks_mouseover, 100, describe_cell);
void clear() { void clear() {
printf("clearing Kohonen...\n"); printf("clearing Kohonen...\n");

View File

@ -954,10 +954,6 @@ bool edgecmp(edgeinfo *e1, edgeinfo *e2) {
return e1->weight > e2->weight; return e1->weight > e2->weight;
} }
void describe(cell *c) {
if(kind == kKohonen) return kohonen::describe(c);
}
bool describe_monster(shmup::monster *m, string& out) { bool describe_monster(shmup::monster *m, string& out) {
if(m->type != moRogueviz) return false; if(m->type != moRogueviz) return false;
@ -1783,25 +1779,6 @@ void showMenu() {
}; };
} }
string makehelp() {
string ret =
"This is RogueViz, a visualization engine based on HyperRogue.\n\nUse WASD to move, v for menu.\n\n"
"Read more about RogueViz on : http://roguetemple.com/z/hyper/rogueviz.php\n\n";
if(kind == kAnyGraph)
ret += "Current visualization: any graph\n\n" + fname;
if(kind == kTree)
ret += "Current visualization: tree\n\n" + fname;
if(kind == kSpiral)
ret += "Current visualization: spiral\n\n";
if(kind == kSAG)
ret += "Current visualization: SAG\n\n" + fname;
if(kind == kCollatz)
ret += "Current visualization: Collatz conjecture\n\n";
if(kind == kFullNet)
ret += "Current visualization: full net\n\n";
return ret;
}
namespace rvtour { namespace rvtour {
using namespace tour; using namespace tour;
@ -2072,6 +2049,29 @@ int rvtour_hooks =
} }
bool default_help() {
if(!rogueviz::on) return false;
help =
"This is RogueViz, a visualization engine based on HyperRogue.\n\nUse WASD to move, v for menu.\n\n"
"Read more about RogueViz on : http://roguetemple.com/z/hyper/rogueviz.php\n\n";
if(kind == kAnyGraph)
help += "Current visualization: any graph\n\n" + fname;
if(kind == kTree)
help += "Current visualization: tree\n\n" + fname;
if(kind == kSpiral)
help += "Current visualization: spiral\n\n";
if(kind == kSAG)
help += "Current visualization: SAG\n\n" + fname;
if(kind == kCollatz)
help += "Current visualization: Collatz conjecture\n\n";
if(kind == kFullNet)
help += "Current visualization: full net\n\n";
help_extensions.push_back(help_extension{'u', XLAT("RogueViz menu"), [] () { popScreen(); pushScreen(showMenu); }});
return true;
}
auto hooks = auto hooks =
addHook(hooks_frame, 0, drawExtra) + addHook(hooks_frame, 0, drawExtra) +
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
@ -2093,7 +2093,8 @@ auto hooks =
if(rogueviz::on) addMessage(XLAT("Welcome to RogueViz!")); if(rogueviz::on) addMessage(XLAT("Welcome to RogueViz!"));
return rogueviz::on; return rogueviz::on;
}) + }) +
0; addHook(hooks_default_help, 100, default_help) +
0;
}; };

View File

@ -4,10 +4,8 @@ namespace rogueviz {
using namespace hr; using namespace hr;
extern bool on; extern bool on;
void describe(cell *c);
void drawExtra(); void drawExtra();
void close(); void close();
string makehelp();
void init(); void init();