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:
@@ -65,6 +65,11 @@ namespace OpenRCT2::Ui
|
||||
void OpenFolder(const std::string& path) override
|
||||
{
|
||||
}
|
||||
|
||||
void OpenURL(const std::string& url) override
|
||||
{
|
||||
STUB();
|
||||
}
|
||||
};
|
||||
|
||||
IPlatformUiContext* CreatePlatformUiContext()
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user