Unstable v0.19.3.0

This commit is contained in:
Juan Pablo Arce
2022-09-02 15:10:56 -03:00
parent 28789616bd
commit 3f2c843247
336 changed files with 7152 additions and 7739 deletions
@@ -61,7 +61,8 @@ namespace Barotrauma
UserData = saveInfo.FilePath
};
var nameText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), saveFrame.RectTransform), Path.GetFileNameWithoutExtension(saveInfo.FilePath))
var nameText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), saveFrame.RectTransform), Path.GetFileNameWithoutExtension(saveInfo.FilePath),
textColor: GUIStyle.TextColorBright)
{
CanBeFocused = false
};
@@ -85,7 +86,6 @@ namespace Barotrauma
UserData = saveInfo.FilePath
};
string saveTimeStr = string.Empty;
if (saveInfo.SaveTime > 0)
{
@@ -187,9 +187,9 @@ namespace Barotrauma
SettingValue<Identifier> startingSetInput = CreateSelectionCarousel(settingsList.Content, TextManager.Get("startitemset"), TextManager.Get("startitemsettooltip"), prevStartingSet, verticalSize, startingSetOptions);
ImmutableArray<SettingCarouselElement<StartingBalanceAmount>> fundOptions = ImmutableArray.Create(
new SettingCarouselElement<StartingBalanceAmount>(StartingBalanceAmount.High, "startingfunds.high"),
new SettingCarouselElement<StartingBalanceAmount>(StartingBalanceAmount.Low, "startingfunds.low"),
new SettingCarouselElement<StartingBalanceAmount>(StartingBalanceAmount.Medium, "startingfunds.medium"),
new SettingCarouselElement<StartingBalanceAmount>(StartingBalanceAmount.Low, "startingfunds.low")
new SettingCarouselElement<StartingBalanceAmount>(StartingBalanceAmount.High, "startingfunds.high")
);
SettingCarouselElement<StartingBalanceAmount> prevStartingFund = fundOptions.FirstOrNull(element => element.Value == prevSettings.StartingBalanceAmount) ?? fundOptions[1];
@@ -11,7 +11,9 @@ namespace Barotrauma
class MultiPlayerCampaignSetupUI : CampaignSetupUI
{
private GUIButton deleteMpSaveButton;
private int prevInitialMoney;
public MultiPlayerCampaignSetupUI(GUIComponent newGameContainer, GUIComponent loadGameContainer, List<CampaignMode.SaveInfo> saveFiles = null)
: base(newGameContainer, loadGameContainer)
{
@@ -133,6 +135,7 @@ namespace Barotrauma
StartButton.RectTransform.MaxSize = RectTransform.MaxPoint;
StartButton.Children.ForEach(c => c.RectTransform.MaxSize = RectTransform.MaxPoint);
prevInitialMoney = 8000;
InitialMoneyText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1f), buttonContainer.RectTransform), "", font: GUIStyle.SmallFont, textColor: GUIStyle.Green)
{
TextGetter = () =>
@@ -142,11 +145,17 @@ namespace Barotrauma
{
initialMoney = definition.GetInt(elements.StartingFunds.GetValue().ToIdentifier());
}
if (prevInitialMoney != initialMoney)
{
GameMain.NetLobbyScreen.RefreshEnabledElements();
prevInitialMoney = initialMoney;
}
if (GameMain.NetLobbyScreen.SelectedSub != null)
{
initialMoney -= GameMain.NetLobbyScreen.SelectedSub.Price;
}
initialMoney = Math.Max(initialMoney, MultiPlayerCampaign.MinimumInitialMoney);
initialMoney = Math.Max(initialMoney, 0);
return TextManager.GetWithVariable("campaignstartingmoney", "[money]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", initialMoney));
}
};
@@ -476,8 +476,7 @@ namespace Barotrauma
{
foreach (GUIComponent child in subList.Content.Children)
{
SubmarineInfo sub = child.UserData as SubmarineInfo;
if (sub == null) { return; }
if (!(child.UserData is SubmarineInfo sub)) { return; }
child.Visible = string.IsNullOrEmpty(filter) || sub.DisplayName.Contains(filter.ToLower(), StringComparison.OrdinalIgnoreCase);
}
}
@@ -523,9 +522,11 @@ namespace Barotrauma
subsToShow.Sort((s1, s2) =>
{
int p1 = s1.Price > CurrentSettings.InitialMoney ? 10 : 0;
int p2 = s2.Price > CurrentSettings.InitialMoney ? 10 : 0;
return p1.CompareTo(p2) * 100 + s1.Name.CompareTo(s2.Name);
int p1 = s1.Price;
if (!s1.IsCampaignCompatible) { p1 += 100000; }
int p2 = s2.Price;
if (!s2.IsCampaignCompatible) { p2 += 100000; }
return p1.CompareTo(p2) * 100 + s1.Name.CompareTo(s2.Name);
});
subList.ClearChildren();
@@ -533,7 +534,7 @@ namespace Barotrauma
foreach (SubmarineInfo sub in subsToShow)
{
var textBlock = new GUITextBlock(
new RectTransform(new Vector2(1, 0.1f), subList.Content.RectTransform) { MinSize = new Point(0, 30) },
new RectTransform(new Vector2(1, 0.15f), subList.Content.RectTransform) { MinSize = new Point(0, 30) },
ToolBox.LimitString(sub.DisplayName.Value, GUIStyle.Font, subList.Rect.Width - 65), style: "ListBoxElement")
{
ToolTip = sub.Description,
@@ -546,12 +547,19 @@ namespace Barotrauma
textBlock.ToolTip = TextManager.Get("ContentPackageMismatch") + "\n\n" + textBlock.ToolTip.SanitizedString;
}
var priceText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), textBlock.RectTransform, Anchor.CenterRight),
TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", sub.Price)), textAlignment: Alignment.CenterRight, font: GUIStyle.SmallFont)
var infoContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), textBlock.RectTransform, Anchor.CenterRight), isHorizontal: false);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), infoContainer.RectTransform),
TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", sub.Price)), textAlignment: Alignment.BottomRight, font: GUIStyle.SmallFont)
{
TextColor = sub.Price > CurrentSettings.InitialMoney ? GUIStyle.Red : textBlock.TextColor * 0.8f,
ToolTip = textBlock.ToolTip
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), infoContainer.RectTransform),
TextManager.Get($"submarineclass.{sub.SubmarineClass}"), textAlignment: Alignment.TopRight, font: GUIStyle.SmallFont)
{
TextColor = textBlock.TextColor * 0.8f,
ToolTip = textBlock.ToolTip
};
#if !DEBUG
if (!GameMain.DebugDraw)
{
@@ -179,7 +179,7 @@ namespace Barotrauma
// Ok button
msgBox.Buttons[1].OnClicked = delegate
{
foreach (var illegalChar in Path.GetInvalidFileNameChars())
foreach (var illegalChar in Path.GetInvalidFileNameCharsCrossPlatform())
{
if (!nameInput.Text.Contains(illegalChar)) { continue; }
@@ -274,7 +274,7 @@ namespace Barotrauma
// Ok button
msgBox.Buttons[1].OnClicked = delegate
{
foreach (var illegalChar in Path.GetInvalidFileNameChars())
foreach (var illegalChar in Path.GetInvalidFileNameCharsCrossPlatform())
{
if (!nameInput.Text.Contains(illegalChar)) { continue; }
@@ -434,25 +434,18 @@ namespace Barotrauma
{
PlaySoundOnSelect = true,
};
var tutorialTypes = new List<Type>()
foreach (var tutorialPrefab in TutorialPrefab.Prefabs.OrderBy(p => p.Order))
{
typeof(MechanicTutorial),
typeof(EngineerTutorial),
typeof(DoctorTutorial),
typeof(OfficerTutorial),
typeof(CaptainTutorial),
};
foreach (Type tutorialType in tutorialTypes)
{
Tutorial tutorial = (Tutorial)Activator.CreateInstance(tutorialType);
var tutorial = new Tutorial(tutorialPrefab);
var tutorialText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), tutorialList.Content.RectTransform), tutorial.DisplayName, textAlignment: Alignment.Center, font: GUIStyle.LargeFont)
{
TextColor = GUIStyle.Green,
UserData = tutorial
};
}
tutorialList.OnSelected += (component, obj) =>
{
(obj as Tutorial).Start();
(obj as Tutorial)?.Start();
return true;
};
@@ -737,34 +730,12 @@ namespace Barotrauma
private void UpdateTutorialList()
{
var tutorialList = menuTabs[Tab.Tutorials].GetChild<GUIListBox>();
int completedTutorials = 0;
foreach (GUITextBlock tutorialText in tutorialList.Content.Children)
foreach (GUITextBlock tutorialText in menuTabs[Tab.Tutorials].GetChild<GUIListBox>().Content.Children)
{
if (CompletedTutorials.Instance.Contains(((Tutorial)tutorialText.UserData).Identifier))
{
completedTutorials++;
}
}
for (int i = 0; i < tutorialList.Content.Children.Count(); i++)
{
if (i < completedTutorials + 1)
{
(tutorialList.Content.GetChild(i) as GUITextBlock).TextColor = GUIStyle.Green;
#if !DEBUG
(tutorialList.Content.GetChild(i) as GUITextBlock).CanBeFocused = true;
#endif
}
else
{
(tutorialList.Content.GetChild(i) as GUITextBlock).TextColor = Color.Gray;
#if !DEBUG
(tutorialList.Content.GetChild(i) as GUITextBlock).CanBeFocused = false;
#endif
}
var tutorial = (Tutorial)tutorialText.UserData;
tutorialText.Text = CompletedTutorials.Instance.Contains(tutorial.Identifier) ?
TextManager.GetWithVariable("tutorialcompleted", "[tutorialname]", tutorial.DisplayName) :
tutorial.DisplayName;
}
}
@@ -9,7 +9,7 @@ using Barotrauma.Steam;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Color = Microsoft.Xna.Framework.Color;
using ServerContentPackage = Barotrauma.Networking.ClientPeer.ServerContentPackage;
using ServerContentPackage = Barotrauma.Networking.ServerContentPackage;
namespace Barotrauma
{
@@ -21,7 +21,7 @@ namespace Barotrauma
private readonly List<ContentPackage> downloadedPackages = new List<ContentPackage>();
public IEnumerable<ContentPackage> DownloadedPackages => downloadedPackages;
private bool confirmDownload;
public void Reset()
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace Barotrauma
@@ -866,7 +867,7 @@ namespace Barotrauma
{
OnSelected = (component, obj) =>
{
GameMain.Client?.RequestSelectSub(component.Parent.GetChildIndex(component), isShuttle: true);
GameMain.Client?.RequestSelectSub(obj as SubmarineInfo, isShuttle: true);
return true;
}
};
@@ -1794,7 +1795,7 @@ namespace Barotrauma
MissionType = missionType;
}
public void UpdateSubList(GUIComponent subList, List<SubmarineInfo> submarines)
public void UpdateSubList(GUIComponent subList, IEnumerable<SubmarineInfo> submarines)
{
if (subList == null) { return; }
@@ -1817,7 +1818,7 @@ namespace Barotrauma
subList = dropDown.ListBox.Content;
}
var frame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), subList.RectTransform) { MinSize = new Point(0, 20) },
var frame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.15f), subList.RectTransform) { MinSize = new Point(0, 25) },
style: "ListBoxElement")
{
ToolTip = sub.Description,
@@ -1873,7 +1874,7 @@ namespace Barotrauma
{
if (sub.HasTag(SubmarineTag.Shuttle))
{
var shuttleText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), parent.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(GUI.IntScale(20), 0) },
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), parent.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(GUI.IntScale(20), 0) },
TextManager.Get("Shuttle", "RespawnShuttle"), textAlignment: Alignment.CenterRight, font: GUIStyle.SmallFont)
{
TextColor = subTextBlock.TextColor * 0.8f,
@@ -1881,7 +1882,7 @@ namespace Barotrauma
CanBeFocused = false
};
//make shuttles more dim in the sub list (selecting a shuttle as the main sub is allowed but not recommended)
if (subList == this.SubList.Content)
if (subList == SubList.Content)
{
subTextBlock.TextColor *= 0.8f;
foreach (GUIComponent child in parent.Children)
@@ -1892,8 +1893,16 @@ namespace Barotrauma
}
else
{
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), parent.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(GUI.IntScale(20), 0) },
TextManager.Get($"submarineclass.{sub.SubmarineClass}"), textAlignment: Alignment.CenterRight, font: GUIStyle.SmallFont)
var infoContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), parent.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(GUI.IntScale(20), 0) }, isHorizontal: false);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), infoContainer.RectTransform),
TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", sub.Price)), textAlignment: Alignment.BottomRight, font: GUIStyle.SmallFont)
{
UserData = "pricetext",
TextColor = subTextBlock.TextColor * 0.8f,
CanBeFocused = false
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), infoContainer.RectTransform),
TextManager.Get($"submarineclass.{sub.SubmarineClass}"), textAlignment: Alignment.TopRight, font: GUIStyle.SmallFont)
{
UserData = "classtext",
TextColor = subTextBlock.TextColor * 0.8f,
@@ -1913,6 +1922,17 @@ namespace Barotrauma
if (!GameMain.Client.ServerSettings.AllowSubVoting)
{
var selectedSub = component.UserData as SubmarineInfo;
if (SelectedMode == GameModePreset.MultiPlayerCampaign && CampaignSetupUI != null)
{
if (selectedSub.Price > CampaignSetupUI.CurrentSettings.InitialMoney)
{
new GUIMessageBox(TextManager.Get("warning"), TextManager.Get("campaignsubtooexpensive"));
}
if (!selectedSub.IsCampaignCompatible)
{
new GUIMessageBox(TextManager.Get("warning"), TextManager.Get("campaignsubincompatible"));
}
}
if (!selectedSub.RequiredContentPackagesInstalled)
{
var msgBox = new GUIMessageBox(TextManager.Get("ContentPackageMismatch"),
@@ -1924,7 +1944,7 @@ namespace Barotrauma
msgBox.Buttons[0].OnClicked = msgBox.Close;
msgBox.Buttons[0].OnClicked += (button, obj) =>
{
GameMain.Client.RequestSelectSub(component.Parent.GetChildIndex(component), isShuttle: false);
GameMain.Client.RequestSelectSub(obj as SubmarineInfo, isShuttle: false);
return true;
};
msgBox.Buttons[1].OnClicked = msgBox.Close;
@@ -1932,7 +1952,7 @@ namespace Barotrauma
}
else if (GameMain.Client.HasPermission(ClientPermissions.SelectSub))
{
GameMain.Client.RequestSelectSub(component.Parent.GetChildIndex(component), isShuttle: false);
GameMain.Client.RequestSelectSub(selectedSub, isShuttle: false);
return true;
}
return false;
@@ -2518,7 +2538,6 @@ namespace Barotrauma
var kickVoteButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaLower.RectTransform),
TextManager.Get("VoteToKick"))
{
Enabled = !selectedClient.HasKickVoteFromSessionId(GameMain.Client.SessionId),
OnClicked = (btn, userdata) => { GameMain.Client.VoteForKick(selectedClient); btn.Enabled = false; return true; },
UserData = selectedClient
};
@@ -3223,6 +3242,22 @@ namespace Barotrauma
{
if (GameMain.Client == null) { return; }
foreach (var subElement in SubList.Content.Children)
{
subElement.CanBeFocused = true;
foreach (var textBlock in subElement.GetAllChildren<GUITextBlock>())
{
textBlock.Enabled = true;
}
}
SubList.Content.RectTransform.SortChildren((rt1, rt2) =>
{
SubmarineInfo s1 = rt1.GUIComponent.UserData as SubmarineInfo;
SubmarineInfo s2 = rt2.GUIComponent.UserData as SubmarineInfo;
return s1.Name.CompareTo(s2.Name);
});
autoRestartBox.Parent.Visible = true;
settingsBlocker.Visible = false;
if (SelectedMode == GameModePreset.Mission || SelectedMode == GameModePreset.PvP)
@@ -3255,6 +3290,33 @@ namespace Barotrauma
TextManager.Get("campaignstarting"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.Center, wrap: true);
}
}
if (CampaignSetupUI != null)
{
foreach (var subElement in SubList.Content.Children)
{
var sub = subElement.UserData as SubmarineInfo;
bool tooExpensive = sub.Price > CampaignSetupUI.CurrentSettings.InitialMoney;
if (tooExpensive || !sub.IsCampaignCompatible)
{
foreach (var textBlock in subElement.GetAllChildren<GUITextBlock>())
{
textBlock.DisabledTextColor = (textBlock.UserData as string == "pricetext" && tooExpensive ? GUIStyle.Red : GUIStyle.TextColorNormal) * 0.7f;
textBlock.Enabled = false;
}
}
}
SubList.Content.RectTransform.SortChildren((rt1, rt2) =>
{
SubmarineInfo s1 = rt1.GUIComponent.UserData as SubmarineInfo;
SubmarineInfo s2 = rt2.GUIComponent.UserData as SubmarineInfo;
int p1 = s1.Price;
if (!s1.IsCampaignCompatible) { p1 += 100000; }
int p2 = s2.Price;
if (!s2.IsCampaignCompatible) { p2 += 100000; }
return p1.CompareTo(p2) * 100 + s1.Name.CompareTo(s2.Name);
});
}
}
else
{
@@ -3656,7 +3718,7 @@ namespace Barotrauma
}
}
private List<SubmarineInfo> visibilityMenuOrder = new List<SubmarineInfo>();
private readonly List<SubmarineInfo> visibilityMenuOrder = new List<SubmarineInfo>();
private void CreateSubmarineVisibilityMenu()
{
var messageBox = new GUIMessageBox(TextManager.Get("SubmarineVisibility"), "",
@@ -1839,7 +1839,7 @@ namespace Barotrauma
return false;
}
foreach (var illegalChar in Path.GetInvalidFileNameChars())
foreach (var illegalChar in Path.GetInvalidFileNameCharsCrossPlatform())
{
if (!name.Contains(illegalChar)) { continue; }
GUI.AddMessage(TextManager.GetWithVariable("SubNameIllegalCharsWarning", "[illegalchar]", illegalChar.ToString()), GUIStyle.Red);
@@ -2410,12 +2410,15 @@ namespace Barotrauma
Stretch = true
};
var classText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), classGroup.RectTransform),
TextManager.Get("submarineclass"), textAlignment: Alignment.CenterLeft, wrap: true);
TextManager.Get("submarineclass"), textAlignment: Alignment.CenterLeft, wrap: true)
{
ToolTip = TextManager.Get("submarineclass.description")
};
GUIDropDown classDropDown = new GUIDropDown(new RectTransform(new Vector2(0.4f, 1.0f), classGroup.RectTransform));
classDropDown.RectTransform.MinSize = new Point(0, subTypeContainer.RectTransform.Children.Max(c => c.MinSize.Y));
foreach (SubmarineClass @class in Enum.GetValues(typeof(SubmarineClass)))
foreach (SubmarineClass subClass in Enum.GetValues(typeof(SubmarineClass)))
{
classDropDown.AddItem(TextManager.Get($"{nameof(SubmarineClass)}.{@class}"), @class);
classDropDown.AddItem(TextManager.Get($"{nameof(SubmarineClass)}.{subClass}"), subClass, toolTip: TextManager.Get($"submarineclass.{subClass}.description"));
}
classDropDown.AddItem(TextManager.Get(nameof(SubmarineTag.Shuttle)), SubmarineTag.Shuttle);
classDropDown.OnSelected += (selected, userdata) =>
@@ -2435,6 +2438,31 @@ namespace Barotrauma
};
classDropDown.SelectItem(!MainSub.Info.HasTag(SubmarineTag.Shuttle) ? MainSub.Info.SubmarineClass : (object)SubmarineTag.Shuttle);
var tierGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), subSettingsContainer.RectTransform), isHorizontal: true)
{
Stretch = true
};
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), tierGroup.RectTransform),
TextManager.Get("subeditor.tier"), textAlignment: Alignment.CenterLeft, wrap: true)
{
ToolTip = TextManager.Get("submarinetier.description")
};
new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), tierGroup.RectTransform), NumberType.Int)
{
IntValue = SubmarineInfo.GetDefaultTier(MainSub.Info.Price),
MinValueInt = 1,
MaxValueInt = 3,
OnValueChanged = (numberInput) =>
{
MainSub.Info.Tier = numberInput.IntValue;
}
};
if (MainSub?.Info != null)
{
MainSub.Info.Tier = Math.Clamp(MainSub.Info.Tier, 1, 3);
}
var crewSizeArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), subSettingsContainer.RectTransform), isHorizontal: true)
{
Stretch = true,
@@ -2970,7 +2998,7 @@ namespace Barotrauma
return false;
}
foreach (char illegalChar in Path.GetInvalidFileNameChars())
foreach (char illegalChar in Path.GetInvalidFileNameCharsCrossPlatform())
{
if (nameBox.Text.Contains(illegalChar))
{
@@ -5014,6 +5042,10 @@ namespace Barotrauma
SkipInventorySlotUpdate = false;
ImageManager.Update((float)deltaTime);
#if DEBUG
Hull.UpdateCheats((float)deltaTime, cam);
#endif
if (GameMain.GraphicsWidth != screenResolution.X || GameMain.GraphicsHeight != screenResolution.Y)
{
saveFrame = null;