diff --git a/Barotrauma/BarotraumaClient/Source/Networking/SteamManager.cs b/Barotrauma/BarotraumaClient/Source/Networking/SteamManager.cs index 3d76093fb..5ec4a4699 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/SteamManager.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/SteamManager.cs @@ -107,6 +107,56 @@ namespace Barotrauma.Steam return true; } + public static bool GetFavouriteServers(Action onServerFound, Action onServerRulesReceived, Action onFinished) + { + if (instance == null || !instance.isInitialized) + { + return false; + } + + var filter = new ServerList.Filter + { + { "appid", AppID.ToString() }, + { "gamedir", "Barotrauma" }, + { "secure", "1" } + }; + + //include unresponsive servers in the server list + + //the response is queried using the server's query port, not the game port, + //so it may be possible to play on the server even if it doesn't respond to server list queries + var query = instance.client.ServerList.Favourites(filter); + query.OnUpdate += () => { UpdateServerQuery(query, onServerFound, onServerRulesReceived, includeUnresponsive: true); }; + query.OnFinished = onFinished; + + return true; + } + + public static bool GetServersFromHistory(Action onServerFound, Action onServerRulesReceived, Action onFinished) + { + if (instance == null || !instance.isInitialized) + { + return false; + } + + var filter = new ServerList.Filter + { + { "appid", AppID.ToString() }, + { "gamedir", "Barotrauma" }, + { "secure", "1" } + }; + + //include unresponsive servers in the server list + + //the response is queried using the server's query port, not the game port, + //so it may be possible to play on the server even if it doesn't respond to server list queries + var query = instance.client.ServerList.History(filter); + query.OnUpdate += () => { UpdateServerQuery(query, onServerFound, onServerRulesReceived, includeUnresponsive: true); }; + query.OnFinished = onFinished; + + return true; + } + private static void UpdateServerQuery(ServerList.Request query, Action onServerFound, Action onServerRulesReceived, bool includeUnresponsive) { IEnumerable servers = includeUnresponsive ? diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs index 89cbf2ef2..a9918309b 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs @@ -43,6 +43,7 @@ namespace Barotrauma private ContentPackage itemContentPackage; private Facepunch.Steamworks.Workshop.Editor itemEditor; + //private Facepunch.Steamworks.Overlay overlay; public SteamWorkshopScreen() { @@ -637,6 +638,12 @@ namespace Barotrauma OutlineColor = new Color(72, 124, 77, 255), OnClicked = (btn, userdata) => { + // Failed attempt, might have to be activated before accessing because as of now it just throws a null for overlay + /*if (overlay.Enabled) + { + overlay.OpenUrl("steam://url/CommunityFilePage/" + item.Id); + }*/ + System.Diagnostics.Process.Start("steam://url/CommunityFilePage/" + item.Id); return true; }