Changeset - r28205:3e71ed293456
[Not reviewed]
master
0 10 0
rubidium42 - 12 months ago 2023-11-29 00:17:05
rubidium@openttd.org
Codechange: pass std::string references to OpenBrowser
10 files changed with 19 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/help_gui.cpp
Show inline comments
 
@@ -145,16 +145,16 @@ struct HelpWindow : public Window {
 
				new GameManualTextfileWindow(LICENSE_FILENAME);
 
				break;
 
			case WID_HW_WEBSITE:
 
				OpenBrowser(WEBSITE_LINK.c_str());
 
				OpenBrowser(WEBSITE_LINK);
 
				break;
 
			case WID_HW_WIKI:
 
				OpenBrowser(WIKI_LINK.c_str());
 
				OpenBrowser(WIKI_LINK);
 
				break;
 
			case WID_HW_BUGTRACKER:
 
				OpenBrowser(BUGTRACKER_LINK.c_str());
 
				OpenBrowser(BUGTRACKER_LINK);
 
				break;
 
			case WID_HW_COMMUNITY:
 
				OpenBrowser(COMMUNITY_LINK.c_str());
 
				OpenBrowser(COMMUNITY_LINK);
 
				break;
 
		}
 
	}
src/network/network_content_gui.cpp
Show inline comments
 
@@ -384,7 +384,7 @@ class NetworkContentListWindow : public 
 
			}
 
		}
 

	
 
		OpenBrowser(url.c_str());
 
		OpenBrowser(url);
 
	}
 

	
 
	/**
 
@@ -855,7 +855,7 @@ public:
 

	
 
			case WID_NCL_OPEN_URL:
 
				if (this->selected != nullptr) {
 
					OpenBrowser(this->selected->url.c_str());
 
					OpenBrowser(this->selected->url);
 
				}
 
				break;
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -2501,7 +2501,7 @@ struct NetworkAskSurveyWindow : public W
 
				break;
 

	
 
			case WID_NAS_LINK:
 
				OpenBrowser(NETWORK_SURVEY_DETAILS_LINK.c_str());
 
				OpenBrowser(NETWORK_SURVEY_DETAILS_LINK);
 
				break;
 

	
 
			case WID_NAS_NO:
src/openttd.cpp
Show inline comments
 
@@ -94,7 +94,7 @@ bool HandleBootstrap();
 

	
 
extern void AfterLoadCompanyStats();
 
extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY);
 
extern void OSOpenBrowser(const char *url);
 
extern void OSOpenBrowser(const std::string &url);
 
extern void RebuildTownCaches();
 
extern void ShowOSErrorBox(const char *buf, bool system);
 
extern std::string _config_file;
 
@@ -370,7 +370,7 @@ void MakeNewgameSettingsLive()
 
	}
 
}
 

	
 
void OpenBrowser(const char *url)
 
void OpenBrowser(const std::string &url)
 
{
 
	/* Make sure we only accept urls that are sure to open a browser. */
 
	if (StrStartsWith(url, "http://") || StrStartsWith(url, "https://")) {
src/openttd.h
Show inline comments
 
@@ -90,7 +90,7 @@ void SwitchToMode(SwitchMode new_mode);
 
bool RequestNewGRFScan(struct NewGRFScanCallback *callback = nullptr);
 
void GenerateSavegameId();
 

	
 
void OpenBrowser(const char *url);
 
void OpenBrowser(const std::string &url);
 
void ChangeAutosaveFrequency(bool reset);
 

	
 
#endif /* OPENTTD_H */
src/os/macosx/macos.mm
Show inline comments
 
@@ -143,9 +143,9 @@ void ShowOSErrorBox(const char *buf, boo
 
	}
 
}
 

	
 
void OSOpenBrowser(const char *url)
 
void OSOpenBrowser(const std::string &url)
 
{
 
	[ [ NSWorkspace sharedWorkspace ] openURL:[ NSURL URLWithString:[ NSString stringWithUTF8String:url ] ] ];
 
	[ [ NSWorkspace sharedWorkspace ] openURL:[ NSURL URLWithString:[ NSString stringWithUTF8String:url.c_str() ] ] ];
 
}
 

	
 
/**
src/os/unix/unix.cpp
Show inline comments
 
@@ -230,20 +230,20 @@ std::optional<std::string> GetClipboardC
 

	
 

	
 
#if defined(__EMSCRIPTEN__)
 
void OSOpenBrowser(const char *url)
 
void OSOpenBrowser(const std::string &url)
 
{
 
	/* Implementation in pre.js */
 
	EM_ASM({ if(window["openttd_open_url"]) window.openttd_open_url($0, $1) }, url, strlen(url));
 
	EM_ASM({ if (window["openttd_open_url"]) window.openttd_open_url($0, $1) }, url.c_str(), url.size());
 
}
 
#elif !defined( __APPLE__)
 
void OSOpenBrowser(const char *url)
 
void OSOpenBrowser(const std::string &url)
 
{
 
	pid_t child_pid = fork();
 
	if (child_pid != 0) return;
 

	
 
	const char *args[3];
 
	args[0] = "xdg-open";
 
	args[1] = url;
 
	args[1] = url.c_str();
 
	args[2] = nullptr;
 
	execvp(args[0], const_cast<char * const *>(args));
 
	Debug(misc, 0, "Failed to open url: {}", url);
src/os/windows/win32.cpp
Show inline comments
 
@@ -52,7 +52,7 @@ void ShowOSErrorBox(const char *buf, boo
 
	MessageBox(GetActiveWindow(), OTTD2FS(buf).c_str(), L"Error!", MB_ICONSTOP | MB_TASKMODAL);
 
}
 

	
 
void OSOpenBrowser(const char *url)
 
void OSOpenBrowser(const std::string &url)
 
{
 
	ShellExecute(GetActiveWindow(), L"open", OTTD2FS(url).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
 
}
src/settings_gui.cpp
Show inline comments
 
@@ -495,7 +495,7 @@ struct GameOptionsWindow : Window {
 
				break;
 

	
 
			case WID_GO_SURVEY_LINK_BUTTON:
 
				OpenBrowser(NETWORK_SURVEY_DETAILS_LINK.c_str());
 
				OpenBrowser(NETWORK_SURVEY_DETAILS_LINK);
 
				break;
 

	
 
			case WID_GO_SURVEY_PREVIEW_BUTTON:
src/textfile_gui.cpp
Show inline comments
 
@@ -406,7 +406,7 @@ void TextfileWindow::NavigateHistory(int
 
		}
 

	
 
		case HyperlinkType::Web:
 
			OpenBrowser(link.destination.c_str());
 
			OpenBrowser(link.destination);
 
			break;
 

	
 
		case HyperlinkType::File:
0 comments (0 inline, 0 general)