diff --git a/help.cpp b/help.cpp index 3a519e87..4f8485d0 100644 --- a/help.cpp +++ b/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); + }}); } } diff --git a/util.cpp b/util.cpp index b840b525..14e58523 100644 --- a/util.cpp +++ b/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); +} + }