From c7e67529b59a53adac61ca4937b4aed3b3dc6c33 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 5 Dec 2025 17:40:40 +0000 Subject: [PATCH] Expose SDL_OpenURL to mod code. --- OpenRA.Game/Graphics/PlatformInterfaces.cs | 1 + OpenRA.Game/Renderer.cs | 5 +++++ OpenRA.Platforms.Default/Sdl2PlatformWindow.cs | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/OpenRA.Game/Graphics/PlatformInterfaces.cs b/OpenRA.Game/Graphics/PlatformInterfaces.cs index f4594b520a..6318d6a733 100644 --- a/OpenRA.Game/Graphics/PlatformInterfaces.cs +++ b/OpenRA.Game/Graphics/PlatformInterfaces.cs @@ -66,6 +66,7 @@ namespace OpenRA void PumpInput(IInputHandler inputHandler); string GetClipboardText(); bool SetClipboardText(string text); + bool TryOpenUrl(string url); void GrabWindowMouseFocus(); void ReleaseWindowMouseFocus(); diff --git a/OpenRA.Game/Renderer.cs b/OpenRA.Game/Renderer.cs index 6359a4b0d7..f12312e11e 100644 --- a/OpenRA.Game/Renderer.cs +++ b/OpenRA.Game/Renderer.cs @@ -568,6 +568,11 @@ namespace OpenRA return Window.SetClipboardText(text); } + public bool TryOpenUrl(string url) + { + return Window.TryOpenUrl(url); + } + public string GLVersion => Context.GLVersion; public int DisplayCount => Window.DisplayCount; diff --git a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs index c775a53b2e..7f365731b4 100644 --- a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs +++ b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs @@ -513,6 +513,18 @@ namespace OpenRA.Platforms.Default return Sdl2Input.SetClipboardText(text); } + public bool TryOpenUrl(string url) + { + try + { + return SDL.SDL_OpenURL(url) == 0; + } + catch + { + return false; + } + } + static void SetSDLAttributes(GLProfile profile) { SDL.SDL_GL_ResetAttributes();