1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Add OpenURL method, with implementation for Linux and Windows

This commit is contained in:
Michał Janiszewski
2020-07-26 21:57:56 +02:00
parent 8217acd86f
commit 352870b503
8 changed files with 31 additions and 0 deletions

View File

@@ -65,6 +65,11 @@ namespace OpenRCT2::Ui
void OpenFolder(const std::string& path) override
{
}
void OpenURL(const std::string& url) override
{
STUB();
}
};
IPlatformUiContext* CreatePlatformUiContext()

View File

@@ -119,6 +119,12 @@ namespace OpenRCT2::Ui
Execute(cmd);
}
void OpenURL(const std::string& url) override
{
std::string cmd = String::Format("xdg-open %s", url.c_str());
Execute(cmd);
}
std::string ShowFileDialog(SDL_Window* window, const FileDialogDesc& desc) override
{
std::string result;

View File

@@ -97,6 +97,12 @@ namespace OpenRCT2::Ui
ShellExecuteW(NULL, L"open", pathW.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
void OpenURL(const std::string& url) override
{
std::wstring urlW = String::ToWideChar(url);
ShellExecuteW(NULL, L"open", urlW.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
std::string ShowFileDialog(SDL_Window* window, const FileDialogDesc& desc) override
{
std::wstring wcFilename = String::ToWideChar(desc.DefaultFilename);

View File

@@ -609,6 +609,11 @@ public:
_platformUiContext->OpenFolder(path);
}
void OpenURL(const std::string& url) override
{
_platformUiContext->OpenURL(url);
}
std::string ShowFileDialog(const FileDialogDesc& desc) override
{
return _platformUiContext->ShowFileDialog(_window, desc);

View File

@@ -34,6 +34,7 @@ namespace OpenRCT2
virtual void ShowMessageBox(SDL_Window * window, const std::string& message) abstract;
virtual void OpenFolder(const std::string& path) abstract;
virtual void OpenURL(const std::string& url) abstract;
virtual std::string ShowFileDialog(SDL_Window * window, const FileDialogDesc& desc) abstract;
virtual std::string ShowDirectoryDialog(SDL_Window * window, const std::string& title) abstract;
};

View File

@@ -68,6 +68,10 @@ namespace OpenRCT2::Ui
}
}
void OpenURL(const std::string& url) override
{
}
std::string ShowFileDialog(SDL_Window* window, const FileDialogDesc& desc) override
{
@autoreleasepool {

View File

@@ -92,6 +92,9 @@ namespace OpenRCT2::Ui
void OpenFolder(const std::string& /*path*/) override
{
}
void OpenURL(const std::string& /*url*/) override
{
}
std::string ShowFileDialog(const FileDialogDesc& /*desc*/) override
{
return std::string();

View File

@@ -113,6 +113,7 @@ namespace OpenRCT2
virtual void ShowMessageBox(const std::string& message) abstract;
virtual void OpenFolder(const std::string& path) abstract;
virtual void OpenURL(const std::string& url) abstract;
virtual std::string ShowFileDialog(const FileDialogDesc& desc) abstract;
virtual std::string ShowDirectoryDialog(const std::string& title) abstract;