mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
bestiaries are now shown in the help for lands
This commit is contained in:
parent
77212e59e5
commit
32ab46d5cd
105
help.cpp
105
help.cpp
@ -597,6 +597,26 @@ string turnstring(int i) {
|
|||||||
else return XLAT("%1 turns", its(i));
|
else return XLAT("%1 turns", its(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reaction_t helpgenerator;
|
||||||
|
string bygen(reaction_t h) {
|
||||||
|
helpgenerator = h;
|
||||||
|
return "HELPGEN";
|
||||||
|
}
|
||||||
|
|
||||||
|
void gotoHelpFor(eLand l);
|
||||||
|
|
||||||
|
void gotoHelpFor(eItem i) {
|
||||||
|
help = generateHelpForItem(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gotoHelpFor(eWall w) {
|
||||||
|
help = generateHelpForWall(w);
|
||||||
|
};
|
||||||
|
|
||||||
|
void gotoHelpFor(eMonster m) {
|
||||||
|
help = generateHelpForMonster(m);
|
||||||
|
};
|
||||||
|
|
||||||
void describeMouseover() {
|
void describeMouseover() {
|
||||||
DEBB(DF_GRAPH, (debugfile,"describeMouseover\n"));
|
DEBB(DF_GRAPH, (debugfile,"describeMouseover\n"));
|
||||||
|
|
||||||
@ -605,7 +625,7 @@ void describeMouseover() {
|
|||||||
if(!c || instat || getcstat != '-') { }
|
if(!c || instat || getcstat != '-') { }
|
||||||
else if(c->wall != waInvisibleFloor) {
|
else if(c->wall != waInvisibleFloor) {
|
||||||
out = XLAT1(linf[c->land].name);
|
out = XLAT1(linf[c->land].name);
|
||||||
help = generateHelpForLand(c->land);
|
help = bygen([c] () { gotoHelpFor(c->land); });
|
||||||
|
|
||||||
if(isIcyLand(c))
|
if(isIcyLand(c))
|
||||||
out += " (" + fts(heat::celsius(c)) + " °C)";
|
out += " (" + fts(heat::celsius(c)) + " °C)";
|
||||||
@ -656,9 +676,11 @@ void describeMouseover() {
|
|||||||
if((c->wall == waBigTree || c->wall == waSmallTree) && c->land != laDryForest)
|
if((c->wall == waBigTree || c->wall == waSmallTree) && c->land != laDryForest)
|
||||||
help =
|
help =
|
||||||
"Trees in this forest can be chopped down. Big trees take two turns to chop down.";
|
"Trees in this forest can be chopped down. Big trees take two turns to chop down.";
|
||||||
else if(c->wall != waSea && c->wall != waPalace)
|
else
|
||||||
if(!((c->wall == waCavefloor || c->wall == waCavewall) && c->land == laEmerald))
|
if(c->wall != waSea && c->wall != waPalace && c->wall != waDeadfloor)
|
||||||
help = generateHelpForWall(c->wall);
|
if(!((c->wall == waCavefloor || c->wall == waCavewall) && (c->land == laEmerald && c->land == laCaves)))
|
||||||
|
if(!((isAlch(c->wall) && c->land == laAlchemist)))
|
||||||
|
help = bygen([c] () { gotoHelpFor(c->wall); });
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isActivable(c)) out += XLAT(" (touch to activate)");
|
if(isActivable(c)) out += XLAT(" (touch to activate)");
|
||||||
@ -680,7 +702,7 @@ void describeMouseover() {
|
|||||||
if(c->monst == moTortoise && tortoise::seek())
|
if(c->monst == moTortoise && tortoise::seek())
|
||||||
out += " " + tortoise::measure(tortoise::getb(c));
|
out += " " + tortoise::measure(tortoise::getb(c));
|
||||||
|
|
||||||
help = generateHelpForMonster(c->monst);
|
help = bygen([c] () { gotoHelpFor(c->monst); });
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c->item && !itemHiddenFromSight(c)) {
|
if(c->item && !itemHiddenFromSight(c)) {
|
||||||
@ -689,7 +711,8 @@ void describeMouseover() {
|
|||||||
if(c->item == itBarrow) out += " (x" + its(c->landparam) + ")";
|
if(c->item == itBarrow) out += " (x" + its(c->landparam) + ")";
|
||||||
if(c->item == itBabyTortoise && tortoise::seek())
|
if(c->item == itBabyTortoise && tortoise::seek())
|
||||||
out += " " + tortoise::measure(tortoise::babymap[c]);
|
out += " " + tortoise::measure(tortoise::babymap[c]);
|
||||||
if(!c->monst) help = generateHelpForItem(c->item);
|
if(!c->monst)
|
||||||
|
help = bygen([c] () { gotoHelpFor(c->monst); });
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isPlayerOn(c) && !shmup::on) out += XLAT(", you"), help = generateHelpForMonster(moPlayer);
|
if(isPlayerOn(c) && !shmup::on) out += XLAT(", you"), help = generateHelpForMonster(moPlayer);
|
||||||
@ -721,8 +744,12 @@ void describeMouseover() {
|
|||||||
if(mousey < vid.fsize * 3/2) getcstat = SDLK_F1;
|
if(mousey < vid.fsize * 3/2) getcstat = SDLK_F1;
|
||||||
}
|
}
|
||||||
|
|
||||||
string help_action_text;
|
struct help_extension {
|
||||||
reaction_t help_action;
|
char key;
|
||||||
|
string text;
|
||||||
|
reaction_t action;
|
||||||
|
};
|
||||||
|
vector<help_extension> help_extensions;
|
||||||
|
|
||||||
void showHelp() {
|
void showHelp() {
|
||||||
gamescreen(2);
|
gamescreen(2);
|
||||||
@ -747,19 +774,25 @@ void showHelp() {
|
|||||||
dialog::addHelp(help);
|
dialog::addHelp(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(help == buildHelpText()) dialog::addItem(XLAT("credits"), 'c');
|
for(auto& he: help_extensions)
|
||||||
if(help_action_text != "") dialog::addItem(help_action_text, 't');
|
dialog::addItem(he.text, he.key);
|
||||||
|
|
||||||
dialog::display();
|
dialog::display();
|
||||||
|
|
||||||
keyhandler = [] (int sym, int uni) {
|
keyhandler = [] (int sym, int uni) {
|
||||||
dialog::handleNavigation(sym, uni);
|
dialog::handleNavigation(sym, uni);
|
||||||
|
|
||||||
|
for(auto& he: help_extensions)
|
||||||
|
if(uni == he.key) {
|
||||||
|
// we need to copy he.action
|
||||||
|
// as otherwise it could clear the extensions,
|
||||||
|
// leading to errors
|
||||||
|
auto act = he.action;
|
||||||
|
act();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(sym == SDLK_F1 && help != "@")
|
if(sym == SDLK_F1 && help != "@")
|
||||||
help = "@";
|
help = "@";
|
||||||
else if(uni == 'c')
|
|
||||||
help = buildCredits();
|
|
||||||
else if(uni == 't' && help_action)
|
|
||||||
help_action();
|
|
||||||
else if(doexiton(sym, uni))
|
else if(doexiton(sym, uni))
|
||||||
popScreen();
|
popScreen();
|
||||||
};
|
};
|
||||||
@ -767,6 +800,48 @@ void showHelp() {
|
|||||||
|
|
||||||
void gotoHelp(const string& h) {
|
void gotoHelp(const string& h) {
|
||||||
help = h;
|
help = h;
|
||||||
help_action = reaction_t();
|
help_extensions.clear();
|
||||||
pushScreen(showHelp);
|
pushScreen(showHelp);
|
||||||
|
if(help == "@" || help == buildHelpText())
|
||||||
|
help_extensions.push_back(help_extension{'c', XLAT("credits"), [] () { help = buildCredits(); }});
|
||||||
|
if(help == "HELPGEN") helpgenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
void subhelp(const string& h) {
|
||||||
|
string oldhelp = help;
|
||||||
|
auto ext = help_extensions;
|
||||||
|
reaction_t back = [oldhelp, ext] () {
|
||||||
|
help = oldhelp;
|
||||||
|
help_extensions = ext;
|
||||||
|
};
|
||||||
|
help = h;
|
||||||
|
help_extensions.clear();
|
||||||
|
if(help == "HELPGEN") helpgenerator();
|
||||||
|
help_extensions.push_back(help_extension{'z', XLAT("back"), back});
|
||||||
|
}
|
||||||
|
|
||||||
|
void gotoHelpFor(eLand l) {
|
||||||
|
help = generateHelpForLand(l);
|
||||||
|
|
||||||
|
int beastcount = 0;
|
||||||
|
for(int m0=0; m0<motypes; m0++)
|
||||||
|
if(isNative(l, eMonster(m0)) && !nodisplay(eMonster(m0))) beastcount++;
|
||||||
|
|
||||||
|
auto listbeasts = [l] () {
|
||||||
|
char nextmonster = 'a';
|
||||||
|
for(int m0=0; m0<motypes; m0++) {
|
||||||
|
eMonster m = eMonster(m0);
|
||||||
|
if(isNative(l, m) && !nodisplay(m))
|
||||||
|
help_extensions.push_back(help_extension{nextmonster++, XLATN(minf[m].name), [m] () {
|
||||||
|
subhelp(bygen([m] () { gotoHelpFor(m); }));
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if(beastcount > 3)
|
||||||
|
help_extensions.push_back(help_extension{'b', XLAT("bestiary of %the1", l), [l, listbeasts] () {
|
||||||
|
subhelp(helptitle(XLAT("bestiary of %the1", l), 0xC00000));
|
||||||
|
listbeasts();
|
||||||
|
}});
|
||||||
|
else listbeasts();
|
||||||
}
|
}
|
||||||
|
25
landlock.cpp
25
landlock.cpp
@ -1,5 +1,14 @@
|
|||||||
// land statistics and flags
|
// land statistics and flags
|
||||||
|
|
||||||
|
bool nodisplay(eMonster m) {
|
||||||
|
return
|
||||||
|
m == moIvyDead ||
|
||||||
|
m == moDragonTail ||
|
||||||
|
m == moWolfMoved ||
|
||||||
|
m == moIvyNext ||
|
||||||
|
m == moIvyDead;
|
||||||
|
}
|
||||||
|
|
||||||
// returns: 2 = treasure increaser, 1 = just appears, 0 = does not appear
|
// returns: 2 = treasure increaser, 1 = just appears, 0 = does not appear
|
||||||
int isNative(eLand l, eMonster m) {
|
int isNative(eLand l, eMonster m) {
|
||||||
switch(l) {
|
switch(l) {
|
||||||
@ -41,7 +50,7 @@ int isNative(eLand l, eMonster m) {
|
|||||||
return (m == moHedge || m == moFireFairy) ? 2 : 0;
|
return (m == moHedge || m == moFireFairy) ? 2 : 0;
|
||||||
|
|
||||||
case laHell:
|
case laHell:
|
||||||
return (m == moLesser) ? 2 : 0;
|
return (m == moLesser || m == moGreater) ? 2 : 0;
|
||||||
|
|
||||||
case laCocytus:
|
case laCocytus:
|
||||||
return (m == moShark || m == moGreaterShark || m == moCrystalSage) ? 2 :
|
return (m == moShark || m == moGreaterShark || m == moCrystalSage) ? 2 :
|
||||||
@ -102,7 +111,7 @@ int isNative(eLand l, eMonster m) {
|
|||||||
|
|
||||||
case laEAir: case laEEarth: case laEWater: case laEFire:
|
case laEAir: case laEEarth: case laEWater: case laEFire:
|
||||||
case laElementalWall:
|
case laElementalWall:
|
||||||
if(m == elementalOf(l)) return 2;
|
if(m == elementalOf(l) && m) return 2;
|
||||||
return (m == moAirElemental || m == moEarthElemental || m == moWaterElemental || m == moFireElemental) ? 1 : 0;
|
return (m == moAirElemental || m == moEarthElemental || m == moWaterElemental || m == moFireElemental) ? 1 : 0;
|
||||||
|
|
||||||
case laStorms:
|
case laStorms:
|
||||||
@ -115,7 +124,15 @@ int isNative(eLand l, eMonster m) {
|
|||||||
return (m == moOutlaw) ? 2 : 0;
|
return (m == moOutlaw) ? 2 : 0;
|
||||||
|
|
||||||
case laHalloween:
|
case laHalloween:
|
||||||
return 1;
|
return (m == moGhost || m == moZombie || m == moWitch ||
|
||||||
|
m == moLesser || m == moGreater ||
|
||||||
|
m == moVampire || m == moDraugr ||
|
||||||
|
m == moSkeleton || m == moWitchFire ||
|
||||||
|
m == moFlailer || m == moPyroCultist ||
|
||||||
|
m == moFatGuard || m == moHedge ||
|
||||||
|
m == moLancer || m == moFireFairy ||
|
||||||
|
m == moBomberbird || m == moRatlingAvenger ||
|
||||||
|
m == moVineBeast || m == moDragonHead || m == moDragonTail) ? 1 : 0;
|
||||||
|
|
||||||
case laClearing:
|
case laClearing:
|
||||||
return (m == moMutant || m == moRedFox) ? 1 : 0;
|
return (m == moMutant || m == moRedFox) ? 1 : 0;
|
||||||
@ -181,7 +198,7 @@ int isNative(eLand l, eMonster m) {
|
|||||||
case laDogPlains:
|
case laDogPlains:
|
||||||
return m == moHunterDog ? 1 : 0;
|
return m == moHunterDog ? 1 : 0;
|
||||||
|
|
||||||
case laCA: return false;
|
case laCA: return 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -140,10 +140,9 @@ void showOverview() {
|
|||||||
int udiv = uni / 1000;
|
int udiv = uni / 1000;
|
||||||
if(udiv == 1 && umod < landtypes) {
|
if(udiv == 1 && umod < landtypes) {
|
||||||
eLand l = eLand(umod);
|
eLand l = eLand(umod);
|
||||||
gotoHelp(generateHelpForLand(l));
|
gotoHelp(""); gotoHelpFor(l);
|
||||||
if(cheater) {
|
if(cheater) {
|
||||||
help_action_text = "teleport";
|
help_extensions.push_back(help_extension{'t', XLAT("teleport"), [l] () {
|
||||||
help_action = [l] () {
|
|
||||||
cheater++;
|
cheater++;
|
||||||
bool princ = (l == laPrincessQuest);
|
bool princ = (l == laPrincessQuest);
|
||||||
if(princ) {
|
if(princ) {
|
||||||
@ -157,7 +156,7 @@ void showOverview() {
|
|||||||
if(princ) fullcenter();
|
if(princ) fullcenter();
|
||||||
popScreen();
|
popScreen();
|
||||||
popScreen();
|
popScreen();
|
||||||
};
|
}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(udiv == 2 && umod < ittypes) {
|
else if(udiv == 2 && umod < ittypes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user