DRY launch doc url

This commit is contained in:
2025-02-06 20:00:19 -06:00
committed by Celtic Minstrel
parent 5804d84012
commit c20dbbf88e
5 changed files with 17 additions and 13 deletions

View File

@@ -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){

View File

@@ -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;
}
}

View File

@@ -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";

View File

@@ -1,5 +1,6 @@
#include "winutil.hpp"
#include <boost/filesystem/operations.hpp>
#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);
}
}

View File

@@ -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.