Add wiki links to land help

This commit is contained in:
Jesse Ruderman 2021-07-03 19:38:20 -07:00
parent 7f8d978beb
commit ff7be8d4e0
2 changed files with 19 additions and 0 deletions

View File

@ -1182,5 +1182,9 @@ EX void gotoHelpFor(eLand l) {
help_extensions.push_back(help_extension{'t', XLAT("Galápagos shading"), [] () {
tortoise::shading_enabled = !tortoise::shading_enabled;
}});
help_extensions.push_back(help_extension{'w', XLAT("wiki"), [l] () {
open_wiki(linf[l].name);
}});
}
}

View File

@ -724,4 +724,19 @@ EX void open_url(string s) {
#endif
}
const char *urlhex = "0123456789ABCDEF";
EX void open_wiki(const char *title) {
string url = "https://hyperrogue.miraheze.org/wiki/";
unsigned char c;
for (size_t i = 0; (c = title[i]); ++i) {
if (('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '_' || c == '-')
url += c;
else if (c == ' ')
url += "_";
else
url += string("%") + urlhex[c/16] + urlhex[c%16];
}
open_url(url);
}
}