Unstable v0.19.1.0
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Barotrauma.Steam
|
||||
});
|
||||
}
|
||||
|
||||
internal static void SubscribeToServerMods(IEnumerable<UInt64> missingIds, string rejoinEndpoint, ulong rejoinLobby, string rejoinServerName)
|
||||
internal static void SubscribeToServerMods(IEnumerable<UInt64> missingIds, ConnectCommand rejoinCommand)
|
||||
{
|
||||
CloseAllMessageBoxes();
|
||||
GUIMessageBox msgBox = new GUIMessageBox(headerText: "", text: TextManager.Get("PreparingWorkshopDownloads"),
|
||||
@@ -59,9 +59,7 @@ namespace Barotrauma.Steam
|
||||
InitiateDownloads(items, onComplete: () =>
|
||||
{
|
||||
ContentPackageManager.UpdateContentPackageList();
|
||||
GameMain.Instance.ConnectEndpoint = rejoinEndpoint;
|
||||
GameMain.Instance.ConnectLobby = rejoinLobby;
|
||||
GameMain.Instance.ConnectName = rejoinServerName;
|
||||
GameMain.Instance.ConnectCommand = Option<ConnectCommand>.Some(rejoinCommand);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,7 +92,9 @@ namespace Barotrauma.Steam
|
||||
//currentLobby?.SetData("hostipaddress", lobbyIP);
|
||||
string pingLocation = Steamworks.SteamNetworkingUtils.LocalPingLocation?.ToString();
|
||||
currentLobby?.SetData("pinglocation", pingLocation ?? "");
|
||||
currentLobby?.SetData("lobbyowner", SteamIDUInt64ToString(GetSteamID()));
|
||||
currentLobby?.SetData("lobbyowner", GetSteamId().TryUnwrap(out var steamId)
|
||||
? steamId.StringRepresentation
|
||||
: throw new InvalidOperationException("Steamworks not initialized"));
|
||||
currentLobby?.SetData("haspassword", serverSettings.HasPassword.ToString());
|
||||
|
||||
currentLobby?.SetData("message", serverSettings.ServerMessageText);
|
||||
@@ -101,7 +103,6 @@ namespace Barotrauma.Steam
|
||||
currentLobby?.SetData("contentpackage", string.Join(",", contentPackages.Select(cp => cp.Name)));
|
||||
currentLobby?.SetData("contentpackagehash", string.Join(",", contentPackages.Select(cp => cp.Hash.StringRepresentation)));
|
||||
currentLobby?.SetData("contentpackageid", string.Join(",", contentPackages.Select(cp => cp.SteamWorkshopId)));
|
||||
currentLobby?.SetData("usingwhitelist", (serverSettings.Whitelist != null && serverSettings.Whitelist.Enabled).ToString());
|
||||
currentLobby?.SetData("modeselectionmode", serverSettings.ModeSelectionMode.ToString());
|
||||
currentLobby?.SetData("subselectionmode", serverSettings.SubSelectionMode.ToString());
|
||||
currentLobby?.SetData("voicechatenabled", serverSettings.VoiceChatEnabled.ToString());
|
||||
@@ -144,9 +145,10 @@ namespace Barotrauma.Steam
|
||||
lobbyID = (currentLobby?.Id).Value;
|
||||
if (joinServer)
|
||||
{
|
||||
GameMain.Instance.ConnectLobby = 0;
|
||||
GameMain.Instance.ConnectName = currentLobby?.GetData("servername");
|
||||
GameMain.Instance.ConnectEndpoint = SteamIDUInt64ToString((currentLobby?.Owner.Id).Value);
|
||||
GameMain.Instance.ConnectCommand = Option<ConnectCommand>.Some(
|
||||
new ConnectCommand(
|
||||
currentLobby?.GetData("servername") ?? "Server",
|
||||
new SteamP2PEndpoint(new SteamId(currentLobby?.Owner.Id ?? 0))));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -189,14 +191,16 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
if (string.IsNullOrEmpty(lobby.GetData("name"))) { continue; }
|
||||
|
||||
ServerInfo serverInfo = new ServerInfo();
|
||||
serverInfo.ServerName = lobby.GetData("name");
|
||||
serverInfo.OwnerID = SteamIDStringToUInt64(lobby.GetData("lobbyowner"));
|
||||
serverInfo.LobbyID = lobby.Id;
|
||||
ServerInfo serverInfo = new ServerInfo
|
||||
{
|
||||
ServerName = lobby.GetData("name"),
|
||||
Endpoint = new SteamP2PEndpoint(SteamId.Parse(lobby.GetData("lobbyowner")).Fallback(default(SteamId))),
|
||||
LobbyID = lobby.Id,
|
||||
RespondedToSteamQuery = true
|
||||
};
|
||||
bool.TryParse(lobby.GetData("haspassword"), out serverInfo.HasPassword);
|
||||
serverInfo.PlayerCount = int.TryParse(lobby.GetData("playercount"), out int playerCount) ? playerCount : 0;
|
||||
serverInfo.MaxPlayers = int.TryParse(lobby.GetData("maxplayernum"), out int maxPlayers) ? maxPlayers : 1;
|
||||
serverInfo.RespondedToSteamQuery = true;
|
||||
|
||||
AssignLobbyDataToServerInfo(lobby, serverInfo);
|
||||
|
||||
@@ -215,8 +219,7 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
ServerName = info.Name,
|
||||
HasPassword = info.Passworded,
|
||||
IP = info.Address.ToString(),
|
||||
Port = info.ConnectionPort.ToString(),
|
||||
Endpoint = new LidgrenEndpoint(info.Address, info.ConnectionPort),
|
||||
PlayerCount = info.Players,
|
||||
MaxPlayers = info.MaxPlayers,
|
||||
RespondedToSteamQuery = responsive
|
||||
@@ -316,7 +319,6 @@ namespace Barotrauma.Steam
|
||||
serverInfo.ContentPackageWorkshopIds.AddRange(WorkshopUrlsToIds(workshopUrls));
|
||||
}
|
||||
|
||||
serverInfo.UsingWhiteList = getLobbyBool("usingwhitelist");
|
||||
if (Enum.TryParse(lobby.GetData("modeselectionmode"), out SelectionMode selectionMode)) { serverInfo.ModeSelectionMode = selectionMode; }
|
||||
if (Enum.TryParse(lobby.GetData("subselectionmode"), out selectionMode)) { serverInfo.SubSelectionMode = selectionMode; }
|
||||
|
||||
@@ -365,7 +367,7 @@ namespace Barotrauma.Steam
|
||||
|
||||
if (rules.ContainsKey("playercount"))
|
||||
{
|
||||
if (int.TryParse(rules["playercount"], out int playerCount)) serverInfo.PlayerCount = playerCount;
|
||||
if (int.TryParse(rules["playercount"], out int playerCount)) { serverInfo.PlayerCount = playerCount; }
|
||||
}
|
||||
|
||||
serverInfo.ContentPackageNames.Clear();
|
||||
@@ -383,7 +385,6 @@ namespace Barotrauma.Steam
|
||||
serverInfo.ContentPackageWorkshopIds.AddRange(WorkshopUrlsToIds(workshopUrls));
|
||||
}
|
||||
|
||||
if (rules.ContainsKey("usingwhitelist")) { serverInfo.UsingWhiteList = rules["usingwhitelist"] == "True"; }
|
||||
if (rules.ContainsKey("modeselectionmode"))
|
||||
{
|
||||
if (Enum.TryParse(rules["modeselectionmode"], out SelectionMode selectionMode)) { serverInfo.ModeSelectionMode = selectionMode; }
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Barotrauma.Steam
|
||||
if (IsInitialized)
|
||||
{
|
||||
DebugConsole.NewMessage(
|
||||
$"Logged in as {GetUsername()} (SteamID {SteamIDUInt64ToString(GetSteamID())})");
|
||||
$"Logged in as {GetUsername()} (SteamID {(GetSteamId().TryUnwrap(out var steamId) ? steamId.ToString() : "[NULL]")})");
|
||||
|
||||
popularTags.Clear();
|
||||
int i = 0;
|
||||
@@ -129,7 +129,7 @@ namespace Barotrauma.Steam
|
||||
}
|
||||
|
||||
|
||||
public static bool OverlayCustomURL(string url)
|
||||
public static bool OverlayCustomUrl(string url)
|
||||
{
|
||||
if (!IsInitialized || !Steamworks.SteamClient.IsValid)
|
||||
{
|
||||
@@ -139,5 +139,10 @@ namespace Barotrauma.Steam
|
||||
Steamworks.SteamFriends.OpenWebOverlay(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void OverlayProfile(SteamId steamId)
|
||||
{
|
||||
OverlayCustomUrl($"https://steamcommunity.com/profiles/{steamId.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
OnClicked = (button, o) =>
|
||||
{
|
||||
SteamManager.OverlayCustomURL(workshopItem.Url);
|
||||
SteamManager.OverlayCustomUrl(workshopItem.Url);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -234,7 +234,7 @@ namespace Barotrauma.Steam
|
||||
|
||||
int indexOfUserDataInPublishedItemsArray(object userData)
|
||||
=> publishedItems.IndexOf(t
|
||||
=> t.WorkshopItem.Id == ((Steamworks.Ugc.Item)(userData as ItemOrPackage)).Id);
|
||||
=> t.WorkshopItem.Id == ((Steamworks.Ugc.Item)(userData as ItemOrPackage)!).Id);
|
||||
|
||||
//Take the existing GUI items that are in the list and sort to match the order of publishedItems
|
||||
var publishedGuiComponents = selfModsList.Content.Children.OrderBy(c => indexOfUserDataInPublishedItemsArray(c.UserData)).ToArray();
|
||||
@@ -582,7 +582,7 @@ namespace Barotrauma.Steam
|
||||
SelectedTextColor = GUIStyle.TextColorNormal,
|
||||
OnClicked = (button, o) =>
|
||||
{
|
||||
SteamManager.OverlayCustomURL(
|
||||
SteamManager.OverlayCustomUrl(
|
||||
$"https://steamcommunity.com/profiles/{author.Id}/myworkshopfiles/?appid={SteamManager.AppID}");
|
||||
return false;
|
||||
}
|
||||
@@ -639,9 +639,10 @@ namespace Barotrauma.Steam
|
||||
new RectTransform(Vector2.Zero, reinstallButton.RectTransform),
|
||||
onUpdate: (f, component) =>
|
||||
{
|
||||
reinstallButton.Visible = workshopItem.IsSubscribed || workshopItem.Owner.Id == SteamManager.GetSteamID();
|
||||
reinstallButton.Enabled = !workshopItem.IsDownloading && !workshopItem.IsDownloadPending &&
|
||||
!SteamManager.Workshop.IsInstalling(workshopItem);
|
||||
reinstallButton.Visible = workshopItem.IsSubscribed
|
||||
|| workshopItem.Owner.Id == SteamManager.GetSteamId().Select(steamId => steamId.Value).Fallback(0);
|
||||
reinstallButton.Enabled = !workshopItem.IsDownloading && !workshopItem.IsDownloadPending
|
||||
&& !SteamManager.Workshop.IsInstalling(workshopItem);
|
||||
|
||||
reinstallSprite.Color = reinstallButton.Enabled
|
||||
? reinstallSprite.Style.Color
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
OnClicked = (button, o) =>
|
||||
{
|
||||
SteamManager.OverlayCustomURL($"https://steamcommunity.com/app/{SteamManager.AppID}/workshop/");
|
||||
SteamManager.OverlayCustomUrl($"https://steamcommunity.com/app/{SteamManager.AppID}/workshop/");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -546,7 +546,7 @@ namespace Barotrauma.Steam
|
||||
|
||||
if (result.Value.NeedsWorkshopAgreement)
|
||||
{
|
||||
SteamManager.OverlayCustomURL(resultItem.Url);
|
||||
SteamManager.OverlayCustomUrl(resultItem.Url);
|
||||
}
|
||||
new GUIMessageBox(string.Empty, TextManager.GetWithVariable("workshopitempublished", "[itemname]", localPackage.Name));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user