(6c8ca4a55) Tester's build, January 20th 2020
This commit is contained in:
@@ -1506,6 +1506,17 @@ namespace Barotrauma
|
||||
ToolBox.OpenFileWithShell(Path.GetFullPath(filePath));
|
||||
}));
|
||||
#if DEBUG
|
||||
commands.Add(new Command("querylobbies", "Queries all SteamP2P lobbies", (args) =>
|
||||
{
|
||||
Steamworks.Data.LobbyQuery lobbyQuery = Steamworks.SteamMatchmaking.CreateLobbyQuery().FilterDistanceWorldwide();
|
||||
|
||||
Steamworks.Data.Lobby[] lobbies = lobbyQuery.RequestAsync().Result;
|
||||
foreach (var lobby in lobbies)
|
||||
{
|
||||
DebugConsole.NewMessage(lobby.GetData("name") + ", " + lobby.GetData("lobbyowner"));
|
||||
}
|
||||
}));
|
||||
|
||||
commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) =>
|
||||
{
|
||||
if (args.Length != 1) return;
|
||||
@@ -2264,6 +2275,18 @@ namespace Barotrauma
|
||||
DebugConsole.NewMessage("Cannot pause when a multiplayer session is active.");
|
||||
}
|
||||
}));
|
||||
|
||||
AssignOnClientExecute("showseed|showlevelseed", (string[] args) =>
|
||||
{
|
||||
if (Level.Loaded == null)
|
||||
{
|
||||
ThrowError("No level loaded.");
|
||||
}
|
||||
else
|
||||
{
|
||||
NewMessage("Level seed: " + Level.Loaded.Seed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void ReloadWearables(Character character, int variant = 0)
|
||||
|
||||
@@ -279,6 +279,28 @@ namespace Barotrauma
|
||||
ScreenOverlayColor, true);
|
||||
}
|
||||
|
||||
#if UNSTABLE
|
||||
string line1 = "Barotrauma Unstable v" + GameMain.Version;
|
||||
string line2 = "(" + AssemblyInfo.GetBuildString() + ", branch " + AssemblyInfo.GetGitBranch() + ", revision " + AssemblyInfo.GetGitRevision() + ")";
|
||||
|
||||
Style.GetComponentStyle("OuterGlow").Sprites[GUIComponent.ComponentState.None][0].Draw(
|
||||
spriteBatch, new Rectangle(-50, GameMain.GraphicsHeight - 80, 50 + (int)(Math.Max(LargeFont.MeasureString(line1).X, Font.MeasureString(line2).X) * 1.2f), 100), Color.Black * 0.8f);
|
||||
LargeFont.DrawString(spriteBatch, line1,
|
||||
new Vector2(10, GameMain.GraphicsHeight - 30 - LargeFont.MeasureString(line1).Y), Color.White * 0.6f);
|
||||
Font.DrawString(spriteBatch, line2,
|
||||
new Vector2(10, GameMain.GraphicsHeight - 30), Color.White * 0.6f);
|
||||
|
||||
if (Screen.Selected != GameMain.GameScreen)
|
||||
{
|
||||
var buttonRect =
|
||||
new Rectangle(20 + (int)Math.Max(LargeFont.MeasureString(line1).X, Font.MeasureString(line2).X), GameMain.GraphicsHeight - (int)(45 * Scale), (int)(150 * Scale), (int)(40 * Scale));
|
||||
if (DrawButton(spriteBatch, buttonRect, "Report Bug", Style.GetComponentStyle("GUIBugButton").Color * 0.8f))
|
||||
{
|
||||
GameMain.Instance.ShowBugReporter();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (DisableHUD) { return; }
|
||||
|
||||
if (GameMain.ShowFPS || GameMain.DebugDraw)
|
||||
|
||||
@@ -1026,11 +1026,17 @@ namespace Barotrauma
|
||||
|
||||
public void ShowBugReporter()
|
||||
{
|
||||
if (GUIMessageBox.VisibleBox != null && GUIMessageBox.VisibleBox.UserData as string == "bugreporter")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("bugreportbutton"), "");
|
||||
msgBox.UserData = "bugreporter";
|
||||
var linkHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), msgBox.Content.RectTransform)) { Stretch = true, RelativeSpacing = 0.025f };
|
||||
linkHolder.RectTransform.MaxSize = new Point(int.MaxValue, linkHolder.Rect.Height);
|
||||
|
||||
#if !UNSTABLE
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), linkHolder.RectTransform), TextManager.Get("bugreportfeedbackform"), style: "MainMenuGUIButton", textAlignment: Alignment.Left)
|
||||
{
|
||||
UserData = "https://steamcommunity.com/app/602960/discussions/1/",
|
||||
@@ -1041,10 +1047,15 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), linkHolder.RectTransform), TextManager.Get("bugreportgithubform"), style: "MainMenuGUIButton", textAlignment: Alignment.Left)
|
||||
{
|
||||
#if UNSTABLE
|
||||
UserData = "https://barotraumagame.com/unstable-3rf3w5t4ter/",
|
||||
#else
|
||||
UserData = "https://github.com/Regalis11/Barotrauma/issues/new?template=bug_report.md",
|
||||
#endif
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
ShowOpenUrlInWebBrowserPrompt(userdata as string);
|
||||
|
||||
+20
-7
@@ -56,17 +56,30 @@ namespace Barotrauma.Tutorials
|
||||
radioSpeakerName = TextManager.Get("Tutorial.Radio.Watchman");
|
||||
GameMain.GameSession.CrewManager.AllowCharacterSwitch = false;
|
||||
|
||||
var revolver = captain.Inventory.FindItemByIdentifier("revolver");
|
||||
var revolver = FindOrGiveItem(captain, "revolver");
|
||||
revolver.Unequip(captain);
|
||||
captain.Inventory.RemoveItem(revolver);
|
||||
|
||||
var captainscap = captain.Inventory.FindItemByIdentifier("captainscap");
|
||||
captainscap.Unequip(captain);
|
||||
captain.Inventory.RemoveItem(captainscap);
|
||||
var captainscap =
|
||||
captain.Inventory.FindItemByIdentifier("captainscap1") ??
|
||||
captain.Inventory.FindItemByIdentifier("captainscap2") ??
|
||||
captain.Inventory.FindItemByIdentifier("captainscap3");
|
||||
|
||||
var captainsuniform = captain.Inventory.FindItemByIdentifier("captainsuniform");
|
||||
captainsuniform.Unequip(captain);
|
||||
captain.Inventory.RemoveItem(captainsuniform);
|
||||
if (captainscap != null)
|
||||
{
|
||||
captainscap.Unequip(captain);
|
||||
captain.Inventory.RemoveItem(captainscap);
|
||||
}
|
||||
|
||||
var captainsuniform =
|
||||
captain.Inventory.FindItemByIdentifier("captainsuniform1") ??
|
||||
captain.Inventory.FindItemByIdentifier("captainsuniform2") ??
|
||||
captain.Inventory.FindItemByIdentifier("captainsuniform3");
|
||||
if (captainsuniform != null)
|
||||
{
|
||||
captainsuniform.Unequip(captain);
|
||||
captain.Inventory.RemoveItem(captainsuniform);
|
||||
}
|
||||
|
||||
var steerOrder = Order.GetPrefab("steer");
|
||||
captain_steerIcon = steerOrder.SymbolSprite;
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ namespace Barotrauma.Tutorials
|
||||
radioSpeakerName = TextManager.Get("Tutorial.Radio.Speaker");
|
||||
engineer = Character.Controlled;
|
||||
|
||||
var toolbox = engineer.Inventory.FindItemByIdentifier("toolbox");
|
||||
var toolbox = FindOrGiveItem(engineer, "toolbox");
|
||||
toolbox.Unequip(engineer);
|
||||
engineer.Inventory.RemoveItem(toolbox);
|
||||
|
||||
|
||||
+2
-2
@@ -87,11 +87,11 @@ namespace Barotrauma.Tutorials
|
||||
radioSpeakerName = TextManager.Get("Tutorial.Radio.Speaker");
|
||||
mechanic = Character.Controlled;
|
||||
|
||||
var toolbox = mechanic.Inventory.FindItemByIdentifier("toolbox");
|
||||
var toolbox = FindOrGiveItem(mechanic, "toolbox");
|
||||
toolbox.Unequip(mechanic);
|
||||
mechanic.Inventory.RemoveItem(toolbox);
|
||||
|
||||
var crowbar = mechanic.Inventory.FindItemByIdentifier("crowbar");
|
||||
var crowbar = FindOrGiveItem(mechanic, "crowbar");
|
||||
crowbar.Unequip(mechanic);
|
||||
mechanic.Inventory.RemoveItem(crowbar);
|
||||
|
||||
|
||||
+4
-4
@@ -89,19 +89,19 @@ namespace Barotrauma.Tutorials
|
||||
radioSpeakerName = TextManager.Get("Tutorial.Radio.Speaker");
|
||||
officer = Character.Controlled;
|
||||
|
||||
var handcuffs = officer.Inventory.FindItemByIdentifier("handcuffs");
|
||||
var handcuffs = FindOrGiveItem(officer, "handcuffs");
|
||||
handcuffs.Unequip(officer);
|
||||
officer.Inventory.RemoveItem(handcuffs);
|
||||
|
||||
var stunbaton = officer.Inventory.FindItemByIdentifier("stunbaton");
|
||||
var stunbaton = FindOrGiveItem(officer, "stunbaton");
|
||||
stunbaton.Unequip(officer);
|
||||
officer.Inventory.RemoveItem(stunbaton);
|
||||
|
||||
var ballistichelmet = officer.Inventory.FindItemByIdentifier("ballistichelmet");
|
||||
var ballistichelmet = FindOrGiveItem(officer, "ballistichelmet");
|
||||
ballistichelmet.Unequip(officer);
|
||||
officer.Inventory.RemoveItem(ballistichelmet);
|
||||
|
||||
var bodyarmor = officer.Inventory.FindItemByIdentifier("bodyarmor");
|
||||
var bodyarmor = FindOrGiveItem(officer, "bodyarmor");
|
||||
bodyarmor.Unequip(officer);
|
||||
officer.Inventory.RemoveItem(bodyarmor);
|
||||
|
||||
|
||||
+11
@@ -298,5 +298,16 @@ namespace Barotrauma.Tutorials
|
||||
character.Bloodloss = 0.0f;
|
||||
character.SetStun(0.0f, true);
|
||||
}
|
||||
|
||||
protected Item FindOrGiveItem(Character character, string identifier)
|
||||
{
|
||||
var item = character.Inventory.FindItemByIdentifier(identifier);
|
||||
if (item != null) { return item; }
|
||||
|
||||
ItemPrefab itemPrefab = MapEntityPrefab.Find(name: null, identifier: identifier) as ItemPrefab;
|
||||
item = new Item(itemPrefab, Vector2.Zero, submarine: null);
|
||||
character.Inventory.TryPutItem(item, character);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
// show what game version the submarine was created on
|
||||
if (!IsVanillaSubmarine())
|
||||
if (!IsVanillaSubmarine() && GameVersion != null)
|
||||
{
|
||||
var versionText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), descriptionBox.Content.RectTransform),
|
||||
TextManager.Get("serverlistversion"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
|
||||
|
||||
@@ -1071,6 +1071,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (Character != null) Character.Remove();
|
||||
HasSpawned = false;
|
||||
eventErrorWritten = false;
|
||||
|
||||
while (CoroutineManager.IsCoroutineRunning("EndGame"))
|
||||
{
|
||||
@@ -2670,6 +2671,48 @@ namespace Barotrauma.Networking
|
||||
break;
|
||||
}
|
||||
clientPeer.Send(outMsg, DeliveryMethod.Reliable);
|
||||
|
||||
if (!eventErrorWritten)
|
||||
{
|
||||
WriteEventErrorData(error, expectedID, eventID, entityID);
|
||||
eventErrorWritten = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool eventErrorWritten;
|
||||
private void WriteEventErrorData(ClientNetError error, UInt16 expectedID, UInt16 eventID, UInt16 entityID)
|
||||
{
|
||||
List<string> errorLines = new List<string>
|
||||
{
|
||||
error.ToString(), ""
|
||||
};
|
||||
|
||||
if (IsServerOwner)
|
||||
{
|
||||
errorLines.Add("SERVER OWNER");
|
||||
}
|
||||
|
||||
if (error == ClientNetError.MISSING_EVENT)
|
||||
{
|
||||
errorLines.Add("Expected ID: " + expectedID + ", received " + eventID);
|
||||
}
|
||||
else if (error == ClientNetError.MISSING_ENTITY)
|
||||
{
|
||||
errorLines.Add("Event ID: " + eventID + ", entity ID " + entityID);
|
||||
}
|
||||
|
||||
errorLines.Add("Entity IDs:");
|
||||
List<Entity> sortedEntities = Entity.GetEntityList();
|
||||
sortedEntities.Sort((e1, e2) => e1.ID.CompareTo(e2.ID));
|
||||
foreach (Entity e in sortedEntities)
|
||||
{
|
||||
errorLines.Add(e.ID + ": " + e.ToString());
|
||||
}
|
||||
|
||||
string filePath = "event_error_log_client_" + Name + "_" + ToolBox.RemoveInvalidFileNameChars(DateTime.UtcNow.ToShortTimeString() + ".log");
|
||||
filePath = Path.Combine(ServerLog.SavePath, filePath);
|
||||
|
||||
File.WriteAllLines(filePath, errorLines);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Barotrauma.Networking
|
||||
public string Port;
|
||||
public string QueryPort;
|
||||
|
||||
public Steamworks.Data.PingLocation? PingLocation;
|
||||
public UInt64 LobbyID;
|
||||
public UInt64 OwnerID;
|
||||
public bool OwnerVerified;
|
||||
@@ -500,18 +501,19 @@ namespace Barotrauma.Networking
|
||||
bool.TryParse(lobby.GetData("haspassword"), out bool hasPassword);
|
||||
int.TryParse(lobby.GetData("playercount"), out int currPlayers);
|
||||
int.TryParse(lobby.GetData("maxplayernum"), out int maxPlayers);
|
||||
//UInt64.TryParse(lobby.GetData("connectsteamid"), out ulong connectSteamId);
|
||||
string ip = lobby.GetData("hostipaddress");
|
||||
UInt64 ownerId = SteamManager.SteamIDStringToUInt64(lobby.GetData("lobbyowner"));
|
||||
|
||||
if (OwnerID != ownerId) { return; }
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ip)) { ip = ""; }
|
||||
|
||||
ServerName = lobby.GetData("name");
|
||||
IP = "";
|
||||
Port = "";
|
||||
QueryPort = "";
|
||||
IP = ip;
|
||||
string pingLocation = lobby.GetData("pinglocation");
|
||||
if (!string.IsNullOrEmpty(pingLocation))
|
||||
{
|
||||
PingLocation = Steamworks.Data.PingLocation.TryParseFromString(pingLocation);
|
||||
}
|
||||
PlayerCount = currPlayers;
|
||||
MaxPlayers = maxPlayers;
|
||||
HasPassword = hasPassword;
|
||||
|
||||
@@ -110,43 +110,40 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
get { return currentLobby?.Id ?? 0; }
|
||||
}
|
||||
private static Task<Steamworks.Data.Lobby?> lobbyCreationTask;
|
||||
private static Task<Steamworks.Data.Lobby?> lobbyJoinTask;
|
||||
|
||||
public static void CreateLobby(ServerSettings serverSettings)
|
||||
{
|
||||
Steamworks.SteamMatchmaking.ResetActions();
|
||||
Steamworks.SteamMatchmaking.OnLobbyCreated += (result, lobby) =>
|
||||
{
|
||||
currentLobby = lobby;
|
||||
|
||||
if (result != Steamworks.Result.OK)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to create Steam lobby: "+result.ToString());
|
||||
lobbyState = LobbyState.NotConnected;
|
||||
return;
|
||||
}
|
||||
|
||||
DebugConsole.NewMessage("Lobby created!", Microsoft.Xna.Framework.Color.Lime);
|
||||
|
||||
lobbyState = LobbyState.Owner;
|
||||
lobbyID = lobby.Id;
|
||||
|
||||
if (serverSettings.isPublic)
|
||||
{
|
||||
lobby.SetPublic();
|
||||
}
|
||||
else
|
||||
{
|
||||
lobby.SetFriendsOnly();
|
||||
}
|
||||
lobby.SetJoinable(true);
|
||||
|
||||
UpdateLobby(serverSettings);
|
||||
};
|
||||
if (lobbyState != LobbyState.NotConnected) { return; }
|
||||
lobbyState = LobbyState.Creating;
|
||||
lobbyCreationTask = Steamworks.SteamMatchmaking.CreateLobbyAsync(serverSettings.MaxPlayers+10);
|
||||
TaskPool.Add(Steamworks.SteamMatchmaking.CreateLobbyAsync(serverSettings.MaxPlayers + 10),
|
||||
(lobby) =>
|
||||
{
|
||||
if (currentLobby == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to create Steam lobby");
|
||||
lobbyState = LobbyState.NotConnected;
|
||||
return;
|
||||
}
|
||||
|
||||
currentLobby = lobby.Result;
|
||||
|
||||
DebugConsole.NewMessage("Lobby created!", Microsoft.Xna.Framework.Color.Lime);
|
||||
|
||||
lobbyState = LobbyState.Owner;
|
||||
lobbyID = (currentLobby?.Id).Value;
|
||||
|
||||
if (serverSettings.isPublic)
|
||||
{
|
||||
currentLobby?.SetPublic();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLobby?.SetFriendsOnly();
|
||||
}
|
||||
currentLobby?.SetJoinable(true);
|
||||
|
||||
UpdateLobby(serverSettings);
|
||||
});
|
||||
}
|
||||
|
||||
public static void UpdateLobby(ServerSettings serverSettings)
|
||||
@@ -169,10 +166,11 @@ namespace Barotrauma.Steam
|
||||
var contentPackages = GameMain.Config.SelectedContentPackages.Where(cp => cp.HasMultiplayerIncompatibleContent);
|
||||
|
||||
currentLobby?.SetData("name", serverSettings.ServerName);
|
||||
currentLobby?.SetData("owner", SteamIDUInt64ToString(GetSteamID()));
|
||||
currentLobby?.SetData("playercount", (GameMain.Client?.ConnectedClients?.Count??0).ToString());
|
||||
currentLobby?.SetData("playercount", (GameMain.Client?.ConnectedClients?.Count ?? 0).ToString());
|
||||
currentLobby?.SetData("maxplayernum", serverSettings.MaxPlayers.ToString());
|
||||
//lobby?..CurrentLobbyData.SetData("connectsteamid", Steam.SteamManager.GetSteamID().ToString());
|
||||
//currentLobby?.SetData("hostipaddress", lobbyIP);
|
||||
currentLobby?.SetData("pinglocation", Steamworks.SteamNetworkingUtils.LocalPingLocation.ToString() ?? "");
|
||||
currentLobby?.SetData("lobbyowner", SteamIDUInt64ToString(GetSteamID()));
|
||||
currentLobby?.SetData("haspassword", serverSettings.HasPassword.ToString());
|
||||
|
||||
currentLobby?.SetData("message", serverSettings.ServerMessageText);
|
||||
@@ -187,9 +185,12 @@ namespace Barotrauma.Steam
|
||||
currentLobby?.SetData("voicechatenabled", serverSettings.VoiceChatEnabled.ToString());
|
||||
currentLobby?.SetData("allowspectating", serverSettings.AllowSpectating.ToString());
|
||||
currentLobby?.SetData("allowrespawn", serverSettings.AllowRespawn.ToString());
|
||||
currentLobby?.SetData("karmaenabled", serverSettings.KarmaEnabled.ToString());
|
||||
currentLobby?.SetData("friendlyfireenabled", serverSettings.AllowFriendlyFire.ToString());
|
||||
currentLobby?.SetData("traitors", serverSettings.TraitorsEnabled.ToString());
|
||||
currentLobby?.SetData("gamestarted", GameMain.Client.GameStarted.ToString());
|
||||
currentLobby?.SetData("gamemode", GameMain.NetLobbyScreen?.SelectedMode?.Identifier??"");
|
||||
currentLobby?.SetData("playstyle", serverSettings.PlayStyle.ToString());
|
||||
currentLobby?.SetData("gamemode", GameMain.NetLobbyScreen?.SelectedMode?.Identifier ?? "");
|
||||
|
||||
DebugConsole.Log("Lobby updated!");
|
||||
}
|
||||
@@ -208,30 +209,22 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
if (currentLobby.HasValue && currentLobby.Value.Id == id) { return; }
|
||||
if (lobbyID == id) { return; }
|
||||
Steamworks.SteamMatchmaking.ResetActions();
|
||||
Steamworks.SteamMatchmaking.OnLobbyEntered += (lobby) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
currentLobby = lobby;
|
||||
lobbyState = LobbyState.Joined;
|
||||
lobbyID = lobby.Id;
|
||||
if (joinServer)
|
||||
{
|
||||
GameMain.Instance.ConnectLobby = 0;
|
||||
GameMain.Instance.ConnectName = lobby.GetData("servername");
|
||||
GameMain.Instance.ConnectEndpoint = SteamIDUInt64ToString(lobby.Owner.Id.Value);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Steamworks.SteamMatchmaking.ResetActions();
|
||||
}
|
||||
};
|
||||
lobbyState = LobbyState.Joining;
|
||||
lobbyID = id;
|
||||
|
||||
lobbyJoinTask = Steamworks.SteamMatchmaking.JoinLobbyAsync(lobbyID);
|
||||
TaskPool.Add(Steamworks.SteamMatchmaking.JoinLobbyAsync(lobbyID),
|
||||
(lobby) =>
|
||||
{
|
||||
currentLobby = lobby.Result;
|
||||
lobbyState = LobbyState.Joined;
|
||||
lobbyID = (currentLobby?.Id).Value;
|
||||
if (joinServer)
|
||||
{
|
||||
GameMain.Instance.ConnectLobby = 0;
|
||||
GameMain.Instance.ConnectName = currentLobby?.GetData("servername");
|
||||
GameMain.Instance.ConnectEndpoint = SteamIDUInt64ToString((currentLobby?.Owner.Id).Value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static bool GetServers(Action<ServerInfo> addToServerList, Action serverQueryFinished)
|
||||
@@ -362,10 +355,13 @@ namespace Barotrauma.Steam
|
||||
serverInfo.AllowSpectating = getLobbyBool("allowspectating");
|
||||
serverInfo.AllowRespawn = getLobbyBool("allowrespawn");
|
||||
serverInfo.VoipEnabled = getLobbyBool("voicechatenabled");
|
||||
serverInfo.KarmaEnabled = getLobbyBool("karmaenabled");
|
||||
serverInfo.FriendlyFireEnabled = getLobbyBool("friendlyfireenabled");
|
||||
if (Enum.TryParse(lobby.GetData("traitors"), out YesNoMaybe traitorsEnabled)) { serverInfo.TraitorsEnabled = traitorsEnabled; }
|
||||
|
||||
serverInfo.GameStarted = lobby.GetData("gamestarted") == "True";
|
||||
serverInfo.GameMode = lobby.GetData("gamemode");
|
||||
if (Enum.TryParse(lobby.GetData("playstyle"), out PlayStyle playStyle)) serverInfo.PlayStyle = playStyle;
|
||||
|
||||
if (serverInfo.ContentPackageNames.Count != serverInfo.ContentPackageHashes.Count ||
|
||||
serverInfo.ContentPackageHashes.Count != serverInfo.ContentPackageWorkshopUrls.Count)
|
||||
|
||||
@@ -351,7 +351,16 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
System.Diagnostics.Process.Start(SaveUtil.SaveFolder);
|
||||
try
|
||||
{
|
||||
ToolBox.OpenFileWithShell(SaveUtil.SaveFolder);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
new GUIMessageBox(
|
||||
TextManager.Get("error"),
|
||||
TextManager.GetWithVariables("showinfoldererror", new string[] { "[folder]", "[errormessage]" }, new string[] { SaveUtil.SaveFolder, e.Message }));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -312,23 +312,9 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
var minButtonSize = new Point(120, 20);
|
||||
var maxButtonSize = new Point(480, 80);
|
||||
|
||||
/*new GUIButton(new RectTransform(new Vector2(1.0f, 0.1f), buttonsParent.RectTransform), TextManager.Get("TutorialButton"), style: "GUIButtonLarge")
|
||||
{
|
||||
UserData = Tab.Tutorials,
|
||||
OnClicked = SelectTab,
|
||||
Enabled = false
|
||||
};*/
|
||||
|
||||
/* var buttons = GUI.CreateButtons(9, new Vector2(1, 0.04f), buttonsParent.RectTransform, anchor: Anchor.BottomLeft,
|
||||
minSize: minButtonSize, maxSize: maxButtonSize, relativeSpacing: 0.005f, extraSpacing: i => i % 2 == 0 ? 20 : 0);
|
||||
buttons.ForEach(b => b.Color *= 0.8f);
|
||||
SetupButtons(buttons);
|
||||
buttons.ForEach(b => b.TextBlock.SetTextPos());*/
|
||||
|
||||
var relativeSize = new Vector2(0.6f, 0.65f);
|
||||
var minSize = new Point(600, 400);
|
||||
var maxSize = new Point(2000, 1500);
|
||||
@@ -491,7 +477,7 @@ namespace Barotrauma
|
||||
if (GameMain.Config.ShowTutorialSkipWarning)
|
||||
{
|
||||
selectedTab = 0;
|
||||
ShowTutorialSkipWarning(selectedTab);
|
||||
ShowTutorialSkipWarning(Tab.NewGame);
|
||||
return true;
|
||||
}
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
@@ -516,7 +502,7 @@ namespace Barotrauma
|
||||
if (GameMain.Config.ShowTutorialSkipWarning)
|
||||
{
|
||||
selectedTab = 0;
|
||||
ShowTutorialSkipWarning(tab);
|
||||
ShowTutorialSkipWarning(Tab.JoinServer);
|
||||
return true;
|
||||
}
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
@@ -955,8 +941,9 @@ namespace Barotrauma
|
||||
|
||||
GUI.Draw(Cam, spriteBatch);
|
||||
|
||||
#if !UNSTABLE
|
||||
GUI.Font.DrawString(spriteBatch, "Barotrauma v" + GameMain.Version + " (" + AssemblyInfo.GetBuildString() + ", branch " + AssemblyInfo.GetGitBranch() + ", revision " + AssemblyInfo.GetGitRevision() + ")", new Vector2(10, GameMain.GraphicsHeight - 20), Color.White * 0.7f);
|
||||
|
||||
#endif
|
||||
if (selectedTab != Tab.Credits)
|
||||
{
|
||||
Vector2 textPos = new Vector2(GameMain.GraphicsWidth - 10, GameMain.GraphicsHeight - 10);
|
||||
|
||||
@@ -949,28 +949,37 @@ namespace Barotrauma
|
||||
Version.TryParse(serverInfo.GameVersion, out remoteVersion);
|
||||
}
|
||||
|
||||
bool incompatible =
|
||||
(!serverInfo.ContentPackageHashes.Any() && serverInfo.ContentPackagesMatch(GameMain.Config.SelectedContentPackages)) ||
|
||||
(remoteVersion != null && !NetworkMember.IsCompatible(GameMain.Version, remoteVersion));
|
||||
//never show newer versions
|
||||
//(ignore revision number, it doesn't affect compatibility)
|
||||
if (remoteVersion != null &&
|
||||
(remoteVersion.Major > GameMain.Version.Major || remoteVersion.Minor > GameMain.Version.Minor || remoteVersion.Build > GameMain.Version.Build))
|
||||
{
|
||||
child.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool incompatible =
|
||||
(!serverInfo.ContentPackageHashes.Any() && serverInfo.ContentPackagesMatch(GameMain.Config.SelectedContentPackages)) ||
|
||||
(remoteVersion != null && !NetworkMember.IsCompatible(GameMain.Version, remoteVersion));
|
||||
|
||||
child.Visible =
|
||||
serverInfo.OwnerVerified &&
|
||||
serverInfo.ServerName.ToLowerInvariant().Contains(searchBox.Text.ToLowerInvariant()) &&
|
||||
(!filterSameVersion.Selected || (remoteVersion != null && NetworkMember.IsCompatible(remoteVersion, GameMain.Version))) &&
|
||||
(!filterPassword.Selected || !serverInfo.HasPassword) &&
|
||||
(!filterIncompatible.Selected || !incompatible) &&
|
||||
(!filterFull.Selected || serverInfo.PlayerCount < serverInfo.MaxPlayers) &&
|
||||
(!filterEmpty.Selected || serverInfo.PlayerCount > 0) &&
|
||||
(!filterWhitelisted.Selected || serverInfo.UsingWhiteList == true) &&
|
||||
(!filterKarma.Selected || serverInfo.KarmaEnabled == true) &&
|
||||
(!filterFriendlyFire.Selected || serverInfo.FriendlyFireEnabled == false) &&
|
||||
(!filterTraitor.Selected || serverInfo.TraitorsEnabled == YesNoMaybe.Yes || serverInfo.TraitorsEnabled == YesNoMaybe.Maybe) &&
|
||||
(!filterVoip.Selected || serverInfo.VoipEnabled == false) &&
|
||||
(!filterModded.Selected || serverInfo.GetPlayStyleTags().Any(t => t.Contains("modded.true"))) &&
|
||||
((selectedTab == ServerListTab.All && (serverInfo.LobbyID != 0 || !string.IsNullOrWhiteSpace(serverInfo.Port))) ||
|
||||
(selectedTab == ServerListTab.Recent && serverInfo.Recent) ||
|
||||
(selectedTab == ServerListTab.Favorites && serverInfo.Favorite)) &&
|
||||
(remoteVersion != null && remoteVersion <= GameMain.Version);
|
||||
child.Visible =
|
||||
serverInfo.OwnerVerified &&
|
||||
serverInfo.ServerName.ToLowerInvariant().Contains(searchBox.Text.ToLowerInvariant()) &&
|
||||
(!filterSameVersion.Selected || (remoteVersion != null && NetworkMember.IsCompatible(remoteVersion, GameMain.Version))) &&
|
||||
(!filterPassword.Selected || !serverInfo.HasPassword) &&
|
||||
(!filterIncompatible.Selected || !incompatible) &&
|
||||
(!filterFull.Selected || serverInfo.PlayerCount < serverInfo.MaxPlayers) &&
|
||||
(!filterEmpty.Selected || serverInfo.PlayerCount > 0) &&
|
||||
(!filterWhitelisted.Selected || serverInfo.UsingWhiteList == true) &&
|
||||
(!filterKarma.Selected || serverInfo.KarmaEnabled == true) &&
|
||||
(!filterFriendlyFire.Selected || serverInfo.FriendlyFireEnabled == false) &&
|
||||
(!filterTraitor.Selected || serverInfo.TraitorsEnabled == YesNoMaybe.Yes || serverInfo.TraitorsEnabled == YesNoMaybe.Maybe) &&
|
||||
(!filterVoip.Selected || serverInfo.VoipEnabled == false) &&
|
||||
(!filterModded.Selected || serverInfo.GetPlayStyleTags().Any(t => t.Contains("modded.true"))) &&
|
||||
((selectedTab == ServerListTab.All && (serverInfo.LobbyID != 0 || !string.IsNullOrWhiteSpace(serverInfo.Port))) ||
|
||||
(selectedTab == ServerListTab.Recent && serverInfo.Recent) ||
|
||||
(selectedTab == ServerListTab.Favorites && serverInfo.Favorite));
|
||||
}
|
||||
|
||||
foreach (GUITickBox tickBox in playStyleTickBoxes)
|
||||
{
|
||||
@@ -1673,6 +1682,14 @@ namespace Barotrauma
|
||||
DebugConsole.ThrowError("Ping is null", ex);
|
||||
}
|
||||
}
|
||||
else if (serverInfo.PingLocation != null)
|
||||
{
|
||||
Steamworks.Data.PingLocation pingLocation = serverInfo.PingLocation.Value;
|
||||
serverInfo.Ping = Steamworks.SteamNetworkingUtils.LocalPingLocation?.EstimatePingTo(pingLocation) ?? -1;
|
||||
serverInfo.PingChecked = true;
|
||||
serverPingText.TextColor = GetPingTextColor(serverInfo.Ping);
|
||||
serverPingText.Text = serverInfo.Ping > -1 ? serverInfo.Ping.ToString() : "?";
|
||||
}
|
||||
|
||||
if (serverInfo.LobbyID == 0 && (string.IsNullOrWhiteSpace(serverInfo.IP) || string.IsNullOrWhiteSpace(serverInfo.Port)))
|
||||
{
|
||||
|
||||
@@ -278,13 +278,13 @@ namespace Barotrauma
|
||||
{
|
||||
//filter out the items published by the player (they're shown in the publish tab)
|
||||
var mySteamID = SteamManager.GetSteamID();
|
||||
OnItemsReceived(items.Where(it => it.Owner.Id != mySteamID).ToList(), subscribedItemList);
|
||||
OnItemsReceived(GetVisibleItems(items.Where(it => it.Owner.Id != mySteamID)), subscribedItemList);
|
||||
});
|
||||
}
|
||||
|
||||
private void RefreshPopularItems()
|
||||
{
|
||||
SteamManager.GetPopularWorkshopItems((items) => { OnItemsReceived(items, topItemList); }, 20);
|
||||
SteamManager.GetPopularWorkshopItems((items) => { OnItemsReceived(GetVisibleItems(items), topItemList); }, 20);
|
||||
}
|
||||
|
||||
private void RefreshPublishedItems()
|
||||
@@ -293,6 +293,17 @@ namespace Barotrauma
|
||||
RefreshMyItemList();
|
||||
}
|
||||
|
||||
private IEnumerable<Steamworks.Ugc.Item> GetVisibleItems(IEnumerable<Steamworks.Ugc.Item> items)
|
||||
{
|
||||
#if UNSTABLE
|
||||
//show everything in Unstable
|
||||
return items;
|
||||
#else
|
||||
//hide Unstable items in normal version
|
||||
return items.Where(it => !it.HasTag("unstable"));
|
||||
#endif
|
||||
}
|
||||
|
||||
private void RefreshMyItemList()
|
||||
{
|
||||
myItemList.ClearChildren();
|
||||
@@ -341,7 +352,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void OnItemsReceived(IList<Steamworks.Ugc.Item> itemDetails, GUIListBox listBox)
|
||||
private void OnItemsReceived(IEnumerable<Steamworks.Ugc.Item> itemDetails, GUIListBox listBox)
|
||||
{
|
||||
CrossThread.RequestExecutionOnMainThread(() =>
|
||||
{
|
||||
@@ -351,7 +362,7 @@ namespace Barotrauma
|
||||
CreateWorkshopItemFrame(item, listBox);
|
||||
}
|
||||
|
||||
if (itemDetails.Count == 0 && listBox == subscribedItemList)
|
||||
if (itemDetails.Count() == 0 && listBox == subscribedItemList)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.9f, 0.9f), listBox.Content.RectTransform, Anchor.Center), TextManager.Get("NoSubscribedMods"), wrap: true)
|
||||
{
|
||||
@@ -1530,11 +1541,30 @@ namespace Barotrauma
|
||||
|
||||
private void PublishWorkshopItem()
|
||||
{
|
||||
if (itemContentPackage == null || itemEditor == null) return;
|
||||
|
||||
if (itemContentPackage == null || itemEditor == null) { return; }
|
||||
|
||||
#if UNSTABLE
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("warning"), TextManager.Get("unstableworkshopitempublishwarning"),
|
||||
new string[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
msgBox.Buttons[0].OnClicked = (btn, userdata) =>
|
||||
{
|
||||
var workshopPublishStatus = SteamManager.StartPublishItem(itemContentPackage, itemEditor);
|
||||
if (workshopPublishStatus != null)
|
||||
{
|
||||
if (!itemEditor.Value.Tags.Contains("unstable")) { itemEditor.Value.Tags.Add("unstable"); }
|
||||
CoroutineManager.StartCoroutine(WaitForPublish(workshopPublishStatus), "WaitForPublish");
|
||||
}
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||
#else
|
||||
var workshopPublishStatus = SteamManager.StartPublishItem(itemContentPackage, itemEditor);
|
||||
if (workshopPublishStatus == null) { return; }
|
||||
if (itemEditor.Value.Tags.Contains("unstable")) { itemEditor.Value.Tags.Remove("unstable"); }
|
||||
CoroutineManager.StartCoroutine(WaitForPublish(workshopPublishStatus), "WaitForPublish");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
private IEnumerable<object> WaitForPublish(SteamManager.WorkshopPublishStatus workshopPublishStatus)
|
||||
@@ -1591,7 +1621,7 @@ namespace Barotrauma
|
||||
SelectTab(Tab.Browse);
|
||||
}
|
||||
|
||||
#region UI management
|
||||
#region UI management
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
{
|
||||
@@ -1613,6 +1643,6 @@ namespace Barotrauma
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,6 +353,19 @@ namespace Barotrauma.Sounds
|
||||
private uint[] unqueuedBuffers;
|
||||
private float[] streamBufferAmplitudes;
|
||||
|
||||
public int StreamSeekPos
|
||||
{
|
||||
get { return streamSeekPos; }
|
||||
set
|
||||
{
|
||||
if (!IsStream)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot set StreamSeekPos on a non-streaming sound channel.");
|
||||
}
|
||||
streamSeekPos = Math.Max(value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private object mutex;
|
||||
|
||||
public bool IsPlaying
|
||||
|
||||
@@ -39,6 +39,9 @@ namespace Barotrauma
|
||||
|
||||
public readonly Vector2 IntensityRange;
|
||||
|
||||
public readonly bool ContinueFromPreviousTime;
|
||||
public int PreviousTime;
|
||||
|
||||
public readonly XElement Element;
|
||||
|
||||
public BackgroundMusic(XElement element)
|
||||
@@ -47,6 +50,7 @@ namespace Barotrauma
|
||||
this.Type = element.GetAttributeString("type", "").ToLowerInvariant();
|
||||
this.IntensityRange = element.GetAttributeVector2("intensityrange", new Vector2(0.0f, 100.0f));
|
||||
this.DuckVolume = element.GetAttributeBool("duckvolume", false);
|
||||
this.ContinueFromPreviousTime = element.GetAttributeBool("continuefromprevioustime", false);
|
||||
this.Element = element;
|
||||
}
|
||||
}
|
||||
@@ -681,6 +685,10 @@ namespace Barotrauma
|
||||
DisposeMusicChannel(i);
|
||||
currentMusic[i] = GameMain.SoundManager.LoadSound(targetMusic[i].File, true);
|
||||
musicChannel[i] = currentMusic[i].Play(0.0f, "music");
|
||||
if (targetMusic[i].ContinueFromPreviousTime)
|
||||
{
|
||||
musicChannel[i].StreamSeekPos = targetMusic[i].PreviousTime;
|
||||
}
|
||||
musicChannel[i].Looping = true;
|
||||
}
|
||||
}
|
||||
@@ -705,6 +713,12 @@ namespace Barotrauma
|
||||
|
||||
private static void DisposeMusicChannel(int index)
|
||||
{
|
||||
var clip = musicClips.Find(m => m.File == musicChannel[index]?.Sound?.Filename);
|
||||
if (clip != null)
|
||||
{
|
||||
if (clip.ContinueFromPreviousTime) { clip.PreviousTime = musicChannel[index].StreamSeekPos; }
|
||||
}
|
||||
|
||||
musicChannel[index]?.Dispose(); musicChannel[index] = null;
|
||||
currentMusic[index]?.Dispose(); currentMusic[index] = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user