diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index d61c23c6..db22f564 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -1318,15 +1318,11 @@ void close_program() { sync_prefs(); } -extern fs::path progDir; - void handle_help_toc() { if(recording){ record_action("handle_help_toc", ""); } - if(fs::is_directory(progDir/"doc")) - launchURL("file://" + (progDir/"doc/game/Contents.html").string()); - else launchURL("http://openboe.com/docs/game/Contents.html"); + launchDocs("game/Contents.html"); } void menu_give_help(short help1){ diff --git a/src/pcedit/pc.main.cpp b/src/pcedit/pc.main.cpp index 8b8b7814..51d8c0a0 100644 --- a/src/pcedit/pc.main.cpp +++ b/src/pcedit/pc.main.cpp @@ -77,7 +77,6 @@ void save_prefs(); bool prefs_event_filter (cDialog& me, std::string id, eKeyMod); extern bool cur_scen_is_mac; -extern fs::path progDir; short specials_res_id; char start_name[256]; @@ -436,9 +435,7 @@ void handle_menu_choice(eMenu item_hit) { edit_stuff_done(); break; case eMenu::HELP_TOC: - if(fs::is_directory(progDir/"doc")) - launchURL("file://" + (progDir/"doc/game/Editor.html").string()); - else launchURL("http://openboe.com/docs/game/Editor.html"); + launchDocs("game/Editor.html"); break; } } diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index c9d2de1a..317b37cb 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -427,7 +427,6 @@ void redraw_everything() { restore_cursor(); } -extern fs::path progDir; void handle_menu_choice(eMenu item_hit) { extern cUndoList undo_list; bool isEdit = false, isHelp = false; @@ -737,9 +736,7 @@ void handle_menu_choice(eMenu item_hit) { isHelp = true; break; case eMenu::HELP_TOC: - if(fs::is_directory(progDir/"doc")) - launchURL("file://" + (progDir/"doc/editor/Contents.html").string()); - else launchURL("http://openboe.com/docs/editor/Contents.html"); + launchDocs("editor/Contents.html"); break; case eMenu::HELP_START: helpDlog = "help-editing"; diff --git a/src/tools/winutil.cpp b/src/tools/winutil.cpp index ffc29132..98bd9c4b 100644 --- a/src/tools/winutil.cpp +++ b/src/tools/winutil.cpp @@ -1,5 +1,6 @@ #include "winutil.hpp" +#include #include "keymods.hpp" // The default scale should be the largest that the user's screen can fit all three @@ -48,4 +49,14 @@ bool pollEvent(sf::Window& win, sf::Event& event){ bool pollEvent(sf::Window* win, sf::Event& event){ return pollEvent(*win, event); +} + +extern fs::path progDir; + +void launchDocs(std::string relative_url) { + if(fs::is_directory(progDir/"doc")){ + launchURL("file://" + (progDir/"doc"/relative_url).string()); + }else{ + launchURL("http://openboe.com/docs/" + relative_url); + } } \ No newline at end of file diff --git a/src/tools/winutil.hpp b/src/tools/winutil.hpp index 34735279..c0dffa02 100644 --- a/src/tools/winutil.hpp +++ b/src/tools/winutil.hpp @@ -29,6 +29,9 @@ bool pollEvent(sf::Window* win, sf::Event& event); void init_fileio(); void launchURL(std::string url); +// Open a documentation page relative to packaged HTML if available, +// or openboe.com if not +void launchDocs(std::string relative_url); // Optionally do some platform-specific preprocessing on the command-line arguments before parsing them. // If preprocessing is needed, the expectation is that they will be modified in-place.