Skip to content

Commit

Permalink
xrGame: Use xdg-open to open url links on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Zegeri committed Sep 16, 2018
1 parent e04dd5f commit e5da009
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/xrGame/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@

#include "ui/UICDkey.h"

#ifdef WINDOWS
#include <shellapi.h>
#pragma comment(lib, "shell32.lib")
#endif

#include "Common/object_broker.h"

Expand Down Expand Up @@ -848,9 +850,14 @@ void CMainMenu::OnDownloadMPMap_CopyURL(CUIWindow* w, void* d)
void CMainMenu::OnDownloadMPMap(CUIWindow* w, void* d)
{
LPCSTR url = m_downloaded_mp_map_url.c_str();
#ifdef WINDOWS
LPCSTR params = NULL;
STRCONCAT(params, "/C start ", url);
ShellExecute(0, "open", "cmd.exe", params, NULL, SW_SHOW);
#else
std::string command = "xdg-open " + std::string{url};
system(command.c_str());
#endif
}

demo_info const* CMainMenu::GetDemoInfo(LPCSTR file_name)
Expand Down
5 changes: 5 additions & 0 deletions src/xrGame/login_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,14 @@ bool login_manager::get_remember_me_from_registry()

void login_manager::forgot_password(char const* url)
{
#ifdef WINDOWS
LPCSTR params = NULL;
STRCONCAT(params, "/C start ", url);
ShellExecute(0, "open", "cmd.exe", params, NULL, SW_SHOW);
#else
std::string command = "xdg-open " + std::string{url};
system(command.c_str());
#endif
}

} // namespace gamespy_gp

0 comments on commit e5da009

Please sign in to comment.