Unstable 0.1300.0.5

This commit is contained in:
Markus Isberg
2021-04-01 16:09:18 +03:00
parent 862221635c
commit 96b2184811
54 changed files with 429 additions and 122 deletions
@@ -403,7 +403,7 @@ namespace Barotrauma
if (GameMain.Client != null) { chatMessage += " " + TextManager.Get("DeathChatNotification"); }
if (GameMain.GameSession?.GameMode is CampaignMode && GameMain.NetworkMember.RespawnManager != null && Level.Loaded?.Type != LevelData.LevelType.Outpost)
if (GameMain.NetworkMember.RespawnManager?.UseRespawnPrompt ?? false)
{
CoroutineManager.InvokeAfter(() =>
{
@@ -11,8 +11,9 @@ using System.Linq;
namespace Barotrauma
{
class CharacterHUD
{
const float BossHealthBarDuration = 30.0f;
{
const float BossHealthBarDuration = 1200.0f;
class BossHealthBar
{
public readonly Character Character;
@@ -35,14 +36,25 @@ namespace Barotrauma
RelativeOffset = new Vector2(0.0f, 0.01f)
}, isHorizontal: false, childAnchor: Anchor.TopCenter);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), TopContainer.RectTransform), character.DisplayName, textAlignment: Alignment.Center, textColor: GUI.Style.Red);
TopHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.6f), TopContainer.RectTransform), barSize: 0.0f, style: "CharacterHealthBarCentered");
TopHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.6f), TopContainer.RectTransform)
{
MinSize = new Point(100, HUDLayoutSettings.HealthBarArea.Size.Y)
}, barSize: 0.0f, style: "CharacterHealthBarCentered")
{
Color = GUI.Style.Red
};
SideContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), bossHealthContainer.RectTransform)
{
MinSize = new Point(80, 60)
}, isHorizontal: false, childAnchor: Anchor.TopRight);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), SideContainer.RectTransform), character.DisplayName, textAlignment: Alignment.CenterRight, textColor: GUI.Style.Red);
SideHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.7f), SideContainer.RectTransform), barSize: 0.0f, style: "CharacterHealthBar");
SideHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.7f), SideContainer.RectTransform), barSize: 0.0f, style: "CharacterHealthBar")
{
Color = GUI.Style.Red
};
TopContainer.Visible = SideContainer.Visible = false;
}
}
@@ -537,6 +549,8 @@ namespace Barotrauma
public static void ShowBossHealthBar(Character character)
{
if (character == null || character.IsDead || character.Removed) { return; }
var existingBar = bossHealthBars.Find(b => b.Character == character);
if (existingBar != null)
{
@@ -578,33 +592,29 @@ namespace Barotrauma
float health = bossHealthBar.Character.Vitality / bossHealthBar.Character.MaxVitality;
float alpha = Math.Min(bossHealthBar.FadeTimer, 1.0f);
foreach (var c in bossHealthBar.TopContainer.GetAllChildren())
foreach (var c in bossHealthBar.SideContainer.GetAllChildren().Concat(bossHealthBar.TopContainer.GetAllChildren()))
{
c.Color = new Color(c.Color, (byte)(alpha * 255));
if (c is GUITextBlock textBlock)
{
textBlock.TextColor = new Color(textBlock.TextColor, (byte)(alpha * 255));
}
}
foreach (var c in bossHealthBar.SideContainer.GetAllChildren())
{
c.Color = new Color(c.Color, (byte)(alpha * 255));
if (c is GUITextBlock textBlock)
{
textBlock.TextColor = new Color(textBlock.TextColor, (byte)(alpha * 255));
textBlock.TextColor = new Color(bossHealthBar.Character.IsDead ? Color.Gray : textBlock.TextColor, (byte)(alpha * 255));
}
}
bossHealthBar.TopHealthBar.BarSize = bossHealthBar.SideHealthBar.BarSize = health;
bossHealthBar.TopHealthBar.Color = bossHealthBar.SideHealthBar.Color =
ToolBox.GradientLerp(health, GUI.Style.HealthBarColorLow, GUI.Style.HealthBarColorMedium, GUI.Style.HealthBarColorHigh) * alpha;
if (bossHealthBar.Character.IsDead || bossHealthBar.Character.Removed)
if (bossHealthBar.Character.Removed || !bossHealthBar.Character.Enabled)
{
bossHealthBar.FadeTimer = Math.Min(bossHealthBar.FadeTimer, 1.0f);
}
else if (bossHealthBar.Character.IsDead)
{
bossHealthBar.FadeTimer = Math.Min(bossHealthBar.FadeTimer, 5.0f);
}
else if (bossHealthBar.Character.AIController is EnemyAIController enemyAI && !enemyAI.IsTargetingPlayerTeam)
{
bossHealthBar.FadeTimer = Math.Min(bossHealthBar.FadeTimer, 10.0f);
}
bossHealthBar.FadeTimer -= deltaTime;
}
@@ -1721,6 +1721,15 @@ namespace Barotrauma
{
GameMain.Client?.ForceTimeOut();
}, isCheat: false));
commands.Add(new Command("bumpitem", "", (string[] args) =>
{
float vel = 10.0f;
if (args.Length > 0)
{
float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out vel);
}
Character.Controlled?.FocusedItem?.body?.ApplyLinearImpulse(Rand.Vector(vel));
}, isCheat: false));
#endif
@@ -2275,12 +2284,15 @@ namespace Barotrauma
"revokeperm",
(string[] args) =>
{
if (args.Length < 1) return;
if (args.Length < 1) { return; }
NewMessage("Valid permissions are:", Color.White);
foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions)))
if (args.Length < 2)
{
NewMessage(" - " + permission.ToString(), Color.White);
NewMessage("Valid permissions are:", Color.White);
foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions)))
{
NewMessage(" - " + permission.ToString(), Color.White);
}
}
ShowQuestionPrompt("Permission to revoke from client " + args[0] + "?", (perm) =>
@@ -390,11 +390,15 @@ namespace Barotrauma
{
foreach (var data in msgText.RichTextData)
{
msgText.ClickableAreas.Add(new GUITextBlock.ClickableArea()
var clickableArea = new GUITextBlock.ClickableArea()
{
Data = data,
OnClick = GameMain.NetLobbyScreen.SelectPlayer
});
Data = data
};
if (GameMain.NetLobbyScreen != null && GameMain.NetworkMember != null)
{
clickableArea.OnClick = GameMain.NetLobbyScreen.SelectPlayer;
}
msgText.ClickableAreas.Add(clickableArea);
}
}
@@ -218,6 +218,21 @@ namespace Barotrauma
public static bool DisableHUD, DisableUpperHUD, DisableItemHighlights, DisableCharacterNames;
private static bool isSavingIndicatorEnabled;
private static Color savingIndicatorColor = Color.Transparent;
private static bool IsSavingIndicatorVisible => savingIndicatorColor.A > 0;
private static float savingIndicatorSpriteIndex;
private static float savingIndicatorColorLerpAmount;
private static SavingIndicatorState savingIndicatorState = SavingIndicatorState.None;
private static float? timeUntilSavingIndicatorDisabled;
private enum SavingIndicatorState
{
None,
FadingIn,
FadingOut
}
public static void Init(GameWindow window, IEnumerable<ContentPackage> selectedContentPackages, GraphicsDevice graphicsDevice)
{
GraphicsDevice = graphicsDevice;
@@ -345,7 +360,11 @@ namespace Barotrauma
}
#endif
if (DisableHUD) { return; }
if (DisableHUD)
{
DrawSavingIndicator(spriteBatch);
return;
}
if (GameMain.ShowFPS || GameMain.DebugDraw)
{
@@ -627,6 +646,8 @@ namespace Barotrauma
}
}
DrawSavingIndicator(spriteBatch);
if (GameMain.WindowActive && !HideCursor)
{
spriteBatch.End();
@@ -1206,6 +1227,7 @@ namespace Barotrauma
Debug.Assert(updateList.Count == updateListSet.Count);
updateList.ForEach(c => c.UpdateAuto(deltaTime));
UpdateMessages(deltaTime);
UpdateSavingIndicator(deltaTime);
}
}
@@ -1250,6 +1272,58 @@ namespace Barotrauma
}
private static void UpdateSavingIndicator(float deltaTime)
{
lock (mutex)
{
if (timeUntilSavingIndicatorDisabled.HasValue)
{
timeUntilSavingIndicatorDisabled -= deltaTime;
if (timeUntilSavingIndicatorDisabled <= 0.0f)
{
isSavingIndicatorEnabled = false;
timeUntilSavingIndicatorDisabled = null;
}
}
if (isSavingIndicatorEnabled)
{
if (savingIndicatorColor == Color.Transparent)
{
savingIndicatorState = SavingIndicatorState.FadingIn;
savingIndicatorColorLerpAmount = 0.0f;
}
else if (savingIndicatorColor == Color.White)
{
savingIndicatorState = SavingIndicatorState.None;
}
}
else
{
if (savingIndicatorColor == Color.White)
{
savingIndicatorState = SavingIndicatorState.FadingOut;
savingIndicatorColorLerpAmount = 0.0f;
}
else if (savingIndicatorColor == Color.Transparent)
{
savingIndicatorState = SavingIndicatorState.None;
}
}
if (savingIndicatorState != SavingIndicatorState.None)
{
bool isFadingIn = savingIndicatorState == SavingIndicatorState.FadingIn;
Color lerpStartColor = isFadingIn ? Color.Transparent : Color.White;
Color lerpTargetColor = isFadingIn ? Color.White : Color.Transparent;
savingIndicatorColorLerpAmount += (isFadingIn ? 2.0f : 0.5f) * deltaTime;
savingIndicatorColor = Color.Lerp(lerpStartColor, lerpTargetColor, savingIndicatorColorLerpAmount);
}
if (IsSavingIndicatorVisible)
{
savingIndicatorSpriteIndex = (savingIndicatorSpriteIndex + 15.0f * deltaTime) % (Style.SavingIndicator.FrameCount + 1);
}
}
}
#region Element drawing
private static List<float> usedIndicatorAngles = new List<float>();
@@ -1574,6 +1648,14 @@ namespace Barotrauma
ShapeExtensions.DrawPoint(spriteBatch, pos, color, dotSize);
}
}
private static void DrawSavingIndicator(SpriteBatch spriteBatch)
{
if (!IsSavingIndicatorVisible) { return; }
var sheet = Style.SavingIndicator;
Vector2 pos = new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) - new Vector2(HUDLayoutSettings.Padding) - 2 * Scale * sheet.FrameSize.ToVector2();
sheet.Draw(spriteBatch, (int)Math.Floor(savingIndicatorSpriteIndex), pos, savingIndicatorColor, origin: Vector2.Zero, rotate: 0.0f, scale: new Vector2(Scale));
}
#endregion
#region Element creation
@@ -2327,6 +2409,21 @@ namespace Barotrauma
float aspectRatio = HorizontalAspectRatio;
return aspectRatio > 1.3f && aspectRatio < 1.4f;
}
public static void SetSavingIndicatorState(bool enabled)
{
if (enabled)
{
timeUntilSavingIndicatorDisabled = null;
}
isSavingIndicatorEnabled = enabled;
}
public static void DisableSavingIndicatorDelayed(float delay = 3.0f)
{
if (!isSavingIndicatorEnabled) { return; }
timeUntilSavingIndicatorDisabled = delay;
}
#endregion
}
}
@@ -427,6 +427,9 @@ namespace Barotrauma
foreach (var type in messageBoxTypes)
{
// Don't display hints when HUD is disabled
if (type == Type.Hint && GUI.DisableHUD) { continue; }
for (int i = 0; i < MessageBoxes.Count; i++)
{
if (MessageBoxes[i] == null) { continue; }
@@ -506,7 +509,7 @@ namespace Barotrauma
else
{
initialPos = new Vector2(GUI.IntScale(64), -InnerFrame.Rect.Height);
defaultPos = new Vector2(initialPos.X, HUDLayoutSettings.MessageAreaTop.Height + GUI.IntScale(64));
defaultPos = new Vector2(initialPos.X, HUDLayoutSettings.ButtonAreaTop.Height + GUI.IntScale(64));
endPos = new Vector2(-InnerFrame.Rect.Width, defaultPos.Y);
}
@@ -37,6 +37,8 @@ namespace Barotrauma
public UISprite RadiationSprite { get; private set; }
public SpriteSheet RadiationAnimSpriteSheet { get; private set; }
public SpriteSheet SavingIndicator { get; private set; }
public UISprite UIGlow { get; private set; }
public UISprite UIGlowCircular { get; private set; }
@@ -248,6 +250,9 @@ namespace Barotrauma
case "focusindicator":
FocusIndicator = new SpriteSheet(subElement);
break;
case "savingindicator":
SavingIndicator = new SpriteSheet(subElement);
break;
case "font":
Font = LoadFont(subElement, graphicsDevice);
ForceFontUpperCase[Font] = subElement.GetAttributeBool("forceuppercase", false);
@@ -128,7 +128,7 @@ namespace Barotrauma
int messageAreaWidth = GameMain.GraphicsWidth / 3;
MessageAreaTop = new Rectangle((GameMain.GraphicsWidth - messageAreaWidth) / 2, ButtonAreaTop.Bottom, messageAreaWidth, ButtonAreaTop.Height);
MessageAreaTop = new Rectangle((GameMain.GraphicsWidth - messageAreaWidth) / 2, ButtonAreaTop.Bottom + ButtonAreaTop.Height, messageAreaWidth, ButtonAreaTop.Height);
bool isFourByThree = GUI.IsFourByThree();
int chatBoxWidth = !isFourByThree ? (int)(475 * GUI.Scale) : (int)(375 * GUI.Scale);
@@ -1066,6 +1066,8 @@ namespace Barotrauma
{
if (save)
{
GUI.SetSavingIndicatorState(true);
if (GameSession.Submarine != null && !GameSession.Submarine.Removed)
{
GameSession.SubmarineInfo = new SubmarineInfo(GameSession.Submarine);
@@ -233,15 +233,20 @@ namespace Barotrauma
{
endRoundButton.RectTransform.ScreenSpaceOffset = new Point(0, Character.Controlled.CharacterHealth.SuicideButton.Rect.Height);
}
else if (GameMain.Client != null && GameMain.Client.IsFollowSubTickBoxVisible)
{
endRoundButton.RectTransform.ScreenSpaceOffset = new Point(0, HUDLayoutSettings.Padding + GameMain.Client.FollowSubTickBox.Rect.Height);
}
else
{
endRoundButton.RectTransform.ScreenSpaceOffset = Point.Zero;
}
}
endRoundButton.DrawManually(spriteBatch);
if (this is MultiPlayerCampaign)
if (this is MultiPlayerCampaign && ReadyCheckButton != null)
{
ReadyCheckButton?.DrawManually(spriteBatch);
ReadyCheckButton.RectTransform.ScreenSpaceOffset = endRoundButton.RectTransform.ScreenSpaceOffset;
ReadyCheckButton.DrawManually(spriteBatch);
}
}
@@ -227,6 +227,11 @@ namespace Barotrauma
float timer = 0.0f;
while (timer < textDuration)
{
if (GameMain.GameSession == null || Screen.Selected != GameMain.GameScreen)
{
GUI.DisableHUD = false;
yield return CoroutineStatus.Success;
}
// Try to grab the controlled here to prevent inputs, assigned late on multiplayer
if (Character.Controlled != null)
{
@@ -321,6 +326,7 @@ namespace Barotrauma
Level prevLevel = Level.Loaded;
bool success = CrewManager.GetCharacters().Any(c => !c.IsDead);
GUI.SetSavingIndicatorState(success);
crewDead = false;
var continueButton = GameMain.GameSession.RoundSummary?.ContinueButton;
@@ -378,6 +384,7 @@ namespace Barotrauma
}
}
GUI.SetSavingIndicatorState(false);
yield return CoroutineStatus.Success;
}
@@ -217,6 +217,7 @@ namespace Barotrauma
if (!savedOnStart)
{
GUI.SetSavingIndicatorState(true);
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
savedOnStart = true;
}
@@ -228,6 +229,8 @@ namespace Barotrauma
{
PetBehavior.LoadPets(petsElement);
}
GUI.DisableSavingIndicatorDelayed();
}
protected override void LoadInitialLevel()
@@ -294,6 +297,11 @@ namespace Barotrauma
break;
}
}
if (GameMain.GameSession == null)
{
GUI.DisableHUD = false;
yield return CoroutineStatus.Success;
}
overlayTextColor = Color.Lerp(Color.Transparent, Color.White, (timer - 1.0f) / fadeInDuration);
timer = Math.Min(timer + CoroutineManager.DeltaTime, textDuration);
yield return CoroutineStatus.Running;
@@ -377,6 +385,7 @@ namespace Barotrauma
bool success = CrewManager.GetCharacters().Any(c => !c.IsDead);
SoundPlayer.OverrideMusicType = success ? "endround" : "crewdead";
SoundPlayer.OverrideMusicDuration = 18.0f;
GUI.SetSavingIndicatorState(success);
crewDead = false;
GameMain.GameSession.EndRound("", traitorResults, transitionType);
@@ -486,6 +495,7 @@ namespace Barotrauma
overlayColor = Color.Transparent;
});
GUI.SetSavingIndicatorState(false);
yield return CoroutineStatus.Success;
}
@@ -106,6 +106,11 @@ namespace Barotrauma.Items.Components
DeattachFromWall();
}
else
{
item.SetTransform(simPosition, 0.0f);
item.Submarine = sub;
}
}
}
}
@@ -705,7 +705,7 @@ namespace Barotrauma.Items.Components
if (c.Params.HideInSonar) { continue; }
if (!c.IsUnconscious && c.Params.DistantSonarRange > 0.0f &&
c.AIController is EnemyAIController enemyAI && enemyAI.IsTargetingPlayer &&
c.AIController is EnemyAIController enemyAI && enemyAI.IsTargetingPlayerTeam &&
((c.WorldPosition - transducerCenter) * displayScale).LengthSquared() > DisplayRadius * DisplayRadius)
{
float dist = Vector2.Distance(c.WorldPosition, transducerCenter);
@@ -4,6 +4,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
@@ -268,7 +269,7 @@ namespace Barotrauma
{
foreach (string idStr in itemIdStrings[i].Split(';'))
{
if (!int.TryParse(idStr, out int id)) { continue; }
if (!int.TryParse(idStr, NumberStyles.Any, CultureInfo.InvariantCulture, out int id)) { continue; }
if (id != 0 && !ids.Contains(id)) { ids.Add(id); }
}
}
@@ -304,7 +305,9 @@ namespace Barotrauma
float rotation = element.GetAttributeFloat("rotation", 0f);
MapEntityPrefab prefab = MapEntityPrefab.List.First(p => p.Identifier.Equals(identifier, StringComparison.OrdinalIgnoreCase));
MapEntityPrefab prefab = MapEntityPrefab.List.FirstOrDefault(p => p.Identifier.Equals(identifier, StringComparison.OrdinalIgnoreCase));
if (prefab == null) { return; }
var texture = prefab.sprite.Texture;
var srcRect = prefab.sprite.SourceRect;
@@ -366,6 +369,12 @@ namespace Barotrauma
}
else if (itemPrefab != null)
{
bool usePrefabValues = element.GetAttributeBool("isoverride", false) != itemPrefab.IsOverride;
if (usePrefabValues)
{
scale = itemPrefab.ConfigElement.GetAttributeFloat(scale, "scale", "Scale");
}
ParseUpgrades(itemPrefab.ConfigElement, ref scale);
if (prefab.ResizeVertical || prefab.ResizeHorizontal)
@@ -494,7 +503,7 @@ namespace Barotrauma
var doorSpriteElem = subElement.Elements().FirstOrDefault(e => e.Name.LocalName.Equals("sprite", StringComparison.OrdinalIgnoreCase));
if (doorSpriteElem != null)
{
string texturePath = subElement.GetAttributeString("texture", "");
string texturePath = doorSpriteElem.GetAttributeString("texture", "");
Vector2 pos = rect.Location.ToVector2() * new Vector2(1f, -1f);
if (subElement.GetAttributeBool("horizontal", false))
{
@@ -539,11 +548,17 @@ namespace Barotrauma
if (scaleModifier.StartsWith("*"))
{
scale *= float.Parse(scaleModifier.Substring(1));
if (float.TryParse(scaleModifier.Substring(1), NumberStyles.Any, CultureInfo.InvariantCulture, out float parsedScale))
{
scale *= parsedScale;
}
}
else
{
scale = float.Parse(scaleModifier);
if (float.TryParse(scaleModifier, NumberStyles.Any, CultureInfo.InvariantCulture, out float parsedScale))
{
scale = parsedScale;
}
}
}
}
@@ -557,14 +572,19 @@ namespace Barotrauma
if (!spriteRecorder.ReadyToRender)
{
string waitText = "Generating preview...";
string waitText = !loadTask.IsCompleted ?
"Generating preview..." :
(loadTask.Exception?.ToString() ?? "Task completed without marking as ready to render");
Vector2 origin = (GUI.Font.MeasureString(waitText) * 0.5f);
origin.X = MathF.Round(origin.X);
origin.Y = MathF.Round(origin.Y);
GUI.Font.DrawString(
spriteBatch,
waitText,
scissorRectangle.Center.ToVector2(),
Color.White,
0f,
GUI.Font.MeasureString(waitText) * 0.5f,
origin,
1f,
SpriteEffects.None,
0f);
@@ -56,6 +56,11 @@ namespace Barotrauma.Networking
public readonly NetStats NetStats;
protected GUITickBox cameraFollowsSub;
public GUITickBox FollowSubTickBox => cameraFollowsSub;
public bool IsFollowSubTickBoxVisible =>
gameStarted && Screen.Selected == GameMain.GameScreen &&
cameraFollowsSub != null && cameraFollowsSub.Visible;
public CameraTransition EndCinematic;
@@ -2095,7 +2100,7 @@ namespace Barotrauma.Networking
serverSettings.ClientRead(settingsBuf);
if (!IsServerOwner)
{
ServerInfo info = GameMain.ServerListScreen.UpdateServerInfoWithServerSettings(serverEndpoint, serverSettings);
ServerInfo info = serverSettings.GetServerListInfo();
GameMain.ServerListScreen.AddToRecentServers(info);
GameMain.NetLobbyScreen.Favorite.Visible = true;
GameMain.NetLobbyScreen.Favorite.Selected = GameMain.ServerListScreen.IsFavorite(info);
@@ -567,5 +567,10 @@ namespace Barotrauma.Networking
(other.LobbyID == LobbyID || other.LobbyID == 0 || LobbyID == 0) &&
((OwnerID == 0) ? (other.IP == IP && other.Port == Port) : true);
}
public bool MatchesByEndpoint(ServerInfo other)
{
return OwnerID == other.OwnerID && (OwnerID != 0 ? true : (IP == other.IP && Port == other.Port));
}
}
}
@@ -126,6 +126,8 @@ namespace Barotrauma.Networking
public void ClientRead(IReadMessage incMsg)
{
cachedServerListInfo = null;
ServerName = incMsg.ReadString();
ServerMessageText = incMsg.ReadString();
MaxPlayers = incMsg.ReadByte();
@@ -928,6 +930,7 @@ namespace Barotrauma.Networking
public bool ToggleSettingsFrame(GUIButton button, object obj)
{
if (GameMain.NetworkMember == null) { return false; }
if (settingsFrame == null)
{
CreateSettingsFrame();
@@ -949,5 +952,12 @@ namespace Barotrauma.Networking
return false;
}
private ServerInfo cachedServerListInfo = null;
public ServerInfo GetServerListInfo()
{
cachedServerListInfo ??= GameMain.ServerListScreen.UpdateServerInfoWithServerSettings(GameMain.Client.ClientPeer.ServerConnection, this);
return cachedServerListInfo;
}
}
}
@@ -683,7 +683,7 @@ namespace Barotrauma
ToolTip = TextManager.Get("addtofavorites"),
OnSelected = (tickbox) =>
{
ServerInfo info = GameMain.ServerListScreen.UpdateServerInfoWithServerSettings(GameMain.Client.ClientPeer.ServerConnection.EndPointString, GameMain.Client.ServerSettings);
ServerInfo info = GameMain.Client.ServerSettings.GetServerListInfo();
if (tickbox.Selected)
{
GameMain.ServerListScreen.AddToFavoriteServers(info);
@@ -138,7 +138,7 @@ namespace Barotrauma
private bool masterServerResponded;
private IRestResponse masterServerResponse;
private readonly float[] columnRelativeWidth = new float[] { 0.1f, 0.1f, 0.7f, 0.12f, 0.08f, 0.08f };
private readonly string[] columnLabel = new string[] { "ServerListCompatible", "ServerListHasPassword", "ServerListName", "ServerListRoundStarted", "ServerListPlayers", "ServerListPing" };
@@ -779,28 +779,19 @@ namespace Barotrauma
doc.SaveSafe(file);
}
public ServerInfo UpdateServerInfoWithServerSettings(object endpoint, ServerSettings serverSettings)
public ServerInfo UpdateServerInfoWithServerSettings(NetworkConnection endpoint, ServerSettings serverSettings)
{
UInt64 steamId = 0;
string ip = ""; string port = "";
if (endpoint is UInt64 id) { steamId = id; }
else if (endpoint is string strEndpoint)
if (endpoint is SteamP2PConnection steamP2PConnection) { steamId = steamP2PConnection.SteamID; }
else if (endpoint is LidgrenConnection lidgrenConnection)
{
string[] address = strEndpoint.Split(':');
if (address.Length == 1)
{
ip = strEndpoint;
port = NetConfig.DefaultPort.ToString();
}
else
{
ip = string.Join(":", address.Take(address.Length - 1));
port = address[address.Length - 1];
}
ip = lidgrenConnection.IPString;
port = lidgrenConnection.Port.ToString();
}
bool isInfoNew = false;
ServerInfo info = serverList.Content.FindChild(d => (d.UserData is ServerInfo serverInfo) && serverInfo != null &&
ServerInfo info = serverList.Content.FindChild(d => (d.UserData is ServerInfo serverInfo) &&
(steamId != 0 ? steamId == serverInfo.OwnerID : (ip == serverInfo.IP && port == serverInfo.Port)))?.UserData as ServerInfo;
if (info == null)
{
@@ -849,7 +840,7 @@ namespace Barotrauma
}
info.Recent = true;
ServerInfo existingInfo = recentServers.Find(serverInfo => info.OwnerID == serverInfo.OwnerID && (info.OwnerID != 0 ? true : (info.IP == serverInfo.IP && info.Port == serverInfo.Port)));
ServerInfo existingInfo = recentServers.Find(info.MatchesByEndpoint);
if (existingInfo == null)
{
recentServers.Add(info);
@@ -865,13 +856,13 @@ namespace Barotrauma
public bool IsFavorite(ServerInfo info)
{
return favoriteServers.Any(serverInfo => info.OwnerID == serverInfo.OwnerID && (info.OwnerID != 0 ? true : (info.IP == serverInfo.IP && info.Port == serverInfo.Port)));
return favoriteServers.Any(info.MatchesByEndpoint);
}
public void AddToFavoriteServers(ServerInfo info)
{
info.Favorite = true;
ServerInfo existingInfo = favoriteServers.Find(serverInfo => info.OwnerID == serverInfo.OwnerID && (info.OwnerID != 0 ? true : (info.IP == serverInfo.IP && info.Port == serverInfo.Port)));
ServerInfo existingInfo = favoriteServers.Find(info.MatchesByEndpoint);
if (existingInfo == null)
{
favoriteServers.Add(info);
@@ -888,7 +879,7 @@ namespace Barotrauma
public void RemoveFromFavoriteServers(ServerInfo info)
{
info.Favorite = false;
ServerInfo existingInfo = favoriteServers.Find(serverInfo => info.OwnerID == serverInfo.OwnerID && (info.OwnerID != 0 ? true : (info.IP == serverInfo.IP && info.Port == serverInfo.Port)));
ServerInfo existingInfo = favoriteServers.Find(info.MatchesByEndpoint);
if (existingInfo != null)
{
favoriteServers.Remove(existingInfo);
@@ -1263,8 +1254,7 @@ namespace Barotrauma
};
var serverFrame = serverList.Content.FindChild(d => (d.UserData is ServerInfo info) &&
info.OwnerID == serverInfo.OwnerID &&
(serverInfo.OwnerID != 0 ? true : (info.IP == serverInfo.IP && info.Port == serverInfo.Port)));
info.MatchesByEndpoint(serverInfo));
if (serverFrame != null)
{