mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-28 14:49:54 +00:00
Merge pull request #183 from jruderman/land_help_wiki
Add wiki links to land help
This commit is contained in:
commit
d8eb44a9f0
4
help.cpp
4
help.cpp
@ -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);
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
15
util.cpp
15
util.cpp
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user