Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop
This commit is contained in:
@@ -166,7 +166,7 @@ namespace Barotrauma
|
||||
// check if the store can afford the item
|
||||
if (store.Balance < itemValue) { continue; }
|
||||
// TODO: Write logic for prioritizing certain items over others (e.g. lone Battery Cell should be preferred over one inside a Stun Baton)
|
||||
var matchingItems = sellableItems.Where(i => i.Prefab == item.ItemPrefab);
|
||||
var matchingItems = sellableItems.Where(i => i.Prefab.Identifier == item.ItemPrefabIdentifier);
|
||||
int count = Math.Min(item.Quantity, matchingItems.Count());
|
||||
SoldItem.SellOrigin origin = sellingMode == Store.StoreTab.Sell ? SoldItem.SellOrigin.Character : SoldItem.SellOrigin.Submarine;
|
||||
if (origin == SoldItem.SellOrigin.Character || GameMain.IsSingleplayer)
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Barotrauma
|
||||
|
||||
/// <summary>
|
||||
/// This property stores the preference in settings. Don't use for automatic logic.
|
||||
/// Use AutoShowCrewList(), AutoHideCrewList(), and ResetCrewList().
|
||||
/// Use AutoHideCrewList(), and ResetCrewList().
|
||||
/// </summary>
|
||||
public bool IsCrewMenuOpen
|
||||
{
|
||||
@@ -62,11 +62,9 @@ namespace Barotrauma
|
||||
|
||||
public static bool PreferCrewMenuOpen = true;
|
||||
|
||||
public bool AutoShowCrewList() => _isCrewMenuOpen = true;
|
||||
|
||||
public void AutoHideCrewList() => _isCrewMenuOpen = false;
|
||||
|
||||
public void ResetCrewList() => _isCrewMenuOpen = PreferCrewMenuOpen;
|
||||
public void ResetCrewListOpenState() => _isCrewMenuOpen = PreferCrewMenuOpen;
|
||||
|
||||
const float CommandNodeAnimDuration = 0.2f;
|
||||
|
||||
@@ -195,6 +193,12 @@ namespace Barotrauma
|
||||
|
||||
ChatBox.InputBox.OnTextChanged += ChatBox.TypingChatMessage;
|
||||
}
|
||||
else if (GameMain.Client == null)
|
||||
{
|
||||
//this method would throw a non-descriptive nullref exception later when trying to access the chatbox
|
||||
//if we'd try to continue from here, better to throw a more descriptive one at this point
|
||||
throw new InvalidOperationException($"Attempted to initialize {nameof(CrewManager)} for multiplayer, but no multiplayer client is active. Are you trying to load a multiplayer save in singleplayer?");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -308,6 +312,14 @@ namespace Barotrauma
|
||||
|
||||
#region Character list management
|
||||
|
||||
/// <summary>
|
||||
/// Note: this is only works client-side. TODO: make it work server-side too?
|
||||
/// </summary>
|
||||
public IEnumerable<Character> GetCharacters()
|
||||
{
|
||||
return characters;
|
||||
}
|
||||
|
||||
public Rectangle GetActiveCrewArea()
|
||||
{
|
||||
return crewArea.Rect;
|
||||
@@ -1357,6 +1369,16 @@ namespace Barotrauma
|
||||
{
|
||||
GameSession.TabMenuInstance.SelectInfoFrameTab(TabMenu.SelectedTab);
|
||||
}
|
||||
if (character.SelectedItem?.GetComponent<Controller>() == null && character.SelectedCharacter == null)
|
||||
{
|
||||
ResetCrewListOpenState();
|
||||
ChatBox.ResetChatBoxOpenState();
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoHideCrewList();
|
||||
ChatBox.AutoHideChatBox();
|
||||
}
|
||||
}
|
||||
|
||||
private int TryAdjustIndex(int amount)
|
||||
@@ -1919,7 +1941,7 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GameMain.GameSession?.CrewManager == null)
|
||||
if (GameMain.GameSession?.CrewManager == null || Screen.Selected is { IsEditor: true })
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -3700,7 +3722,7 @@ namespace Barotrauma
|
||||
bool hasLeaks = Character.Controlled.CurrentHull.ConnectedGaps.Any(g => !g.IsRoomToRoom && g.Open > 0.0f);
|
||||
ToggleReportButton("reportbreach", hasLeaks);
|
||||
|
||||
bool hasIntruders = Character.CharacterList.Any(c => c.CurrentHull == Character.Controlled.CurrentHull && AIObjectiveFightIntruders.IsValidTarget(c, Character.Controlled, false));
|
||||
bool hasIntruders = Character.CharacterList.Any(c => c.CurrentHull == Character.Controlled.CurrentHull && AIObjectiveFightIntruders.IsValidTarget(c, Character.Controlled, targetCharactersInOtherSubs: false));
|
||||
ToggleReportButton("reportintruders", hasIntruders);
|
||||
|
||||
foreach (GUIComponent reportButton in ReportButtonFrame.Children)
|
||||
@@ -3826,5 +3848,72 @@ namespace Barotrauma
|
||||
GameMain.GameSession?.CrewManager?.AddOrder(order, fadeOutTime);
|
||||
}
|
||||
}
|
||||
|
||||
private class CharacterInfoComparer : IEqualityComparer<CharacterInfo>
|
||||
{
|
||||
public bool Equals(CharacterInfo x, CharacterInfo y)
|
||||
{
|
||||
if (ReferenceEquals(x, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x is null || y is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return x.ID == y.ID;
|
||||
}
|
||||
|
||||
public int GetHashCode(CharacterInfo obj)
|
||||
{
|
||||
return obj.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateReserveBenchIfNeeded(IEnumerable<CharacterInfo> updatedReserveBench)
|
||||
{
|
||||
var newBench = updatedReserveBench.ToHashSet(new CharacterInfoComparer());
|
||||
var currentBench = reserveBench.ToHashSet(new CharacterInfoComparer());
|
||||
|
||||
bool updateNeeded = !newBench.SetEquals(currentBench);
|
||||
if (updateNeeded)
|
||||
{
|
||||
reserveBench.Clear(); // since this is the reserve bench (characters not instantiated), there's no need to retain any references etc
|
||||
reserveBench.AddRange(updatedReserveBench);
|
||||
}
|
||||
|
||||
return updateNeeded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will update which CharacterInfos should be in CrewManager and which shouldn't, excluding the reserve bench.
|
||||
/// The CharacterInfos themselves aren't updated, they will only be either added, removed, or kept as-is.
|
||||
/// </summary>
|
||||
public bool UpdateCrewManagerIfNecessary(List<CharacterInfo> updatedCrewManager)
|
||||
{
|
||||
// CharacterInfos no longer in the server's CrewManager
|
||||
var toRemove = characterInfos.Where(original => updatedCrewManager.None(updated => updated.ID == original.ID)).ToList();
|
||||
// CharacterInfos that are in the server's CrewManager but not on the client yet
|
||||
var toAdd = updatedCrewManager.Where(updated => characterInfos.None(original => original.ID == updated.ID)).ToList();
|
||||
|
||||
foreach (CharacterInfo characterInfo in toRemove)
|
||||
{
|
||||
if (characterInfo.Character is Character existingCharacter)
|
||||
{
|
||||
if (!existingCharacter.IsBot) { continue; } // on client side players are also stored here, we should skip those in this case
|
||||
RemoveCharacter(characterInfo.Character, removeInfo: true, resetCrewListIndex: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
characterInfos.Remove(characterInfo);
|
||||
}
|
||||
}
|
||||
|
||||
characterInfos.AddRange(toAdd);
|
||||
|
||||
return toRemove.Count > 0 || toAdd.Count > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ namespace Barotrauma
|
||||
default:
|
||||
ShowCampaignUI = true;
|
||||
CampaignUI.SelectTab(npc.CampaignInteractionType, npc);
|
||||
CampaignUI.UpgradeStore?.RequestRefresh();
|
||||
CampaignUI.UpgradeStore?.RequestRefresh(refreshUpgrades: true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+61
-22
@@ -532,6 +532,7 @@ namespace Barotrauma
|
||||
|
||||
bool isFirstRound = msg.ReadBoolean();
|
||||
byte campaignID = msg.ReadByte();
|
||||
byte roundId = msg.ReadByte();
|
||||
UInt16 saveID = msg.ReadUInt16();
|
||||
string mapSeed = msg.ReadString();
|
||||
|
||||
@@ -553,7 +554,7 @@ namespace Barotrauma
|
||||
|
||||
if (requiredFlags.HasFlag(NetFlags.Misc))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (Misc)");
|
||||
DebugConsole.Log("Received campaign update (Misc), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
bool purchasedHullRepairs = msg.ReadBoolean();
|
||||
bool purchasedItemRepairs = msg.ReadBoolean();
|
||||
@@ -571,7 +572,7 @@ namespace Barotrauma
|
||||
|
||||
if (requiredFlags.HasFlag(NetFlags.MapAndMissions))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (MapAndMissions)");
|
||||
DebugConsole.Log("Received campaign update (MapAndMissions), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
bool forceMapUI = msg.ReadBoolean();
|
||||
bool allowDebugTeleport = msg.ReadBoolean();
|
||||
@@ -634,7 +635,7 @@ namespace Barotrauma
|
||||
|
||||
if (requiredFlags.HasFlag(NetFlags.SubList))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (SubList)");
|
||||
DebugConsole.Log("Received campaign update (SubList), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
ushort ownedSubCount = msg.ReadUInt16();
|
||||
List<ushort> ownedSubIndices = new List<ushort>();
|
||||
@@ -679,7 +680,7 @@ namespace Barotrauma
|
||||
|
||||
if (requiredFlags.HasFlag(NetFlags.UpgradeManager))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (UpgradeManager)");
|
||||
DebugConsole.Log("Received campaign update (UpgradeManager), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
|
||||
ushort pendingUpgradeCount = msg.ReadUInt16();
|
||||
@@ -737,7 +738,7 @@ namespace Barotrauma
|
||||
|
||||
if (requiredFlags.HasFlag(NetFlags.ItemsInBuyCrate))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (ItemsInBuyCrate)");
|
||||
DebugConsole.Log("Received campaign update (ItemsInBuyCrate), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
var buyCrateItems = ReadPurchasedItems(msg, sender: null);
|
||||
if (ShouldApply(NetFlags.ItemsInBuyCrate, id, requireUpToDateSave: true))
|
||||
@@ -753,7 +754,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (requiredFlags.HasFlag(NetFlags.ItemsInSellFromSubCrate))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (ItemsInSellFromSubCrate)");
|
||||
DebugConsole.Log("Received campaign update (ItemsInSellFromSubCrate), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
var subSellCrateItems = ReadPurchasedItems(msg, sender: null);
|
||||
if (ShouldApply(NetFlags.ItemsInSellFromSubCrate, id, requireUpToDateSave: true))
|
||||
@@ -769,7 +770,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (requiredFlags.HasFlag(NetFlags.PurchasedItems))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (PuchasedItems)");
|
||||
DebugConsole.Log("Received campaign update (PuchasedItems), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
var purchasedItems = ReadPurchasedItems(msg, sender: null);
|
||||
if (ShouldApply(NetFlags.PurchasedItems, id, requireUpToDateSave: true))
|
||||
@@ -785,7 +786,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (requiredFlags.HasFlag(NetFlags.SoldItems))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (SoldItems)");
|
||||
DebugConsole.Log("Received campaign update (SoldItems), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
var soldItems = ReadSoldItems(msg);
|
||||
if (ShouldApply(NetFlags.SoldItems, id, requireUpToDateSave: true))
|
||||
@@ -801,7 +802,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (requiredFlags.HasFlag(NetFlags.Reputation))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (Reputation)");
|
||||
DebugConsole.Log("Received campaign update (Reputation), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
Dictionary<Identifier, float> factionReps = new Dictionary<Identifier, float>();
|
||||
byte factionsCount = msg.ReadByte();
|
||||
@@ -828,7 +829,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (requiredFlags.HasFlag(NetFlags.CharacterInfo))
|
||||
{
|
||||
DebugConsole.Log("Received campaign update (CharacterInfo)");
|
||||
DebugConsole.Log("Received campaign update (CharacterInfo), round id: " + roundId);
|
||||
UInt16 id = msg.ReadUInt16();
|
||||
bool hasCharacterData = msg.ReadBoolean();
|
||||
CharacterInfo myCharacterInfo = null;
|
||||
@@ -837,16 +838,27 @@ namespace Barotrauma
|
||||
{
|
||||
myCharacterInfo = CharacterInfo.ClientRead(CharacterPrefab.HumanSpeciesName, msg, requireJobPrefabFound: !waitForModsDownloaded);
|
||||
}
|
||||
if (!waitForModsDownloaded && ShouldApply(NetFlags.CharacterInfo, id, requireUpToDateSave: true))
|
||||
//don't require the correct round ID for the character info if we're in the lobby
|
||||
// = allow updating the character to the latest one in the lobby, even though we've not loaded to the same round as the server
|
||||
if (!waitForModsDownloaded && ShouldApply(NetFlags.CharacterInfo, id, requireUpToDateSave: true, requireCorrectRoundId: Screen.Selected != GameMain.NetLobbyScreen))
|
||||
{
|
||||
if (myCharacterInfo != null)
|
||||
{
|
||||
GameMain.Client.CharacterInfo = myCharacterInfo;
|
||||
GameMain.NetLobbyScreen.SetCampaignCharacterInfo(myCharacterInfo);
|
||||
GameMain.GameSession.RefreshAnyOpenPlayerInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
//don't reset the character info nor the open UI here here,
|
||||
//the client needs it to be able to customize the character they want to next spawn as
|
||||
GameMain.NetLobbyScreen.SetCampaignCharacterInfo(null);
|
||||
//if we've already discarded our current character and the server is just "verifying" that,
|
||||
//no need to refresh the UI (no changes, refreshing would just throw the client out of the character settings panel)
|
||||
if (!GameMain.NetLobbyScreen.CampaignCharacterDiscarded)
|
||||
{
|
||||
GameMain.GameSession.RefreshAnyOpenPlayerInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -863,8 +875,14 @@ namespace Barotrauma
|
||||
}
|
||||
campaign.SuppressStateSending = false;
|
||||
|
||||
bool ShouldApply(NetFlags flag, UInt16 id, bool requireUpToDateSave)
|
||||
bool ShouldApply(NetFlags flag, UInt16 id, bool requireUpToDateSave, bool requireCorrectRoundId = true)
|
||||
{
|
||||
if (requireCorrectRoundId && roundId != campaign.RoundID)
|
||||
{
|
||||
DebugConsole.Log($"Received campaing update for a different round (client: {campaign.RoundID}, server: {roundId}), ignoring...");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NetIdUtils.IdMoreRecent(id, campaign.GetLastUpdateIdForFlag(flag)) &&
|
||||
(!requireUpToDateSave || saveID == campaign.LastSaveID))
|
||||
{
|
||||
@@ -919,26 +937,42 @@ namespace Barotrauma
|
||||
|
||||
ushort pendingHireLength = msg.ReadUInt16();
|
||||
List<UInt16> pendingHires = new List<UInt16>();
|
||||
bool[] pendingHiresToReserveBench = new bool[pendingHireLength];
|
||||
for (int i = 0; i < pendingHireLength; i++)
|
||||
{
|
||||
pendingHires.Add(msg.ReadUInt16());
|
||||
pendingHiresToReserveBench[i] = msg.ReadBoolean();
|
||||
}
|
||||
|
||||
ushort hiredLength = msg.ReadUInt16();
|
||||
List<CharacterInfo> hiredCharacters = new List<CharacterInfo>();
|
||||
for (int i = 0; i < hiredLength; i++)
|
||||
List<CharacterInfo> updatedCrewManager = new List<CharacterInfo>();
|
||||
ushort crewLength = msg.ReadUInt16();
|
||||
for (int i = 0; i < crewLength; i++)
|
||||
{
|
||||
CharacterInfo hired = CharacterInfo.ClientRead(CharacterPrefab.HumanSpeciesName, msg);
|
||||
hired.Salary = msg.ReadInt32();
|
||||
hiredCharacters.Add(hired);
|
||||
CharacterInfo crewMember = CharacterInfo.ClientRead(CharacterPrefab.HumanSpeciesName, msg);
|
||||
if (crewMember.IsNewHire)
|
||||
{
|
||||
hiredCharacters.Add(crewMember);
|
||||
}
|
||||
updatedCrewManager.Add(crewMember);
|
||||
}
|
||||
|
||||
bool crewManagerUpdated = GameMain.GameSession.CrewManager?.UpdateCrewManagerIfNecessary(updatedCrewManager) ?? false;
|
||||
|
||||
ushort reserveBenchLength = msg.ReadUInt16();
|
||||
List<CharacterInfo> updatedReserveBench = new List<CharacterInfo>();
|
||||
for (int i = 0; i < reserveBenchLength; i++)
|
||||
{
|
||||
CharacterInfo info = CharacterInfo.ClientRead(CharacterPrefab.HumanSpeciesName, msg);
|
||||
updatedReserveBench.Add(info);
|
||||
}
|
||||
bool reserveBenchUpdated = GameMain.GameSession.CrewManager?.UpdateReserveBenchIfNeeded(updatedReserveBench) ?? false;
|
||||
|
||||
bool renameCrewMember = msg.ReadBoolean();
|
||||
if (renameCrewMember)
|
||||
{
|
||||
UInt16 renamedIdentifier = msg.ReadUInt16();
|
||||
string newName = msg.ReadString();
|
||||
CharacterInfo renamedCharacter = CrewManager.GetCharacterInfos().FirstOrDefault(info => info.ID == renamedIdentifier);
|
||||
CharacterInfo renamedCharacter = CrewManager.GetCharacterInfos(includeReserveBench: true).FirstOrDefault(info => info.ID == renamedIdentifier);
|
||||
if (renamedCharacter != null)
|
||||
{
|
||||
CrewManager.RenameCharacter(renamedCharacter, newName);
|
||||
@@ -955,7 +989,7 @@ namespace Barotrauma
|
||||
if (fireCharacter)
|
||||
{
|
||||
UInt16 firedIdentifier = msg.ReadUInt16();
|
||||
CharacterInfo firedCharacter = CrewManager.GetCharacterInfos().FirstOrDefault(info => info.ID == firedIdentifier);
|
||||
CharacterInfo firedCharacter = CrewManager.GetCharacterInfos(includeReserveBench: true).FirstOrDefault(info => info.ID == firedIdentifier);
|
||||
// this one might and is allowed to be null since the character is already fired on the original sender's game
|
||||
if (firedCharacter != null) { CrewManager.FireCharacter(firedCharacter); }
|
||||
}
|
||||
@@ -967,8 +1001,8 @@ namespace Barotrauma
|
||||
{
|
||||
CampaignUI.HRManagerUI.SetHireables(map.CurrentLocation, availableHires);
|
||||
if (hiredCharacters.Any()) { CampaignUI.HRManagerUI.ValidateHires(hiredCharacters, takeMoney: false, createNotification: createNotification); }
|
||||
CampaignUI.HRManagerUI.SetPendingHires(pendingHires, map.CurrentLocation);
|
||||
if (renameCrewMember || fireCharacter) { CampaignUI.HRManagerUI.UpdateCrew(); }
|
||||
//don't check the crew size limit: if the server says someone's hired, then it's so
|
||||
CampaignUI.HRManagerUI.SetPendingHires(pendingHires, pendingHiresToReserveBench, map.CurrentLocation, checkCrewSizeLimit: false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -979,6 +1013,11 @@ namespace Barotrauma
|
||||
CurrentLocation?.ForceHireableCharacters(availableHires);
|
||||
}
|
||||
|
||||
if (fireCharacter || renameCrewMember || crewManagerUpdated || reserveBenchUpdated)
|
||||
{
|
||||
CampaignUI?.HRManagerUI?.RefreshHRView();
|
||||
GameMain.GameSession?.DeathPrompt?.UpdateBotList();
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientReadMoney(IReadMessage inc)
|
||||
|
||||
+1
-1
@@ -379,7 +379,7 @@ namespace Barotrauma
|
||||
if (success)
|
||||
{
|
||||
// Event history must be registered before ending the round or it will be cleared
|
||||
GameMain.GameSession.EventManager.RegisterEventHistory();
|
||||
GameMain.GameSession.EventManager.StoreEventDataAtRoundEnd();
|
||||
}
|
||||
GameMain.GameSession.EndRound("", transitionType);
|
||||
var continueButton = GameMain.GameSession.RoundSummary?.ContinueButton;
|
||||
|
||||
@@ -110,9 +110,13 @@ namespace Barotrauma
|
||||
deathChoiceInfoFrame = new GUIFrame(new RectTransform(new Vector2(0.5f, 1.0f), parent: topLeftButtonGroup.RectTransform)
|
||||
{ MaxSize = new Point(HUDLayoutSettings.ButtonAreaTop.Width / 3, int.MaxValue) }, style: null)
|
||||
{
|
||||
CanBeFocused = false,
|
||||
Visible = false
|
||||
};
|
||||
respawnInfoText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), deathChoiceInfoFrame.RectTransform), "", wrap: true);
|
||||
respawnInfoText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), deathChoiceInfoFrame.RectTransform), "", wrap: true)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
deathChoiceButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), deathChoiceInfoFrame.RectTransform, Anchor.CenterRight), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
AbsoluteSpacing = HUDLayoutSettings.Padding,
|
||||
@@ -189,7 +193,7 @@ namespace Barotrauma
|
||||
if (GameMain.NetworkMember != null)
|
||||
{
|
||||
GameMain.NetLobbyScreen.CharacterAppearanceCustomizationMenu?.AddToGUIUpdateList();
|
||||
GameMain.NetLobbyScreen?.JobSelectionFrame?.AddToGUIUpdateList();
|
||||
GameMain.NetLobbyScreen?.JobSelectionFrame?.AddToGUIUpdateList(order: 1);
|
||||
}
|
||||
|
||||
DeathPrompt?.AddToGUIUpdateList();
|
||||
@@ -335,6 +339,20 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If there are any menu panels etc. open that contain information about the current player character, refresh it.
|
||||
/// Useful when the player character changes, e.g. at permadeath, and subsequent taking over of a bot character.
|
||||
/// </summary>
|
||||
public void RefreshAnyOpenPlayerInfo()
|
||||
{
|
||||
DebugConsole.NewMessage($"Refreshing any open player info");
|
||||
if (IsTabMenuOpen && TabMenu.SelectedTab == TabMenu.InfoFrameTab.Talents)
|
||||
{
|
||||
TabMenuInstance.SelectInfoFrameTab(TabMenu.InfoFrameTab.Talents);
|
||||
}
|
||||
// TODO: This can be expanded as need arises
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace Barotrauma
|
||||
if (affliction?.Prefab == null) { continue; }
|
||||
if (affliction.Prefab.IsBuff) { continue; }
|
||||
if (affliction.Prefab == AfflictionPrefab.OxygenLow) { continue; }
|
||||
if (affliction.Prefab == AfflictionPrefab.RadiationSickness && (GameMain.GameSession.Map?.Radiation?.IsEntityRadiated(character) ?? false)) { continue; }
|
||||
if (affliction.Prefab == AfflictionPrefab.RadiationSickness && (GameMain.GameSession.Map?.Radiation?.DepthInRadiation(character) ?? 0) > 0) { continue; }
|
||||
if (affliction.Strength < affliction.Prefab.ShowIconThreshold) { continue; }
|
||||
DisplayHint("onafflictiondisplayed".ToIdentifier(),
|
||||
variables: new[] { ("[key]".ToIdentifier(), GameSettings.CurrentConfig.KeyMap.KeyBindText(InputType.Health)) },
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace Barotrauma
|
||||
private float crewListAnimDelay = 0.25f;
|
||||
private float missionIconAnimDelay;
|
||||
|
||||
private const float JobColumnWidthPercentage = 0.1f;
|
||||
private const float CharacterColumnWidthPercentage = 0.4f;
|
||||
private const float StatusColumnWidthPercentage = 0.12f;
|
||||
private const float KillColumnWidthPercentage = 0.1f;
|
||||
private const float DeathColumnWidthPercentage = 0.1f;
|
||||
private const float JobColumnWidthPercentage = 0.05f;
|
||||
private const float CharacterColumnWidthPercentage = 0.35f;
|
||||
private const float StatusColumnWidthPercentage = 0.25f;
|
||||
private const float KillColumnWidthPercentage = 0.05f;
|
||||
private const float DeathColumnWidthPercentage = 0.05f;
|
||||
|
||||
private int jobColumnWidth, characterColumnWidth, statusColumnWidth, killColumnWidth, deathColumnWidth;
|
||||
|
||||
@@ -467,7 +467,7 @@ namespace Barotrauma
|
||||
};
|
||||
if (icon != null)
|
||||
{
|
||||
missionIcon = new GUIImage(new RectTransform(new Point(iconSize), content.RectTransform), icon, null, true)
|
||||
missionIcon = new GUIImage(new RectTransform(new Point(iconSize), content.RectTransform), icon, scaleToFit: true)
|
||||
{
|
||||
Color = iconColor,
|
||||
HoverColor = iconColor,
|
||||
@@ -661,15 +661,18 @@ namespace Barotrauma
|
||||
GUIButton jobButton = new GUIButton(new RectTransform(new Vector2(JobColumnWidthPercentage, 1f), headerFrame.RectTransform), TextManager.Get("tabmenu.job"), style: "GUIButtonSmallFreeScale");
|
||||
GUIButton characterButton = new GUIButton(new RectTransform(new Vector2(CharacterColumnWidthPercentage, 1f), headerFrame.RectTransform), TextManager.Get("name"), style: "GUIButtonSmallFreeScale");
|
||||
|
||||
if (gameMode is PvPMode)
|
||||
if (gameMode is PvPMode && GameMain.NetworkMember?.RespawnManager != null)
|
||||
{
|
||||
var killButton = new GUIButton(new RectTransform(new Vector2(KillColumnWidthPercentage, 1f), headerFrame.RectTransform), TextManager.Get("killcount"), style: "GUIButtonSmallFreeScale");
|
||||
killColumnWidth = killButton.Rect.Width;
|
||||
var deathButton = new GUIButton(new RectTransform(new Vector2(DeathColumnWidthPercentage, 1f), headerFrame.RectTransform), TextManager.Get("deathcount"), style: "GUIButtonSmallFreeScale");
|
||||
deathColumnWidth = deathButton.Rect.Width;
|
||||
}
|
||||
|
||||
GUIButton statusButton = new GUIButton(new RectTransform(new Vector2(StatusColumnWidthPercentage, 1f), headerFrame.RectTransform), TextManager.Get("label.statuslabel"), style: "GUIButtonSmallFreeScale");
|
||||
else
|
||||
{
|
||||
GUIButton statusButton = new GUIButton(new RectTransform(new Vector2(StatusColumnWidthPercentage, 1f), headerFrame.RectTransform), TextManager.Get("label.statuslabel"), style: "GUIButtonSmallFreeScale");
|
||||
statusColumnWidth = statusButton.Rect.Width;
|
||||
}
|
||||
|
||||
foreach (var btn in headerFrame.GetAllChildren<GUIButton>())
|
||||
{
|
||||
@@ -680,7 +683,6 @@ namespace Barotrauma
|
||||
|
||||
jobColumnWidth = jobButton.Rect.Width;
|
||||
characterColumnWidth = characterButton.Rect.Width;
|
||||
statusColumnWidth = statusButton.Rect.Width;
|
||||
|
||||
GUIListBox crewList = new GUIListBox(new RectTransform(Vector2.One, parent.RectTransform))
|
||||
{
|
||||
@@ -758,7 +760,7 @@ namespace Barotrauma
|
||||
Character character = characterInfo.Character;
|
||||
if (character == null || character.IsDead)
|
||||
{
|
||||
if (character == null && characterInfo.IsNewHire && characterInfo.CauseOfDeath == null)
|
||||
if (character == null && (characterInfo.IsNewHire || characterInfo.BotStatus == BotStatus.ActiveService) && characterInfo.CauseOfDeath == null)
|
||||
{
|
||||
statusText = TextManager.Get("CampaignCrew.NewHire");
|
||||
statusColor = GUIStyle.Blue;
|
||||
@@ -798,19 +800,21 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (gameMode is PvPMode pvpMode)
|
||||
if (gameMode is PvPMode && GameMain.NetworkMember?.RespawnManager != null)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Point(killColumnWidth, paddedFrame.Rect.Height), paddedFrame.RectTransform),
|
||||
killCounts.GetValueOrDefault(characterInfo).ToString(), textAlignment: Alignment.Center);
|
||||
new GUITextBlock(new RectTransform(new Point(deathColumnWidth, paddedFrame.Rect.Height), paddedFrame.RectTransform),
|
||||
deathCounts.GetValueOrDefault(characterInfo).ToString(), textAlignment: Alignment.Center);
|
||||
}
|
||||
|
||||
GUITextBlock statusBlock = new GUITextBlock(new RectTransform(new Point(statusColumnWidth, paddedFrame.Rect.Height), paddedFrame.RectTransform),
|
||||
ToolBox.LimitString(statusText.Value, GUIStyle.Font, statusColumnWidth), textAlignment: Alignment.Center, textColor: statusColor, font: GUIStyle.SmallFont)
|
||||
else
|
||||
{
|
||||
ToolTip = statusText.Value
|
||||
};
|
||||
GUITextBlock statusBlock = new GUITextBlock(new RectTransform(new Point(statusColumnWidth, paddedFrame.Rect.Height), paddedFrame.RectTransform),
|
||||
ToolBox.LimitString(statusText.Value, GUIStyle.SmallFont, statusColumnWidth), textAlignment: Alignment.Center, textColor: statusColor, font: GUIStyle.SmallFont)
|
||||
{
|
||||
ToolTip = statusText.Value
|
||||
};
|
||||
}
|
||||
|
||||
frame.FadeIn(animDelay, 0.15f);
|
||||
foreach (var child in frame.GetAllChildren())
|
||||
|
||||
Reference in New Issue
Block a user