Build 0.18.0.0

This commit is contained in:
Markus Isberg
2022-05-13 00:55:52 +09:00
parent 15d18e6ff6
commit 7547a9b78a
218 changed files with 3881 additions and 2192 deletions
@@ -77,9 +77,20 @@ namespace Barotrauma
if (remoteContentDoc?.Root != null)
{
remoteContentContainer.ClearChildren();
foreach (var subElement in remoteContentDoc.Root.Elements())
try
{
GUIComponent.FromXML(subElement.FromPackage(null), remoteContentContainer.RectTransform);
foreach (var subElement in remoteContentDoc.Root.Elements())
{
GUIComponent.FromXML(subElement.FromPackage(null), remoteContentContainer.RectTransform);
}
}
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("Reading received remote main menu content failed.", e);
#endif
GameAnalyticsManager.AddErrorEventOnce("MainMenuScreen.RemoteContentParse:Exception", GameAnalyticsManager.ErrorSeverity.Error,
"Reading received remote main menu content failed. " + e.Message);
}
}
};
@@ -20,10 +20,11 @@ namespace Barotrauma
private ServerContentPackage? currentDownload;
private readonly List<ContentPackage> downloadedPackages = new List<ContentPackage>();
public IEnumerable<ContentPackage> DownloadedPackages => downloadedPackages;
private bool confirmDownload;
private void Reset()
public void Reset()
{
pendingDownloads.Clear();
downloadedPackages.Clear();
@@ -255,12 +256,6 @@ namespace Barotrauma
}
}
public override void Deselect()
{
Reset();
base.Deselect();
}
public override void Update(double deltaTime)
{
base.Update(deltaTime);
@@ -1400,7 +1400,7 @@ namespace Barotrauma
public void CreatePlayerFrame(GUIComponent parent, bool createPendingText = true, bool alwaysAllowEditing = false)
{
UpdatePlayerFrame(
Character.Controlled?.Info ?? playerInfoContainer.Children?.First().UserData as CharacterInfo,
Character.Controlled?.Info ?? playerInfoContainer.Children?.First().UserData as CharacterInfo ?? GameMain.Client.CharacterInfo,
allowEditing: alwaysAllowEditing || campaignCharacterInfo == null,
parent: parent,
createPendingText: createPendingText);
@@ -3131,10 +3131,11 @@ namespace Barotrauma
retVal[i] = new GUIImage[outfitPreview.Sprites.Count];
for (int j = 0; j < outfitPreview.Sprites.Count; j++)
{
Pair<Sprite, Vector2> sprite = outfitPreview.Sprites[j];
Sprite sprite = outfitPreview.Sprites[j].sprite;
Vector2 drawOffset = outfitPreview.Sprites[j].drawOffset;
float aspectRatio = outfitPreview.Dimensions.Y / outfitPreview.Dimensions.X;
retVal[i][j] = new GUIImage(new RectTransform(new Vector2(0.7f / aspectRatio, 0.7f), innerFrame.RectTransform, Anchor.Center)
{ RelativeOffset = sprite.Second / outfitPreview.Dimensions }, sprite.First, scaleToFit: true)
{ RelativeOffset = drawOffset / outfitPreview.Dimensions }, sprite, scaleToFit: true)
{
PressedColor = Color.White,
CanBeFocused = false
@@ -1190,18 +1190,23 @@ namespace Barotrauma
frame.RectTransform.MaxSize = new Point(int.MaxValue, frame.Rect.Width);
LocalizedString name = legacy ? TextManager.GetWithVariable("legacyitemformat", "[name]", ep.Name) : ep.Name;
frame.ToolTip = ep.Description.IsNullOrEmpty() ? name : name + '\n' + ep.Description;
frame.ToolTip = $"{frame.ToolTip}\n‖color:{XMLExtensions.ToStringHex(GUIStyle.TextColorBright)}‖{name}‖color:end‖";
if (!ep.Description.IsNullOrEmpty())
{
frame.ToolTip += '\n' + ep.Description;
}
if (ep.ContentPackage != GameMain.VanillaContent && ep.ContentPackage != null)
{
frame.Color = Color.Magenta;
frame.ToolTip = RichString.Rich($"{frame.ToolTip}\n‖color:{XMLExtensions.ToStringHex(Color.MediumPurple)}‖{ep.ContentPackage?.Name}‖color:end‖");
frame.ToolTip = $"{frame.ToolTip}\n‖color:{XMLExtensions.ToStringHex(Color.MediumPurple)}‖{ep.ContentPackage?.Name}‖color:end‖";
}
if (ep.HideInMenus)
{
frame.Color = Color.Red;
name = "[HIDDEN] " + name;
}
frame.ToolTip = RichString.Rich(frame.ToolTip);
GUILayoutGroup paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.8f), frame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
{
@@ -1976,7 +1981,7 @@ namespace Barotrauma
return true;
};
nameBox.Text = subNameLabel?.Text?.SanitizedValue ?? "";
nameBox.Text = MainSub?.Info.Name ?? "";
submarineNameCharacterCount.Text = nameBox.Text.Length + " / " + submarineNameLimit;
@@ -2750,6 +2755,8 @@ namespace Barotrauma
}
}
nameBox.Text = nameBox.Text.Trim();
bool hideInMenus = nameBox.Parent.GetChildByUserData("hideinmenus") is GUITickBox hideInMenusTickBox && hideInMenusTickBox.Selected;
string saveFolder = Path.Combine(ContentPackage.LocalModsDir, nameBox.Text);
string filePath = Path.Combine(saveFolder, $"{nameBox.Text}.xml").CleanUpPathCrossPlatform();
@@ -2884,8 +2891,30 @@ namespace Barotrauma
{
if (deleteButtonHolder.FindChild("delete") is GUIButton deleteBtn)
{
deleteBtn.Enabled = userData is SubmarineInfo subInfo
&& GetContentPackageIntrinsicallyTiedToSub(subInfo) != null;
deleteBtn.ToolTip = string.Empty;
if (!(userData is SubmarineInfo subInfo))
{
deleteBtn.Enabled = false;
return true;
}
var package = GetContentPackageIntrinsicallyTiedToSub(subInfo);
if (package != null)
{
deleteBtn.Enabled = true;
}
else
{
deleteBtn.Enabled = false;
if (ContentPackageManager.VanillaCorePackage?.Files.Any(f => f.Path == subInfo.FilePath) ?? false)
{
deleteBtn.ToolTip = TextManager.Get("cantdeletevanillasub");
}
else if (ContentPackageManager.AllPackages.FirstOrDefault(p => p.Files.Any(f => f.Path == subInfo.FilePath)) is ContentPackage subPackage)
{
deleteBtn.ToolTip = TextManager.GetWithVariable("cantdeletemodsub", "[modname]", subPackage.Name);
}
}
}
return true;
}
@@ -2925,6 +2954,21 @@ namespace Barotrauma
ToolTip = sub.FilePath
};
if (!(ContentPackageManager.VanillaCorePackage?.Files.Any(f => f.Path == sub.FilePath) ?? false))
{
if (GetContentPackageIntrinsicallyTiedToSub(sub) == null &&
ContentPackageManager.AllPackages.FirstOrDefault(p => p.Files.Any(f => f.Path == sub.FilePath)) is ContentPackage subPackage)
{
//workshop mod
textBlock.OverrideTextColor(Color.MediumPurple);
}
else
{
//local mod
textBlock.OverrideTextColor(GUIStyle.TextColorBright);
}
}
if (sub.HasTag(SubmarineTag.Shuttle))
{
var shuttleText = new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), textBlock.RectTransform, Anchor.CenterRight),
@@ -3037,6 +3081,24 @@ namespace Barotrauma
if (!(child.UserData is SubmarineInfo sub)) { continue; }
child.Visible = string.IsNullOrEmpty(filter) || sub.Name.ToLower().Contains(filter.ToLower());
}
//go through the elements backwards, and disable the labels for sub categories if there's no subs visible in them
bool subVisibleInCategory = false;
foreach (GUIComponent child in subList.Content.Children.Reverse())
{
if (!(child.UserData is SubmarineInfo sub))
{
if (child.Enabled)
{
child.Visible = subVisibleInCategory;
}
subVisibleInCategory = false;
}
else
{
subVisibleInCategory |= child.Visible;
}
}
}
/// <summary>
@@ -4828,7 +4890,7 @@ namespace Barotrauma
}
}
if (GameSettings.CurrentConfig.KeyMap.Bindings[InputType.ToggleInventory].IsHit() && mode == Mode.Default)
if (PlayerInput.KeyHit(Keys.Q) && mode == Mode.Default)
{
toggleEntityMenuButton.OnClicked?.Invoke(toggleEntityMenuButton, toggleEntityMenuButton.UserData);
}