Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into unstable
This commit is contained in:
@@ -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
-2
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
+16
-8
@@ -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)
|
||||
{
|
||||
|
||||
@@ -27,8 +27,6 @@ namespace Barotrauma
|
||||
|
||||
private bool hasMaxMissions;
|
||||
|
||||
private GUIButton repairHullsButton, replaceShuttlesButton, repairItemsButton;
|
||||
|
||||
private SubmarineSelection submarineSelection;
|
||||
|
||||
private Location selectedLocation;
|
||||
@@ -101,170 +99,6 @@ namespace Barotrauma
|
||||
tabs[(int)CampaignMode.InteractionType.Store] = storeTab;
|
||||
Store = new Store(this, storeTab);
|
||||
|
||||
// repair tab -------------------------------------------------------------------------
|
||||
|
||||
tabs[(int)CampaignMode.InteractionType.Repair] = CreateDefaultTabContainer(container, new Vector2(0.7f));
|
||||
var repairFrame = new GUIFrame(new RectTransform(Vector2.One, GetTabContainer(CampaignMode.InteractionType.Repair).RectTransform, Anchor.TopLeft), color: Color.Black * 0.9f);
|
||||
new GUIFrame(new RectTransform(new Vector2(1.25f, 1.25f), repairFrame.RectTransform, Anchor.Center), style: "OuterGlow", color: Color.Black * 0.7f)
|
||||
{
|
||||
UserData = "outerglow",
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
var repairContent = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), repairFrame.RectTransform, Anchor.Center))
|
||||
{
|
||||
RelativeSpacing = 0.05f,
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), repairContent.RectTransform), "", font: GUIStyle.LargeFont)
|
||||
{
|
||||
TextGetter = GetMoney
|
||||
};
|
||||
|
||||
// repair hulls -----------------------------------------------
|
||||
|
||||
var repairHullsHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), repairContent.RectTransform), childAnchor: Anchor.TopRight)
|
||||
{
|
||||
RelativeSpacing = 0.05f,
|
||||
Stretch = true
|
||||
};
|
||||
new GUIImage(new RectTransform(new Vector2(0.3f, 1.0f), repairHullsHolder.RectTransform, Anchor.CenterLeft), "RepairHullButton")
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
CanBeFocused = false
|
||||
};
|
||||
var repairHullsLabel = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.3f), repairHullsHolder.RectTransform), TextManager.Get("RepairAllWalls"), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont)
|
||||
{
|
||||
ForceUpperCase = ForceUpperCase.Yes
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), repairHullsHolder.RectTransform), CampaignMode.HullRepairCost.ToString(), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont);
|
||||
repairHullsButton = new GUIButton(new RectTransform(new Vector2(0.4f, 0.3f), repairHullsHolder.RectTransform) { MinSize = new Point(140, 0) }, TextManager.Get("Repair"))
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (Campaign.PurchasedHullRepairs)
|
||||
{
|
||||
Campaign.Wallet.Refund(CampaignMode.HullRepairCost);
|
||||
Campaign.PurchasedHullRepairs = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Campaign.TryPurchase(null, CampaignMode.HullRepairCost))
|
||||
{
|
||||
GameAnalyticsManager.AddMoneySpentEvent(CampaignMode.HullRepairCost, GameAnalyticsManager.MoneySink.Service, "hullrepairs");
|
||||
Campaign.PurchasedHullRepairs = true;
|
||||
}
|
||||
}
|
||||
GameMain.Client?.SendCampaignState();
|
||||
btn.GetChild<GUITickBox>().Selected = Campaign.PurchasedHullRepairs;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUITickBox(new RectTransform(new Vector2(0.65f), repairHullsButton.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(10, 0) }, "")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
// repair items -------------------------------------------
|
||||
|
||||
var repairItemsHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), repairContent.RectTransform), childAnchor: Anchor.TopRight)
|
||||
{
|
||||
RelativeSpacing = 0.05f,
|
||||
Stretch = true
|
||||
};
|
||||
new GUIImage(new RectTransform(new Vector2(0.3f, 1.0f), repairItemsHolder.RectTransform, Anchor.CenterLeft), "RepairItemsButton")
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
CanBeFocused = false
|
||||
};
|
||||
var repairItemsLabel = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.3f), repairItemsHolder.RectTransform), TextManager.Get("RepairAllItems"), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont)
|
||||
{
|
||||
ForceUpperCase = ForceUpperCase.Yes
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), repairItemsHolder.RectTransform), CampaignMode.ItemRepairCost.ToString(), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont);
|
||||
repairItemsButton = new GUIButton(new RectTransform(new Vector2(0.4f, 0.3f), repairItemsHolder.RectTransform) { MinSize = new Point(140, 0) }, TextManager.Get("Repair"))
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (Campaign.PurchasedItemRepairs)
|
||||
{
|
||||
Campaign.Wallet.Refund(CampaignMode.ItemRepairCost);
|
||||
Campaign.PurchasedItemRepairs = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Campaign.TryPurchase(null, CampaignMode.ItemRepairCost))
|
||||
{
|
||||
GameAnalyticsManager.AddMoneySpentEvent(CampaignMode.ItemRepairCost, GameAnalyticsManager.MoneySink.Service, "devicerepairs");
|
||||
Campaign.PurchasedItemRepairs = true;
|
||||
}
|
||||
}
|
||||
GameMain.Client?.SendCampaignState();
|
||||
btn.GetChild<GUITickBox>().Selected = Campaign.PurchasedItemRepairs;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUITickBox(new RectTransform(new Vector2(0.65f), repairItemsButton.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(10, 0) }, "")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
// replace lost shuttles -------------------------------------------
|
||||
|
||||
var replaceShuttlesHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), repairContent.RectTransform), childAnchor: Anchor.TopRight)
|
||||
{
|
||||
RelativeSpacing = 0.05f,
|
||||
Stretch = true
|
||||
};
|
||||
new GUIImage(new RectTransform(new Vector2(0.3f, 1.0f), replaceShuttlesHolder.RectTransform, Anchor.CenterLeft), "ReplaceShuttlesButton")
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
CanBeFocused = false
|
||||
};
|
||||
var replaceShuttlesLabel = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.3f), replaceShuttlesHolder.RectTransform), TextManager.Get("ReplaceLostShuttles"), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont)
|
||||
{
|
||||
ForceUpperCase = ForceUpperCase.Yes
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), replaceShuttlesHolder.RectTransform), CampaignMode.ShuttleReplaceCost.ToString(), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont);
|
||||
replaceShuttlesButton = new GUIButton(new RectTransform(new Vector2(0.4f, 0.3f), replaceShuttlesHolder.RectTransform) { MinSize = new Point(140, 0) }, TextManager.Get("ReplaceShuttles"))
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (GameMain.GameSession?.SubmarineInfo != null &&
|
||||
GameMain.GameSession.SubmarineInfo.LeftBehindSubDockingPortOccupied)
|
||||
{
|
||||
new GUIMessageBox("", TextManager.Get("ReplaceShuttleDockingPortOccupied"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Campaign.PurchasedLostShuttles)
|
||||
{
|
||||
Campaign.Wallet.Refund(CampaignMode.ShuttleReplaceCost);
|
||||
Campaign.PurchasedLostShuttles = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Campaign.TryPurchase(null, CampaignMode.ShuttleReplaceCost))
|
||||
{
|
||||
GameAnalyticsManager.AddMoneySpentEvent(CampaignMode.ShuttleReplaceCost, GameAnalyticsManager.MoneySink.Service, "retrieveshuttle");
|
||||
Campaign.PurchasedLostShuttles = true;
|
||||
}
|
||||
}
|
||||
GameMain.Client?.SendCampaignState();
|
||||
btn.GetChild<GUITickBox>().Selected = Campaign.PurchasedLostShuttles;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUITickBox(new RectTransform(new Vector2(0.65f), replaceShuttlesButton.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(10, 0) }, "")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
GUITextBlock.AutoScaleAndNormalize(repairHullsLabel, repairItemsLabel, replaceShuttlesLabel);
|
||||
GUITextBlock.AutoScaleAndNormalize(repairHullsButton.GetChild<GUITickBox>().TextBlock, repairItemsButton.GetChild<GUITickBox>().TextBlock, replaceShuttlesButton.GetChild<GUITickBox>().TextBlock);
|
||||
|
||||
// upgrade tab -------------------------------------------------------------------------
|
||||
|
||||
tabs[(int)CampaignMode.InteractionType.Upgrade] = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform), color: Color.Black * 0.9f);
|
||||
@@ -512,7 +346,7 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var missionName = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission?.Name ?? TextManager.Get("NoMission"), font: GUIStyle.SubHeadingFont, wrap: true);
|
||||
// missionName.RectTransform.MinSize = new Point(0, (int)(missionName.Rect.Height * 1.5f));
|
||||
missionName.RectTransform.MinSize = new Point(0, GUI.IntScale(15));
|
||||
if (mission != null)
|
||||
{
|
||||
var tickBox = new GUITickBox(new RectTransform(Vector2.One * 0.9f, missionName.RectTransform, anchor: Anchor.CenterLeft, scaleBasis: ScaleBasis.Smallest) { AbsoluteOffset = new Point((int)missionName.Padding.X, 0) }, label: string.Empty)
|
||||
@@ -701,26 +535,6 @@ namespace Barotrauma
|
||||
|
||||
switch (selectedTab)
|
||||
{
|
||||
case CampaignMode.InteractionType.Repair:
|
||||
repairHullsButton.Enabled =
|
||||
(Campaign.PurchasedHullRepairs || Campaign.Wallet.CanAfford(CampaignMode.HullRepairCost));
|
||||
repairHullsButton.GetChild<GUITickBox>().Selected = Campaign.PurchasedHullRepairs;
|
||||
repairItemsButton.Enabled =
|
||||
(Campaign.PurchasedItemRepairs || Campaign.Wallet.CanAfford(CampaignMode.ItemRepairCost));
|
||||
repairItemsButton.GetChild<GUITickBox>().Selected = Campaign.PurchasedItemRepairs;
|
||||
|
||||
if (GameMain.GameSession?.SubmarineInfo == null || !GameMain.GameSession.SubmarineInfo.SubsLeftBehind)
|
||||
{
|
||||
replaceShuttlesButton.Enabled = false;
|
||||
replaceShuttlesButton.GetChild<GUITickBox>().Selected = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
replaceShuttlesButton.Enabled =
|
||||
(Campaign.PurchasedLostShuttles || Campaign.Wallet.CanAfford(CampaignMode.ShuttleReplaceCost));
|
||||
replaceShuttlesButton.GetChild<GUITickBox>().Selected = Campaign.PurchasedLostShuttles;
|
||||
}
|
||||
break;
|
||||
case CampaignMode.InteractionType.Store:
|
||||
Store.SelectStore(storeIdentifier);
|
||||
break;
|
||||
|
||||
+2
-2
@@ -2606,8 +2606,8 @@ namespace Barotrauma.CharacterEditor
|
||||
animationControls = new GUIFrame(new RectTransform(Vector2.One, centerArea.RectTransform), style: null) { CanBeFocused = false };
|
||||
var layoutGroupAnimation = new GUILayoutGroup(new RectTransform(Vector2.One, animationControls.RectTransform), childAnchor: Anchor.TopLeft) { CanBeFocused = false };
|
||||
var animationSelectionElement = new GUIFrame(new RectTransform(new Point(elementSize.X * 2 - (int)(5 * GUI.xScale), elementSize.Y), layoutGroupAnimation.RectTransform), style: null);
|
||||
var animationSelectionText = new GUITextBlock(new RectTransform(new Point(elementSize.X, elementSize.Y), animationSelectionElement.RectTransform), GetCharacterEditorTranslation("SelectedAnimation") + ": ", Color.WhiteSmoke, textAlignment: Alignment.Center);
|
||||
animSelection = new GUIDropDown(new RectTransform(new Point((int)(100 * GUI.xScale), elementSize.Y), animationSelectionElement.RectTransform, Anchor.TopRight), elementCount: 5);
|
||||
var animationSelectionText = new GUITextBlock(new RectTransform(new Point(elementSize.X, elementSize.Y), animationSelectionElement.RectTransform), GetCharacterEditorTranslation("SelectedAnimation"), Color.WhiteSmoke, textAlignment: Alignment.CenterRight);
|
||||
animSelection = new GUIDropDown(new RectTransform(new Point((int)(150 * GUI.xScale), elementSize.Y), animationSelectionElement.RectTransform, Anchor.Center, Pivot.CenterLeft), elementCount: 5);
|
||||
if (character.AnimController.CanWalk)
|
||||
{
|
||||
animSelection.AddItem(AnimationType.Walk.ToString(), AnimationType.Walk);
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using FarseerPhysics;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -79,21 +78,27 @@ namespace Barotrauma
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null && Character.Controlled.CanInteractWith(Character.Controlled.SelectedConstruction))
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
Character.Controlled.SelectedConstruction.AddToGUIUpdateList();
|
||||
}
|
||||
if (Character.Controlled?.Inventory != null)
|
||||
{
|
||||
foreach (Item item in Character.Controlled.Inventory.AllItems)
|
||||
if (Character.Controlled.SelectedItem is { } selectedItem && Character.Controlled.CanInteractWith(selectedItem))
|
||||
{
|
||||
if (Character.Controlled.HasEquippedItem(item))
|
||||
selectedItem.AddToGUIUpdateList();
|
||||
}
|
||||
if (Character.Controlled.SelectedSecondaryItem is { } selectedSecondaryItem && Character.Controlled.CanInteractWith(selectedSecondaryItem))
|
||||
{
|
||||
selectedSecondaryItem.AddToGUIUpdateList();
|
||||
}
|
||||
if (Character.Controlled.Inventory != null)
|
||||
{
|
||||
foreach (Item item in Character.Controlled.Inventory.AllItems)
|
||||
{
|
||||
item.AddToGUIUpdateList();
|
||||
if (Character.Controlled.HasEquippedItem(item))
|
||||
{
|
||||
item.AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameMain.GameSession?.AddToGUIUpdateList();
|
||||
Character.AddAllToGUIUpdateList();
|
||||
base.AddToGUIUpdateList();
|
||||
@@ -261,11 +266,7 @@ namespace Barotrauma
|
||||
//Draw the rest of the structures, characters and front structures
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
Submarine.DrawBack(spriteBatch, false, e => !(e is Structure) || e.SpriteDepth < 0.9f);
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
if (!c.IsVisible || c.AnimController.Limbs.Any(l => l.DeformSprite != null)) { continue; }
|
||||
c.Draw(spriteBatch, Cam);
|
||||
}
|
||||
DrawCharacters(deformed: false, firstPass: true);
|
||||
spriteBatch.End();
|
||||
|
||||
sw.Stop();
|
||||
@@ -273,11 +274,12 @@ namespace Barotrauma
|
||||
sw.Restart();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
DrawDeformed(firstPass: true);
|
||||
DrawDeformed(firstPass: false);
|
||||
DrawCharacters(deformed: true, firstPass: true);
|
||||
DrawCharacters(deformed: true, firstPass: false);
|
||||
DrawCharacters(deformed: false, firstPass: false);
|
||||
spriteBatch.End();
|
||||
|
||||
void DrawDeformed(bool firstPass)
|
||||
void DrawCharacters(bool deformed, bool firstPass)
|
||||
{
|
||||
//backwards order to render the most recently spawned characters in front (characters spawned later have a larger sprite depth)
|
||||
for (int i = Character.CharacterList.Count - 1; i >= 0; i--)
|
||||
@@ -285,7 +287,14 @@ namespace Barotrauma
|
||||
Character c = Character.CharacterList[i];
|
||||
if (!c.IsVisible) { continue; }
|
||||
if (c.Params.DrawLast == firstPass) { continue; }
|
||||
if (c.AnimController.Limbs.All(l => l.DeformSprite == null)) { continue; }
|
||||
if (deformed)
|
||||
{
|
||||
if (c.AnimController.Limbs.All(l => l.DeformSprite == null)) { continue; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c.AnimController.Limbs.Any(l => l.DeformSprite != null)) { continue; }
|
||||
}
|
||||
c.Draw(spriteBatch, Cam);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -810,7 +810,7 @@ namespace Barotrauma
|
||||
GUI.DrawString(spriteBatch, pos, interestingPos.PositionType.ToString(), Color.White, font: GUIStyle.LargeFont);
|
||||
}
|
||||
|
||||
// TODO: Improve this temporary level editor debug solution (or remove it)
|
||||
// TODO: Improve this temporary level editor debug solution
|
||||
foreach (var pathPoint in Level.Loaded.PathPoints)
|
||||
{
|
||||
Vector2 pathPointPos = new Vector2(pathPoint.Position.X, -pathPoint.Position.Y);
|
||||
@@ -833,6 +833,17 @@ namespace Barotrauma
|
||||
GUI.DrawString(spriteBatch, pathPointPos, "Path Point\n" + pathPoint.Id, color, font: GUIStyle.LargeFont);
|
||||
}
|
||||
|
||||
foreach (var location in Level.Loaded.AbyssResources)
|
||||
{
|
||||
if (location.Resources == null) { continue; }
|
||||
foreach (var resource in location.Resources)
|
||||
{
|
||||
Vector2 resourcePos = new Vector2(resource.Position.X, -resource.Position.Y);
|
||||
spriteBatch.DrawCircle(resourcePos, 100, 6, Color.DarkGreen * 0.5f, thickness: (int)(2 / Cam.Zoom));
|
||||
GUI.DrawString(spriteBatch, resourcePos, resource.Name, Color.DarkGreen, font: GUIStyle.LargeFont);
|
||||
}
|
||||
}
|
||||
|
||||
/*for (int i = 0; i < Level.Loaded.distanceField.Count; i++)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
|
||||
@@ -67,6 +67,10 @@ namespace Barotrauma
|
||||
|
||||
public static readonly Queue<ulong> WorkshopItemsToUpdate = new Queue<ulong>();
|
||||
|
||||
private GUIImage tutorialBanner;
|
||||
private GUITextBlock tutorialHeader, tutorialDescription;
|
||||
private GUIListBox tutorialList;
|
||||
|
||||
#region Creation
|
||||
public MainMenuScreen(GameMain game)
|
||||
{
|
||||
@@ -390,7 +394,7 @@ namespace Barotrauma
|
||||
SelectTab(tb, userdata);
|
||||
|
||||
GameMain.Client = new GameClient(MultiplayerPreferences.Instance.PlayerName.FallbackNullOrEmpty(SteamManager.GetUsername()),
|
||||
IPAddress.Loopback.ToString(), 0, "localhost", 0, false);
|
||||
new LidgrenEndpoint(IPAddress.Loopback, NetConfig.DefaultPort), "localhost", Option<int>.None());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -449,34 +453,7 @@ namespace Barotrauma
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
menuTabs[Tab.Tutorials] = new GUIFrame(new RectTransform(relativeSize, GUI.Canvas, anchor, pivot, minSize, maxSize) { RelativeOffset = relativeSpacing });
|
||||
|
||||
//PLACEHOLDER
|
||||
var tutorialList = new GUIListBox(
|
||||
new RectTransform(new Vector2(0.95f, 0.85f), menuTabs[Tab.Tutorials].RectTransform, Anchor.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.1f) })
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
};
|
||||
var tutorialTypes = new List<Type>()
|
||||
{
|
||||
typeof(MechanicTutorial),
|
||||
typeof(EngineerTutorial),
|
||||
typeof(DoctorTutorial),
|
||||
typeof(OfficerTutorial),
|
||||
typeof(CaptainTutorial),
|
||||
};
|
||||
foreach (Type tutorialType in tutorialTypes)
|
||||
{
|
||||
Tutorial tutorial = (Tutorial)Activator.CreateInstance(tutorialType);
|
||||
var tutorialText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), tutorialList.Content.RectTransform), tutorial.DisplayName, textAlignment: Alignment.Center, font: GUIStyle.LargeFont)
|
||||
{
|
||||
UserData = tutorial
|
||||
};
|
||||
}
|
||||
tutorialList.OnSelected += (component, obj) =>
|
||||
{
|
||||
(obj as Tutorial).Start();
|
||||
return true;
|
||||
};
|
||||
CreateTutorialTab();
|
||||
|
||||
this.game = game;
|
||||
|
||||
@@ -492,7 +469,72 @@ namespace Barotrauma
|
||||
var creditsContainer = new GUIFrame(new RectTransform(new Vector2(0.75f, 1.5f), menuTabs[Tab.Credits].RectTransform, Anchor.CenterRight), style: "OuterGlow", color: Color.Black * 0.8f);
|
||||
creditsPlayer = new CreditsPlayer(new RectTransform(Vector2.One, creditsContainer.RectTransform), "Content/Texts/Credits.xml");
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void CreateTutorialTab()
|
||||
{
|
||||
var tutorialInnerFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), menuTabs[Tab.Tutorials].RectTransform, Anchor.Center), style: "InnerFrame");
|
||||
var tutorialContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), tutorialInnerFrame.RectTransform, Anchor.Center), isHorizontal: true) { RelativeSpacing = 0.02f, Stretch = true };
|
||||
|
||||
tutorialList = new GUIListBox(new RectTransform(new Vector2(0.4f, 1.0f), tutorialContent.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = (component, obj) =>
|
||||
{
|
||||
SelectTutorial(obj as Tutorial);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var tutorialPreview = new GUILayoutGroup(new RectTransform(new Vector2(0.6f, 1.0f), tutorialContent.RectTransform)) { RelativeSpacing = 0.05f, Stretch = true };
|
||||
var imageContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.6f), tutorialPreview.RectTransform), style: "InnerFrame");
|
||||
tutorialBanner = new GUIImage(new RectTransform(Vector2.One, imageContainer.RectTransform), style: null, scaleToFit: true);
|
||||
|
||||
var infoContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.4f), tutorialPreview.RectTransform), style: "GUIFrameListBox");
|
||||
var infoContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), infoContainer.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter);
|
||||
|
||||
tutorialHeader = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.75f), infoContent.RectTransform), string.Empty, font: GUIStyle.SubHeadingFont, textAlignment: Alignment.Center);
|
||||
|
||||
var startButton = new GUIButton(new RectTransform(new Vector2(0.5f, 0.0f), infoContent.RectTransform, Anchor.BottomRight), text: TextManager.Get("startgamebutton"))
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
OnClicked = (component, obj) =>
|
||||
{
|
||||
(tutorialList.SelectedData as Tutorial)?.Start();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Tutorial firstTutorial = null;
|
||||
foreach (var tutorialPrefab in TutorialPrefab.Prefabs.OrderBy(p => p.Order))
|
||||
{
|
||||
var tutorial = new Tutorial(tutorialPrefab);
|
||||
firstTutorial ??= tutorial;
|
||||
var tutorialText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), tutorialList.Content.RectTransform), tutorial.DisplayName)
|
||||
{
|
||||
Padding = new Vector4(30.0f * GUI.Scale, 0,0,0),
|
||||
UserData = tutorial
|
||||
};
|
||||
tutorialText.RectTransform.MinSize = new Point(0, (int)(tutorialText.TextSize.Y * 2));
|
||||
}
|
||||
GUITextBlock.AutoScaleAndNormalize(tutorialList.Content.Children.Select(c => c as GUITextBlock));
|
||||
tutorialList.Select(firstTutorial);
|
||||
}
|
||||
|
||||
private void SelectTutorial(Tutorial tutorial)
|
||||
{
|
||||
tutorialHeader.Text = tutorial.DisplayName;
|
||||
tutorial.TutorialPrefab.Banner?.EnsureLazyLoaded();
|
||||
tutorialBanner.Sprite = tutorial.TutorialPrefab.Banner;
|
||||
tutorialBanner.Color = tutorial.TutorialPrefab.Banner == null ? Color.Black : Color.White;
|
||||
}
|
||||
|
||||
public static void UpdateInstanceTutorialButtons()
|
||||
{
|
||||
if (GameMain.MainMenuScreen is not MainMenuScreen menuScreen) { return; }
|
||||
menuScreen.tutorialList.ClearChildren();
|
||||
menuScreen.CreateTutorialTab();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Selection
|
||||
public override void Select()
|
||||
@@ -513,7 +555,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.Client.Disconnect();
|
||||
GameMain.Client.Quit();
|
||||
GameMain.Client = null;
|
||||
}
|
||||
|
||||
@@ -719,8 +761,13 @@ namespace Barotrauma
|
||||
gamesession.StartRound(fixedSeed ? "abcd" : ToolBox.RandomSeed(8), difficulty, levelGenerationParams);
|
||||
GameMain.GameScreen.Select();
|
||||
// TODO: modding support
|
||||
string[] jobIdentifiers = new string[] { "captain", "engineer", "mechanic", "securityofficer", "medicaldoctor" };
|
||||
foreach (string job in jobIdentifiers)
|
||||
Identifier[] jobIdentifiers = new Identifier[] {
|
||||
"captain".ToIdentifier(),
|
||||
"engineer".ToIdentifier(),
|
||||
"mechanic".ToIdentifier(),
|
||||
"securityofficer".ToIdentifier(),
|
||||
"medicaldoctor".ToIdentifier() };
|
||||
foreach (Identifier job in jobIdentifiers)
|
||||
{
|
||||
var jobPrefab = JobPrefab.Get(job);
|
||||
var variant = Rand.Range(0, jobPrefab.Variants);
|
||||
@@ -756,33 +803,12 @@ namespace Barotrauma
|
||||
|
||||
private void UpdateTutorialList()
|
||||
{
|
||||
var tutorialList = menuTabs[Tab.Tutorials].GetChild<GUIListBox>();
|
||||
|
||||
int completedTutorials = 0;
|
||||
|
||||
foreach (GUITextBlock tutorialText in tutorialList.Content.Children)
|
||||
{
|
||||
if (CompletedTutorials.Instance.Contains(((Tutorial)tutorialText.UserData).Identifier))
|
||||
var tutorial = (Tutorial)tutorialText.UserData;
|
||||
if (CompletedTutorials.Instance.Contains(tutorial.Identifier) && tutorialText.GetChild<GUIImage>() == null)
|
||||
{
|
||||
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
|
||||
new GUIImage(new RectTransform(new Point((int)(tutorialText.Padding.X * 0.8f)), tutorialText.RectTransform, Anchor.CenterLeft), style: "ObjectiveIndicatorCompleted");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -853,9 +879,9 @@ namespace Barotrauma
|
||||
arguments += " -nopassword";
|
||||
}
|
||||
|
||||
if (Steam.SteamManager.GetSteamID() != 0)
|
||||
if (SteamManager.GetSteamId().TryUnwrap(out var steamId1))
|
||||
{
|
||||
arguments += " -steamid " + Steam.SteamManager.GetSteamID();
|
||||
arguments += " -steamid " + steamId1.Value;
|
||||
}
|
||||
int ownerKey = Math.Max(CryptoRandom.Instance.Next(), 1);
|
||||
arguments += " -ownerkey " + ownerKey;
|
||||
@@ -884,8 +910,12 @@ namespace Barotrauma
|
||||
Thread.Sleep(1000); //wait until the server is ready before connecting
|
||||
|
||||
GameMain.Client = new GameClient(MultiplayerPreferences.Instance.PlayerName.FallbackNullOrEmpty(
|
||||
SteamManager.GetUsername().FallbackNullOrEmpty(name)),
|
||||
System.Net.IPAddress.Loopback.ToString(), Steam.SteamManager.GetSteamID(), name, ownerKey, true);
|
||||
SteamManager.GetUsername().FallbackNullOrEmpty(name)),
|
||||
SteamManager.GetSteamId().TryUnwrap(out var steamId)
|
||||
? new SteamP2PEndpoint(steamId)
|
||||
: (Endpoint)new LidgrenEndpoint(IPAddress.Loopback, NetConfig.DefaultPort),
|
||||
name,
|
||||
Option<int>.Some(ownerKey));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1165,7 +1195,7 @@ namespace Barotrauma
|
||||
var playstyleContainer = new GUIFrame(new RectTransform(new Vector2(1.35f, 0.1f), parent.RectTransform), style: null, color: Color.Black);
|
||||
|
||||
playstyleBanner = new GUIImage(new RectTransform(new Vector2(1.0f, 0.1f), playstyleContainer.RectTransform),
|
||||
ServerListScreen.PlayStyleBanners[0], scaleToFit: true)
|
||||
GUIStyle.GetComponentStyle($"PlayStyleBanner.{PlayStyle.Serious}").GetSprite(GUIComponent.ComponentState.None), scaleToFit: true)
|
||||
{
|
||||
UserData = PlayStyle.Serious
|
||||
};
|
||||
@@ -1384,12 +1414,15 @@ namespace Barotrauma
|
||||
|
||||
private void SetServerPlayStyle(PlayStyle playStyle)
|
||||
{
|
||||
playstyleBanner.Sprite = ServerListScreen.PlayStyleBanners[(int)playStyle];
|
||||
playstyleBanner.Sprite = GUIStyle
|
||||
.GetComponentStyle($"PlayStyleBanner.{playStyle}")
|
||||
.GetSprite(GUIComponent.ComponentState.None);
|
||||
playstyleBanner.UserData = playStyle;
|
||||
|
||||
var nameText = playstyleBanner.GetChild<GUITextBlock>();
|
||||
nameText.Text = TextManager.AddPunctuation(':', TextManager.Get("serverplaystyle"), TextManager.Get("servertag." + playStyle));
|
||||
nameText.Color = ServerListScreen.PlayStyleColors[(int)playStyle];
|
||||
nameText.Color = playstyleBanner.Sprite
|
||||
.SourceElement.GetAttributeColor("BannerColor") ?? Color.White;
|
||||
nameText.RectTransform.NonScaledSize = (nameText.Font.MeasureString(nameText.Text) + new Vector2(25, 10) * GUI.Scale).ToPoint();
|
||||
|
||||
playstyleDescription.Text = TextManager.Get("servertagdescription." + playStyle);
|
||||
|
||||
@@ -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()
|
||||
@@ -68,15 +68,31 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (guiButton, o) =>
|
||||
{
|
||||
GameMain.Client?.Disconnect();
|
||||
GameMain.Client?.Quit();
|
||||
GameMain.MainMenuScreen.Select();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (!GameMain.Client.IsServerOwner)
|
||||
{
|
||||
if (GameMain.Client.ClientPeer.ServerContentPackages.Length == 0)
|
||||
{
|
||||
string errorMsg = $"Error in ModDownloadScreen: the list of mods the server has enabled was empty. Content package list received: {GameMain.Client.ClientPeer.ContentPackageOrderReceived}";
|
||||
GameAnalyticsManager.AddErrorEventOnce("ModDownloadScreen.Select:NoContentPackages", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
throw new InvalidOperationException(errorMsg);
|
||||
}
|
||||
if (GameMain.Client.ClientPeer.ServerContentPackages.None(p => p.CorePackage != null))
|
||||
{
|
||||
string errorMsg = $"Error in ModDownloadScreen: no core packages in the list of mods the server has enabled. Content package list received: {GameMain.Client.ClientPeer.ContentPackageOrderReceived}";
|
||||
GameAnalyticsManager.AddErrorEventOnce("ModDownloadScreen.Select:NoCorePackage", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
throw new InvalidOperationException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
var missingPackages = GameMain.Client.ClientPeer.ServerContentPackages
|
||||
.Where(sp => sp.ContentPackage is null).ToArray();
|
||||
if (!missingPackages.Any())
|
||||
if (!missingPackages.Any(p => p.IsMandatory))
|
||||
{
|
||||
if (!GameMain.Client.IsServerOwner)
|
||||
{
|
||||
@@ -84,11 +100,14 @@ namespace Barotrauma
|
||||
ContentPackageManager.EnabledPackages.SetCore(
|
||||
GameMain.Client.ClientPeer.ServerContentPackages
|
||||
.Select(p => p.CorePackage)
|
||||
.First(p => p != null));
|
||||
ContentPackageManager.EnabledPackages.SetRegular(
|
||||
.OfType<CorePackage>().First());
|
||||
List<RegularPackage> regularPackages =
|
||||
GameMain.Client.ClientPeer.ServerContentPackages
|
||||
.Select(p => p.RegularPackage)
|
||||
.Where(p => p != null).ToArray());
|
||||
.OfType<RegularPackage>().ToList();
|
||||
//keep enabled client-side-only mods enabled
|
||||
regularPackages.AddRange(ContentPackageManager.EnabledPackages.Regular.Where(p => !p.HasMultiplayerSyncedContent && !regularPackages.Contains(p)));
|
||||
ContentPackageManager.EnabledPackages.SetRegular(regularPackages);
|
||||
}
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
GameMain.LuaCs.Initialize();
|
||||
@@ -154,16 +173,16 @@ namespace Barotrauma
|
||||
buttonContainerSpacing(0.2f);
|
||||
button(TextManager.Get("No"), () =>
|
||||
{
|
||||
GameMain.Client?.Disconnect();
|
||||
GameMain.Client?.Quit();
|
||||
GameMain.MainMenuScreen.Select();
|
||||
});
|
||||
buttonContainerSpacing(0.1f);
|
||||
|
||||
var missingIds = missingPackages.Where(
|
||||
mp => mp.WorkshopId != 0
|
||||
&& ContentPackageManager.WorkshopPackages.All(wp
|
||||
=> wp.SteamWorkshopId != mp.WorkshopId))
|
||||
.Select(mp => mp.WorkshopId)
|
||||
var missingIds = missingPackages
|
||||
.Where(p => p.IsMandatory)
|
||||
.Select(mp => ContentPackageId.Parse(mp.UgcId))
|
||||
.NotNone()
|
||||
.Where(id => ContentPackageManager.WorkshopPackages.All(wp => !wp.UgcId.Equals(id)))
|
||||
.ToArray();
|
||||
if (missingIds.Any() && SteamManager.IsInitialized)
|
||||
{
|
||||
@@ -173,18 +192,18 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
BulkDownloader.SubscribeToServerMods(missingIds,
|
||||
rejoinEndpoint: GameMain.Client.ClientPeer.ServerConnection.EndPointString,
|
||||
rejoinLobby: SteamManager.CurrentLobbyID,
|
||||
rejoinServerName: GameMain.NetLobbyScreen.ServerName.Text);
|
||||
GameMain.Client.Disconnect();
|
||||
BulkDownloader.SubscribeToServerMods(missingIds.OfType<SteamWorkshopId>().Select(id => id.Value),
|
||||
new ConnectCommand(
|
||||
serverName: GameMain.Client.ServerName,
|
||||
endpoint: GameMain.Client.ClientPeer.ServerEndpoint));
|
||||
GameMain.Client.Quit();
|
||||
}
|
||||
GameMain.MainMenuScreen.Select();
|
||||
}, width: 0.7f);
|
||||
buttonContainerSpacing(0.15f);
|
||||
}
|
||||
|
||||
foreach (var p in missingPackages)
|
||||
foreach (var p in missingPackages.Where(p => p.IsMandatory))
|
||||
{
|
||||
pendingDownloads.Enqueue(p);
|
||||
|
||||
@@ -276,23 +295,50 @@ namespace Barotrauma
|
||||
?? serverPackages.FirstOrDefault(p => p.CorePackage != null)
|
||||
?.CorePackage
|
||||
?? throw new Exception($"Failed to find core package to enable");
|
||||
RegularPackage[] regularPackages
|
||||
= serverPackages.Where(p => p.CorePackage is null)
|
||||
.Select(p =>
|
||||
p.RegularPackage
|
||||
?? downloadedPackages.FirstOrDefault(d => d is RegularPackage && d.Hash.Equals(p.Hash))
|
||||
?? throw new Exception($"Could not find regular package \"{p.Name}\""))
|
||||
.Cast<RegularPackage>()
|
||||
.ToArray();
|
||||
|
||||
List<RegularPackage> regularPackages = new List<RegularPackage>();
|
||||
foreach (var p in serverPackages)
|
||||
{
|
||||
if (p.CorePackage != null) { continue; }
|
||||
RegularPackage? matchingPackage =
|
||||
p.RegularPackage ?? downloadedPackages.FirstOrDefault(d => d is RegularPackage && d.Hash.Equals(p.Hash)) as RegularPackage;
|
||||
if (matchingPackage is null)
|
||||
{
|
||||
if (!p.IsMandatory)
|
||||
{
|
||||
//we don't need to care about missing non-mandatory (= submarine) mods
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Could not find regular package \"{p.Name}\"");
|
||||
}
|
||||
}
|
||||
regularPackages.Add(matchingPackage);
|
||||
}
|
||||
foreach (var regularPackage in regularPackages)
|
||||
{
|
||||
DebugConsole.NewMessage($"Enabling \"{regularPackage.Name}\" ({regularPackage.Dir})", Color.Lime);
|
||||
}
|
||||
|
||||
//keep enabled client-side-only mods enabled
|
||||
regularPackages.AddRange(ContentPackageManager.EnabledPackages.Regular.Where(p => !p.HasMultiplayerSyncedContent && !regularPackages.Contains(p)));
|
||||
|
||||
ContentPackageManager.EnabledPackages.BackUp();
|
||||
ContentPackageManager.EnabledPackages.SetCore(corePackage);
|
||||
ContentPackageManager.EnabledPackages.SetRegular(regularPackages);
|
||||
|
||||
//see if any of the packages we enabled contain subs that we were missing previously, and update their paths
|
||||
foreach (var serverSub in GameMain.Client.ServerSubmarines)
|
||||
{
|
||||
if (File.Exists(serverSub.FilePath)) { continue; }
|
||||
var matchingSub = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == serverSub.Name && s.MD5Hash == serverSub.MD5Hash);
|
||||
if (matchingSub != null)
|
||||
{
|
||||
serverSub.FilePath = matchingSub.FilePath;
|
||||
}
|
||||
}
|
||||
GameMain.NetLobbyScreen.UpdateSubList(GameMain.NetLobbyScreen.SubList, GameMain.Client.ServerSubmarines);
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
GameMain.LuaCs.Initialize();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -665,7 +666,7 @@ namespace Barotrauma
|
||||
OnSelected = (tickbox) =>
|
||||
{
|
||||
if (GameMain.Client == null) { return true; }
|
||||
ServerInfo info = GameMain.Client.ServerSettings.GetServerListInfo();
|
||||
ServerInfo info = GameMain.Client.CreateServerInfoFromSettings();
|
||||
if (tickbox.Selected)
|
||||
{
|
||||
GameMain.ServerListScreen.AddToFavoriteServers(info);
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
@@ -1431,10 +1432,6 @@ namespace Barotrauma
|
||||
bool nameChangePending = isGameRunning && GameMain.Client.PendingName != string.Empty && GameMain.Client?.Character?.Name != GameMain.Client.PendingName;
|
||||
changesPendingText = null;
|
||||
|
||||
if (isGameRunning)
|
||||
{
|
||||
infoContainer.RectTransform.AbsoluteOffset = new Point(0, (int)(parent.Rect.Height * 0.025f));
|
||||
}
|
||||
|
||||
if (TabMenu.PendingChanges)
|
||||
{
|
||||
@@ -1453,7 +1450,6 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Client == null) { return; }
|
||||
string newName = Client.SanitizeName(tb.Text);
|
||||
newName = newName.Replace(":", "").Replace(";", "");
|
||||
if (newName == GameMain.Client.Name) return;
|
||||
if (string.IsNullOrWhiteSpace(newName))
|
||||
{
|
||||
@@ -1529,14 +1525,13 @@ namespace Barotrauma
|
||||
while (i < MultiplayerPreferences.Instance.JobPreferences.Count)
|
||||
{
|
||||
var jobPreference = MultiplayerPreferences.Instance.JobPreferences[i];
|
||||
if (!JobPrefab.Prefabs.ContainsKey(jobPreference.JobIdentifier))
|
||||
if (!JobPrefab.Prefabs.TryGet(jobPreference.JobIdentifier, out JobPrefab prefab) || prefab.HiddenJob)
|
||||
{
|
||||
MultiplayerPreferences.Instance.JobPreferences.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
// The old job variant system used one-based indexing
|
||||
// so let's make sure no one get to pick a variant which doesn't exist
|
||||
var prefab = JobPrefab.Prefabs[jobPreference.JobIdentifier];
|
||||
var variant = Math.Min(jobPreference.Variant, prefab.Variants - 1);
|
||||
jobPrefab = new JobVariant(prefab, variant);
|
||||
break;
|
||||
@@ -1782,6 +1777,10 @@ namespace Barotrauma
|
||||
|
||||
// Hide spectate tickbox if spectating is not allowed
|
||||
spectateBox.Visible = allowSpectating;
|
||||
if (infoContainer != null)
|
||||
{
|
||||
infoContainer.RectTransform.RelativeSize = new Vector2(infoContainer.RectTransform.RelativeSize.X, spectateBox.Visible ? 0.92f : 0.97f);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAutoRestart(bool enabled, float timer = 0.0f)
|
||||
@@ -1795,7 +1794,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; }
|
||||
|
||||
@@ -1818,7 +1817,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,
|
||||
@@ -1874,7 +1873,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,
|
||||
@@ -1882,7 +1881,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)
|
||||
@@ -1893,8 +1892,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,
|
||||
@@ -1914,6 +1921,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"),
|
||||
@@ -1925,7 +1943,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;
|
||||
@@ -1933,7 +1951,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;
|
||||
@@ -2160,15 +2178,8 @@ namespace Barotrauma
|
||||
if (child != null) { PlayerList.RemoveChild(child); }
|
||||
}
|
||||
|
||||
private Client ExtractClientFromClickableArea(GUITextBlock.ClickableArea area)
|
||||
{
|
||||
if (!UInt64.TryParse(area.Data.Metadata, out UInt64 id)) { return null; }
|
||||
Client client = GameMain.Client.ConnectedClients.Find(c => c.SteamID == id)
|
||||
?? GameMain.Client.ConnectedClients.Find(c => c.ID == id)
|
||||
?? GameMain.Client.PreviouslyConnectedClients.FirstOrDefault(c => c.SteamID == id)
|
||||
?? GameMain.Client.PreviouslyConnectedClients.FirstOrDefault(c => c.ID == id);
|
||||
return client;
|
||||
}
|
||||
public static Client ExtractClientFromClickableArea(GUITextBlock.ClickableArea area)
|
||||
=> area.Data.ExtractClient();
|
||||
|
||||
public void SelectPlayer(GUITextBlock component, GUITextBlock.ClickableArea area)
|
||||
{
|
||||
@@ -2188,29 +2199,35 @@ namespace Barotrauma
|
||||
public static void CreateModerationContextMenu(Client client)
|
||||
{
|
||||
if (GUIContextMenu.CurrentContextMenu != null) { return; }
|
||||
if (GameMain.IsSingleplayer || client == null || ((!GameMain.Client?.PreviouslyConnectedClients?.Contains(client)) ?? true)) { return; }
|
||||
bool hasSteam = client.SteamID > 0 && SteamManager.IsInitialized,
|
||||
canKick = GameMain.Client.HasPermission(ClientPermissions.Kick),
|
||||
canBan = GameMain.Client.HasPermission(ClientPermissions.Ban) && client.AllowKicking,
|
||||
canPromo = GameMain.Client.HasPermission(ClientPermissions.ManagePermissions);
|
||||
if (GameMain.IsSingleplayer || client == null) { return; }
|
||||
if (!(GameMain.Client is { PreviouslyConnectedClients: var previouslyConnectedClients })
|
||||
|| !previouslyConnectedClients.Contains(client)) { return; }
|
||||
|
||||
bool hasAccountId = client.AccountId.IsSome();
|
||||
bool canKick = GameMain.Client.HasPermission(ClientPermissions.Kick);
|
||||
bool canBan = GameMain.Client.HasPermission(ClientPermissions.Ban) && client.AllowKicking;
|
||||
bool canManagePermissions = GameMain.Client.HasPermission(ClientPermissions.ManagePermissions);
|
||||
|
||||
// Disable options if we are targeting ourselves
|
||||
if (client.ID == GameMain.Client?.ID)
|
||||
if (client.SessionId == GameMain.Client.SessionId)
|
||||
{
|
||||
canKick = canBan = canPromo = false;
|
||||
canKick = canBan = canManagePermissions = false;
|
||||
}
|
||||
|
||||
List<ContextMenuOption> options = new List<ContextMenuOption>
|
||||
List<ContextMenuOption> options = new List<ContextMenuOption>();
|
||||
|
||||
if (client.AccountId.TryUnwrap(out var accountId) && accountId is SteamId steamId)
|
||||
{
|
||||
new ContextMenuOption("ViewSteamProfile", isEnabled: hasSteam, onSelected: delegate
|
||||
{
|
||||
Steamworks.SteamFriends.OpenWebOverlay($"https://steamcommunity.com/profiles/{client.SteamID}");
|
||||
}),
|
||||
new ContextMenuOption("ModerationMenu.ManagePlayer", isEnabled: true, onSelected: delegate
|
||||
options.Add(new ContextMenuOption("ViewSteamProfile", isEnabled: hasAccountId, onSelected: () =>
|
||||
{
|
||||
SteamManager.OverlayProfile(steamId);
|
||||
}));
|
||||
}
|
||||
|
||||
options.Add(new ContextMenuOption("ModerationMenu.ManagePlayer", isEnabled: true, onSelected: () =>
|
||||
{
|
||||
GameMain.NetLobbyScreen?.SelectPlayer(client);
|
||||
})
|
||||
};
|
||||
}));
|
||||
|
||||
// Creates sub context menu options for all the ranks
|
||||
List<ContextMenuOption> rankOptions = new List<ContextMenuOption>();
|
||||
@@ -2236,18 +2253,18 @@ namespace Barotrauma
|
||||
}) { Tooltip = rank.Description });
|
||||
}
|
||||
|
||||
options.Add(new ContextMenuOption("Rank", isEnabled: canPromo, options: rankOptions.ToArray()));
|
||||
options.Add(new ContextMenuOption("Rank", isEnabled: canManagePermissions, options: rankOptions.ToArray()));
|
||||
|
||||
Color clientColor = client.Character?.Info?.Job.Prefab.UIColor ?? Color.White;
|
||||
|
||||
if (GameMain.Client.ConnectedClients.Contains(client))
|
||||
{
|
||||
options.Add(new ContextMenuOption(client.MutedLocally ? "Unmute" : "Mute", isEnabled: client.ID != GameMain.Client?.ID, onSelected: delegate
|
||||
options.Add(new ContextMenuOption(client.MutedLocally ? "Unmute" : "Mute", isEnabled: client.SessionId != GameMain.Client.SessionId, onSelected: delegate
|
||||
{
|
||||
client.MutedLocally = !client.MutedLocally;
|
||||
}));
|
||||
|
||||
bool kickEnabled = client.ID != GameMain.Client?.ID && client.AllowKicking;
|
||||
bool kickEnabled = client.SessionId != GameMain.Client.SessionId && client.AllowKicking;
|
||||
|
||||
// if the user can kick create a kick option else create the votekick option
|
||||
ContextMenuOption kickOption;
|
||||
@@ -2281,7 +2298,7 @@ namespace Barotrauma
|
||||
|
||||
public bool SelectPlayer(Client selectedClient)
|
||||
{
|
||||
bool myClient = selectedClient.ID == GameMain.Client.ID;
|
||||
bool myClient = selectedClient.SessionId == GameMain.Client.SessionId;
|
||||
bool hasManagePermissions = GameMain.Client.HasPermission(ClientPermissions.ManagePermissions);
|
||||
|
||||
PlayerFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null)
|
||||
@@ -2510,14 +2527,6 @@ namespace Barotrauma
|
||||
};
|
||||
banButton.OnClicked = (bt, userdata) => { BanPlayer(selectedClient); return true; };
|
||||
banButton.OnClicked += ClosePlayerFrame;
|
||||
|
||||
var rangebanButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaTop.RectTransform),
|
||||
TextManager.Get("BanRange"))
|
||||
{
|
||||
UserData = selectedClient
|
||||
};
|
||||
rangebanButton.OnClicked = (bt, userdata) => { BanPlayerRange(selectedClient); return true; };
|
||||
rangebanButton.OnClicked += ClosePlayerFrame;
|
||||
}
|
||||
|
||||
if (GameMain.Client != null && GameMain.Client.ConnectedClients.Contains(selectedClient))
|
||||
@@ -2528,7 +2537,6 @@ namespace Barotrauma
|
||||
var kickVoteButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaLower.RectTransform),
|
||||
TextManager.Get("VoteToKick"))
|
||||
{
|
||||
Enabled = !selectedClient.HasKickVoteFromID(GameMain.Client.ID),
|
||||
OnClicked = (btn, userdata) => { GameMain.Client.VoteForKick(selectedClient); btn.Enabled = false; return true; },
|
||||
UserData = selectedClient
|
||||
};
|
||||
@@ -2560,7 +2568,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedClient.SteamID != 0 && Steam.SteamManager.IsInitialized)
|
||||
if (selectedClient.AccountId.TryUnwrap(out var accountId) && accountId is SteamId steamId && Steam.SteamManager.IsInitialized)
|
||||
{
|
||||
var viewSteamProfileButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), headerContainer.RectTransform, Anchor.TopCenter) { MaxSize = new Point(int.MaxValue, (int)(40 * GUI.Scale)) },
|
||||
TextManager.Get("ViewSteamProfile"))
|
||||
@@ -2570,7 +2578,7 @@ namespace Barotrauma
|
||||
viewSteamProfileButton.TextBlock.AutoScaleHorizontal = true;
|
||||
viewSteamProfileButton.OnClicked = (bt, userdata) =>
|
||||
{
|
||||
SteamManager.OverlayCustomURL("https://steamcommunity.com/profiles/" + selectedClient.SteamID.ToString());
|
||||
SteamManager.OverlayProfile(steamId);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
@@ -2628,13 +2636,7 @@ namespace Barotrauma
|
||||
public void BanPlayer(Client client)
|
||||
{
|
||||
if (GameMain.NetworkMember == null || client == null) { return; }
|
||||
GameMain.Client.CreateKickReasonPrompt(client.Name, ban: true, rangeBan: false);
|
||||
}
|
||||
|
||||
public void BanPlayerRange(Client client)
|
||||
{
|
||||
if (GameMain.NetworkMember == null || client == null) { return; }
|
||||
GameMain.Client.CreateKickReasonPrompt(client.Name, ban: true, rangeBan: true);
|
||||
GameMain.Client.CreateKickReasonPrompt(client.Name, ban: true);
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
@@ -2679,7 +2681,7 @@ namespace Barotrauma
|
||||
if (child.FindChild(c => c.UserData is Pair<string, float> pair && pair.First == "soundicon") is GUIImage soundIcon)
|
||||
{
|
||||
double voipAmplitude = 0.0f;
|
||||
if (client.ID != GameMain.Client.ID)
|
||||
if (client.SessionId != GameMain.Client.SessionId)
|
||||
{
|
||||
voipAmplitude = client.VoipSound?.CurrentAmplitude ?? 0.0f;
|
||||
}
|
||||
@@ -2750,25 +2752,24 @@ namespace Barotrauma
|
||||
if (GameMain.NetworkMember?.ServerSettings == null) { return; }
|
||||
|
||||
PlayStyle playStyle = GameMain.NetworkMember.ServerSettings.PlayStyle;
|
||||
if ((int)playStyle < 0 ||
|
||||
(int)playStyle >= ServerListScreen.PlayStyleBanners.Length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Sprite sprite = ServerListScreen.PlayStyleBanners[(int)playStyle];
|
||||
Sprite sprite = GUIStyle
|
||||
.GetComponentStyle($"PlayStyleBanner.{playStyle}")?
|
||||
.GetSprite(GUIComponent.ComponentState.None);
|
||||
if (sprite is null) { return; }
|
||||
|
||||
float scale = component.Rect.Width / sprite.size.X;
|
||||
sprite.Draw(spriteBatch, component.Center, scale: scale);
|
||||
|
||||
if (!prevPlayStyle.HasValue || playStyle != prevPlayStyle.Value)
|
||||
{
|
||||
var nameText = component.GetChild<GUITextBlock>();
|
||||
nameText.Text = TextManager.Get("servertag." + playStyle);
|
||||
nameText.Color = ServerListScreen.PlayStyleColors[(int)playStyle];
|
||||
nameText.Text = TextManager.Get($"ServerTag.{playStyle}");
|
||||
nameText.Color = sprite.SourceElement.GetAttributeColor("BannerColor") ?? Color.White;
|
||||
nameText.RectTransform.NonScaledSize = (nameText.Font.MeasureString(nameText.Text) + new Vector2(25, 10) * GUI.Scale).ToPoint();
|
||||
prevPlayStyle = playStyle;
|
||||
|
||||
component.ToolTip = TextManager.Get("servertagdescription." + playStyle);
|
||||
component.ToolTip = TextManager.Get($"ServerTagDescription.{playStyle}");
|
||||
}
|
||||
|
||||
publicOrPrivate.RectTransform.NonScaledSize = (publicOrPrivate.Font.MeasureString(publicOrPrivate.Text) + new Vector2(25, 8) * GUI.Scale).ToPoint();
|
||||
@@ -3239,6 +3240,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)
|
||||
@@ -3271,6 +3288,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
|
||||
{
|
||||
@@ -3672,7 +3716,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"), "",
|
||||
|
||||
@@ -55,9 +55,7 @@ namespace Barotrauma
|
||||
while (timer < duration)
|
||||
{
|
||||
GUI.ScreenOverlayColor = Color.Lerp(from, to, Math.Min(timer / duration, 1.0f));
|
||||
|
||||
timer += CoroutineManager.UnscaledDeltaTime;
|
||||
|
||||
timer += CoroutineManager.DeltaTime;
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public class PanelAnimator
|
||||
{
|
||||
private readonly GUIScissorComponent container;
|
||||
|
||||
private readonly GUIFrame leftFrame;
|
||||
private readonly GUIComponent middleFrame;
|
||||
private readonly GUIFrame rightFrame;
|
||||
|
||||
private readonly GUIButton leftButton;
|
||||
private readonly GUIButton rightButton;
|
||||
|
||||
private float leftAnimState = 1.0f;
|
||||
private float rightAnimState = 0.0f;
|
||||
|
||||
public bool LeftEnabled
|
||||
{
|
||||
get => leftButton.Enabled;
|
||||
set => leftButton.Enabled = value;
|
||||
}
|
||||
public bool RightEnabled
|
||||
{
|
||||
get => rightButton.Enabled;
|
||||
set => rightButton.Enabled = value;
|
||||
}
|
||||
|
||||
public bool LeftVisible = true;
|
||||
public bool RightVisible = false;
|
||||
|
||||
public PanelAnimator(RectTransform rectTransform, GUIFrame leftFrame, GUIComponent middleFrame, GUIFrame rightFrame)
|
||||
{
|
||||
container = new GUIScissorComponent(rectTransform);
|
||||
|
||||
this.leftFrame = leftFrame;
|
||||
this.middleFrame = middleFrame;
|
||||
this.rightFrame = rightFrame;
|
||||
|
||||
void own(GUIComponent component)
|
||||
{
|
||||
component.RectTransform.Parent = container.Content.RectTransform;
|
||||
component.RectTransform.Anchor = Anchor.TopLeft;
|
||||
component.RectTransform.Pivot = Pivot.TopLeft;
|
||||
|
||||
component.GetAllChildren<GUIDropDown>().ForEach(dd => dd.RefreshListBoxParent());
|
||||
}
|
||||
|
||||
GUIButton makeButton(Action action)
|
||||
=> new GUIButton(new RectTransform(new Vector2(0.01f, 1.0f), container.Content.RectTransform)
|
||||
{ MinSize = new Point(20, 0), MaxSize = new Point(int.MaxValue, (int)(150 * GUI.Scale)) },
|
||||
style: "UIToggleButton")
|
||||
{
|
||||
OnClicked = (_, __) =>
|
||||
{
|
||||
action();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
own(leftFrame);
|
||||
this.leftButton = makeButton(() => LeftVisible = !LeftVisible);
|
||||
|
||||
own(middleFrame);
|
||||
|
||||
this.rightButton = makeButton(() => RightVisible = !RightVisible);
|
||||
own(rightFrame);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!LeftEnabled) { LeftVisible = false; }
|
||||
if (!RightEnabled) { RightVisible = false; }
|
||||
|
||||
static void updateState(ref float state, bool visible)
|
||||
=> state = MathHelper.Lerp(state, visible ? 0.0f : 1.0f, 0.5f);
|
||||
updateState(ref leftAnimState, LeftVisible);
|
||||
updateState(ref rightAnimState, RightVisible);
|
||||
|
||||
static int width(GUIComponent c)
|
||||
=> c.RectTransform.NonScaledSize.X;
|
||||
|
||||
int height = container.RectTransform.NonScaledSize.Y;
|
||||
int buttonY = height/2 - leftButton.RectTransform.NonScaledSize.Y/2;
|
||||
|
||||
leftFrame.RectTransform.AbsoluteOffset = new Point((int)(-width(leftFrame) * leftAnimState), 0);
|
||||
leftButton.RectTransform.AbsoluteOffset = leftFrame.RectTransform.AbsoluteOffset
|
||||
+ new Point(width(leftFrame), buttonY);
|
||||
leftButton.Children.ForEach(c => c.SpriteEffects = LeftVisible
|
||||
? SpriteEffects.FlipHorizontally
|
||||
: SpriteEffects.None);
|
||||
|
||||
rightFrame.RectTransform.AbsoluteOffset = new Point((int)(width(container) + width(rightFrame) * (rightAnimState-1f)), 0);
|
||||
rightButton.RectTransform.AbsoluteOffset = rightFrame.RectTransform.AbsoluteOffset
|
||||
+ new Point(-width(rightButton), buttonY);
|
||||
rightButton.Children.ForEach(c => c.SpriteEffects = RightVisible
|
||||
? SpriteEffects.None
|
||||
: SpriteEffects.FlipHorizontally);
|
||||
|
||||
middleFrame.RectTransform.AbsoluteOffset = new Point(
|
||||
leftButton.RectTransform.AbsoluteOffset.X + width(leftButton),
|
||||
0);
|
||||
middleFrame.RectTransform.NonScaledSize = new Point(
|
||||
rightButton.RectTransform.AbsoluteOffset.X - middleFrame.RectTransform.AbsoluteOffset.X,
|
||||
height);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1676
File diff suppressed because it is too large
Load Diff
@@ -149,7 +149,7 @@ namespace Barotrauma
|
||||
private GUIDropDown linkedSubBox;
|
||||
|
||||
private static GUIComponent autoSaveLabel;
|
||||
private static int maxAutoSaves => GameSettings.CurrentConfig.MaxAutoSaves;
|
||||
private static int MaxAutoSaves => GameSettings.CurrentConfig.MaxAutoSaves;
|
||||
|
||||
public static readonly object ItemAddMutex = new object(), ItemRemoveMutex = new object();
|
||||
|
||||
@@ -228,6 +228,8 @@ namespace Barotrauma
|
||||
|
||||
private static bool isAutoSaving;
|
||||
|
||||
private KeyOrMouse toggleEntityListBind;
|
||||
|
||||
public override Camera Cam => cam;
|
||||
|
||||
public static XDocument AutoSaveInfo;
|
||||
@@ -813,8 +815,13 @@ namespace Barotrauma
|
||||
var itemCount = new GUITextBlock(new RectTransform(new Vector2(0.33f, 1.0f), itemCountText.RectTransform, Anchor.TopRight, Pivot.TopLeft), "", textAlignment: Alignment.CenterRight);
|
||||
itemCount.TextGetter = () =>
|
||||
{
|
||||
itemCount.TextColor = Item.ItemList.Count > MaxItems ? GUIStyle.Red : Color.Lerp(GUIStyle.Green, GUIStyle.Orange, Item.ItemList.Count / (float)MaxItems);
|
||||
return Item.ItemList.Count.ToString();
|
||||
int count = Item.ItemList.Count;
|
||||
if (dummyCharacter?.Inventory != null)
|
||||
{
|
||||
count -= dummyCharacter.Inventory.AllItems.Count();
|
||||
}
|
||||
itemCount.TextColor = count > MaxItems ? GUIStyle.Red : Color.Lerp(GUIStyle.Green, GUIStyle.Orange, count / (float)MaxItems);
|
||||
return count.ToString();
|
||||
};
|
||||
|
||||
var structureCountText = new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.0f), paddedEntityCountPanel.RectTransform), TextManager.Get("Structures"),
|
||||
@@ -921,7 +928,6 @@ namespace Barotrauma
|
||||
toggleEntityMenuButton = new GUIButton(new RectTransform(new Vector2(0.15f, 0.08f), EntityMenu.RectTransform, Anchor.TopCenter, Pivot.BottomCenter) { MinSize = new Point(0, 15) },
|
||||
style: "UIToggleButtonVertical")
|
||||
{
|
||||
ToolTip = RichString.Rich($"{TextManager.Get("EntityMenuToggleTooltip")}\n‖color:125,125,125‖{GameSettings.CurrentConfig.KeyMap.Bindings[InputType.ToggleInventory].Name}‖color:end‖"),
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
entityMenuOpen = !entityMenuOpen;
|
||||
@@ -1503,7 +1509,7 @@ namespace Barotrauma
|
||||
/// <returns></returns>
|
||||
private static IEnumerable<CoroutineStatus> AutoSaveCoroutine()
|
||||
{
|
||||
DateTime target = DateTime.Now.AddMinutes(GameSettings.CurrentConfig.AutoSaveIntervalSeconds);
|
||||
DateTime target = DateTime.Now.AddSeconds(GameSettings.CurrentConfig.AutoSaveIntervalSeconds);
|
||||
DateTime tempTarget = DateTime.Now;
|
||||
|
||||
bool wasPaused = false;
|
||||
@@ -1547,6 +1553,8 @@ namespace Barotrauma
|
||||
|
||||
GUI.ForceMouseOn(null);
|
||||
|
||||
if (ImageManager.EditorMode) { GameSettings.SaveCurrentConfig(); }
|
||||
|
||||
MapEntityPrefab.Selected = null;
|
||||
|
||||
saveFrame = null;
|
||||
@@ -1555,7 +1563,9 @@ namespace Barotrauma
|
||||
MapEntity.DeselectAll();
|
||||
ClearUndoBuffer();
|
||||
|
||||
#if !DEBUG
|
||||
DebugConsole.DeactivateCheats();
|
||||
#endif
|
||||
|
||||
SetMode(Mode.Default);
|
||||
|
||||
@@ -1644,7 +1654,7 @@ namespace Barotrauma
|
||||
if (AutoSaveInfo?.Root == null || MainSub?.Info == null) { return; }
|
||||
|
||||
int saveCount = AutoSaveInfo.Root.Elements().Count();
|
||||
while (AutoSaveInfo.Root.Elements().Count() > maxAutoSaves)
|
||||
while (AutoSaveInfo.Root.Elements().Count() > MaxAutoSaves)
|
||||
{
|
||||
XElement min = AutoSaveInfo.Root.Elements().OrderBy(element => element.GetAttributeUInt64("time", 0)).FirstOrDefault();
|
||||
#warning TODO: revise
|
||||
@@ -1795,25 +1805,14 @@ namespace Barotrauma
|
||||
{
|
||||
Type subFileType = DetermineSubFileType(MainSub?.Info.Type ?? SubmarineType.Player);
|
||||
|
||||
void addSubAndSaveModProject(ModProject modProject, string filePath, string packagePath)
|
||||
static string getExistingFilePath(ContentPackage package, string fileName)
|
||||
{
|
||||
filePath = filePath.CleanUpPath();
|
||||
packagePath = packagePath.CleanUpPath();
|
||||
string packageDir = Path.GetDirectoryName(packagePath).CleanUpPathCrossPlatform(correctFilenameCase: false);
|
||||
if (filePath.StartsWith(packageDir))
|
||||
if (Submarine.MainSub?.Info == null) { return null; }
|
||||
if (package.Files.Any(f => f.Path == MainSub.Info.FilePath && Path.GetFileName(f.Path.Value) == fileName))
|
||||
{
|
||||
filePath = $"{ContentPath.ModDirStr}/{filePath[packageDir.Length..]}";
|
||||
return MainSub.Info.FilePath;
|
||||
}
|
||||
if (!modProject.Files.Any(f => f.Type == subFileType &&
|
||||
f.Path == filePath))
|
||||
{
|
||||
var newFile = ModProject.File.FromPath(filePath, subFileType);
|
||||
modProject.AddFile(newFile);
|
||||
}
|
||||
|
||||
using var _ = Validation.SkipInDebugBuilds();
|
||||
modProject.DiscardHashAndInstallTime();
|
||||
modProject.Save(packagePath);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!GameMain.DebugDraw)
|
||||
@@ -1837,7 +1836,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);
|
||||
@@ -1859,101 +1858,139 @@ namespace Barotrauma
|
||||
#if !DEBUG
|
||||
throw new InvalidOperationException("Cannot save to Vanilla package");
|
||||
#endif
|
||||
savePath = string.Format((MainSub?.Info.Type ?? SubmarineType.Player) switch
|
||||
{
|
||||
SubmarineType.Player => "Content/Submarines/{0}",
|
||||
SubmarineType.Outpost => "Content/Map/Outposts/{0}",
|
||||
SubmarineType.Ruin => "Content/Submarines/{0}", //we don't seem to use this anymore...
|
||||
SubmarineType.Wreck => "Content/Map/Wrecks/{0}",
|
||||
SubmarineType.BeaconStation => "Content/Map/BeaconStations/{0}",
|
||||
SubmarineType.EnemySubmarine => "Content/Map/EnemySubmarines/{0}",
|
||||
SubmarineType.OutpostModule => "Content/Map/Outposts/{0}",
|
||||
_ => throw new InvalidOperationException()
|
||||
}, savePath);
|
||||
savePath =
|
||||
getExistingFilePath(packageToSaveTo, savePath) ??
|
||||
string.Format((MainSub?.Info.Type ?? SubmarineType.Player) switch
|
||||
{
|
||||
SubmarineType.Player => "Content/Submarines/{0}",
|
||||
SubmarineType.Outpost => "Content/Map/Outposts/{0}",
|
||||
SubmarineType.Ruin => "Content/Submarines/{0}", //we don't seem to use this anymore...
|
||||
SubmarineType.Wreck => "Content/Map/Wrecks/{0}",
|
||||
SubmarineType.BeaconStation => "Content/Map/BeaconStations/{0}",
|
||||
SubmarineType.EnemySubmarine => "Content/Map/EnemySubmarines/{0}",
|
||||
SubmarineType.OutpostModule => MainSub.Info.FilePath.Contains("RuinModules") ? "Content/Map/RuinModules/{0}" : "Content/Map/Outposts/{0}",
|
||||
_ => throw new InvalidOperationException()
|
||||
}, savePath);
|
||||
modProject.ModVersion = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
savePath = Path.Combine(packageToSaveTo.Dir, savePath);
|
||||
string existingFilePath = getExistingFilePath(packageToSaveTo, savePath);
|
||||
//if we're trying to save a sub that's already included in the package with the same name as before, save directly in the same path
|
||||
if (existingFilePath != null)
|
||||
{
|
||||
savePath = existingFilePath;
|
||||
}
|
||||
//otherwise make sure we're not trying to overwrite another sub in the same package
|
||||
else
|
||||
{
|
||||
savePath = Path.Combine(packageToSaveTo.Dir, savePath);
|
||||
if (File.Exists(savePath))
|
||||
{
|
||||
var verification = new GUIMessageBox(TextManager.Get("warning"), TextManager.Get("subeditor.duplicatesubinpackage"),
|
||||
new LocalizedString[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
verification.Buttons[0].OnClicked = (_, _) =>
|
||||
{
|
||||
addSubAndSave(modProject, savePath, fileListPath);
|
||||
verification.Close();
|
||||
return true;
|
||||
};
|
||||
verification.Buttons[1].OnClicked = verification.Close;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
addSubAndSaveModProject(modProject, savePath, fileListPath);
|
||||
}
|
||||
else if (MainSub?.Info?.FilePath != null
|
||||
&& MainSub.Info.Name != null
|
||||
&& MainSub.Info.FilePath.StartsWith(ContentPackage.LocalModsDir)
|
||||
&& MainSub.Info.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
prevSavePath = MainSub.Info.FilePath.CleanUpPath();
|
||||
ContentPackage contentPackage = GetLocalPackageThatOwnsSub(MainSub.Info);
|
||||
if (contentPackage == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Tried to overwrite a submarine ({name}) that's not in a local package!");
|
||||
}
|
||||
ModProject modProject = new ModProject(contentPackage);
|
||||
packageToSaveTo = contentPackage;
|
||||
savePath = prevSavePath;
|
||||
addSubAndSaveModProject(modProject, savePath, contentPackage.Path);
|
||||
addSubAndSave(modProject, savePath, fileListPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
savePath = Path.Combine(newLocalModDir, savePath);
|
||||
ModProject modProject = new ModProject { Name = name };
|
||||
addSubAndSaveModProject(modProject, savePath, Path.Combine(Path.GetDirectoryName(savePath), ContentPackage.FileListFileName));
|
||||
}
|
||||
savePath = savePath.CleanUpPathCrossPlatform(correctFilenameCase: false);
|
||||
|
||||
if (MainSub != null)
|
||||
{
|
||||
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = true;
|
||||
if (previewImage?.Sprite?.Texture != null && !previewImage.Sprite.Texture.IsDisposed && MainSub.Info.Type != SubmarineType.OutpostModule)
|
||||
if (File.Exists(savePath))
|
||||
{
|
||||
bool savePreviewImage = true;
|
||||
using System.IO.MemoryStream imgStream = new System.IO.MemoryStream();
|
||||
try
|
||||
{
|
||||
previewImage.Sprite.Texture.SaveAsPng(imgStream, previewImage.Sprite.Texture.Width, previewImage.Sprite.Texture.Height);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError($"Saving the preview image of the submarine \"{MainSub.Info.Name}\" failed.", e);
|
||||
savePreviewImage = false;
|
||||
}
|
||||
MainSub.TrySaveAs(savePath, savePreviewImage ? imgStream : null);
|
||||
new GUIMessageBox(TextManager.Get("warning"), TextManager.GetWithVariable("subeditor.packagealreadyexists", "[name]", name));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainSub.TrySaveAs(savePath);
|
||||
ModProject modProject = new ModProject { Name = name };
|
||||
addSubAndSave(modProject, savePath, Path.Combine(Path.GetDirectoryName(savePath), ContentPackage.FileListFileName));
|
||||
}
|
||||
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = false;
|
||||
}
|
||||
|
||||
MainSub.CheckForErrors();
|
||||
|
||||
GUI.AddMessage(TextManager.GetWithVariable("SubSavedNotification", "[filepath]", savePath), GUIStyle.Green);
|
||||
|
||||
if (savePath.StartsWith(newLocalModDir))
|
||||
void addSubAndSave(ModProject modProject, string filePath, string packagePath)
|
||||
{
|
||||
filePath = filePath.CleanUpPath();
|
||||
packagePath = packagePath.CleanUpPath();
|
||||
string packageDir = Path.GetDirectoryName(packagePath).CleanUpPathCrossPlatform(correctFilenameCase: false);
|
||||
if (filePath.StartsWith(packageDir))
|
||||
{
|
||||
ContentPackageManager.LocalPackages.Refresh();
|
||||
var newPackage = ContentPackageManager.LocalPackages.FirstOrDefault(p => p.Path.StartsWith(newLocalModDir));
|
||||
if (newPackage is RegularPackage regular)
|
||||
filePath = $"{ContentPath.ModDirStr}/{filePath[packageDir.Length..]}";
|
||||
}
|
||||
if (!modProject.Files.Any(f => f.Type == subFileType &&
|
||||
f.Path == filePath))
|
||||
{
|
||||
var newFile = ModProject.File.FromPath(filePath, subFileType);
|
||||
modProject.AddFile(newFile);
|
||||
}
|
||||
|
||||
using var _ = Validation.SkipInDebugBuilds();
|
||||
modProject.DiscardHashAndInstallTime();
|
||||
modProject.Save(packagePath);
|
||||
|
||||
savePath = savePath.CleanUpPathCrossPlatform(correctFilenameCase: false);
|
||||
if (MainSub != null)
|
||||
{
|
||||
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = true;
|
||||
if (previewImage?.Sprite?.Texture != null && !previewImage.Sprite.Texture.IsDisposed && MainSub.Info.Type != SubmarineType.OutpostModule)
|
||||
{
|
||||
ContentPackageManager.EnabledPackages.EnableRegular(regular);
|
||||
GameSettings.SaveCurrentConfig();
|
||||
bool savePreviewImage = true;
|
||||
using System.IO.MemoryStream imgStream = new System.IO.MemoryStream();
|
||||
try
|
||||
{
|
||||
previewImage.Sprite.Texture.SaveAsPng(imgStream, previewImage.Sprite.Texture.Width, previewImage.Sprite.Texture.Height);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError($"Saving the preview image of the submarine \"{MainSub.Info.Name}\" failed.", e);
|
||||
savePreviewImage = false;
|
||||
}
|
||||
MainSub.TrySaveAs(savePath, savePreviewImage ? imgStream : null);
|
||||
}
|
||||
}
|
||||
if (packageToSaveTo != null) { ReloadModifiedPackage(packageToSaveTo); }
|
||||
SubmarineInfo.RefreshSavedSub(savePath);
|
||||
if (prevSavePath != null && prevSavePath != savePath) { SubmarineInfo.RefreshSavedSub(prevSavePath); }
|
||||
MainSub.Info.PreviewImage = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.FilePath == savePath)?.PreviewImage;
|
||||
else
|
||||
{
|
||||
MainSub.TrySaveAs(savePath);
|
||||
}
|
||||
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = false;
|
||||
|
||||
string downloadFolder = Path.GetFullPath(SaveUtil.SubmarineDownloadFolder);
|
||||
linkedSubBox.ClearChildren();
|
||||
foreach (SubmarineInfo sub in SubmarineInfo.SavedSubmarines)
|
||||
{
|
||||
if (sub.Type != SubmarineType.Player) { continue; }
|
||||
if (Path.GetDirectoryName(Path.GetFullPath(sub.FilePath)) == downloadFolder) { continue; }
|
||||
linkedSubBox.AddItem(sub.Name, sub);
|
||||
MainSub.CheckForErrors();
|
||||
|
||||
GUI.AddMessage(TextManager.GetWithVariable("SubSavedNotification", "[filepath]", savePath), GUIStyle.Green);
|
||||
|
||||
if (savePath.StartsWith(newLocalModDir))
|
||||
{
|
||||
ContentPackageManager.LocalPackages.Refresh();
|
||||
var newPackage = ContentPackageManager.LocalPackages.FirstOrDefault(p => p.Path.StartsWith(newLocalModDir));
|
||||
if (newPackage is RegularPackage regular)
|
||||
{
|
||||
ContentPackageManager.EnabledPackages.EnableRegular(regular);
|
||||
GameSettings.SaveCurrentConfig();
|
||||
}
|
||||
}
|
||||
if (packageToSaveTo != null) { ReloadModifiedPackage(packageToSaveTo); }
|
||||
SubmarineInfo.RefreshSavedSub(savePath);
|
||||
if (prevSavePath != null && prevSavePath != savePath) { SubmarineInfo.RefreshSavedSub(prevSavePath); }
|
||||
MainSub.Info.PreviewImage = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.FilePath == savePath)?.PreviewImage;
|
||||
|
||||
string downloadFolder = Path.GetFullPath(SaveUtil.SubmarineDownloadFolder);
|
||||
linkedSubBox.ClearChildren();
|
||||
foreach (SubmarineInfo sub in SubmarineInfo.SavedSubmarines)
|
||||
{
|
||||
if (sub.Type != SubmarineType.Player) { continue; }
|
||||
if (Path.GetDirectoryName(Path.GetFullPath(sub.FilePath)) == downloadFolder) { continue; }
|
||||
linkedSubBox.AddItem(sub.Name, sub);
|
||||
}
|
||||
subNameLabel.Text = ToolBox.LimitString(MainSub.Info.Name, subNameLabel.Font, subNameLabel.Rect.Width);
|
||||
}
|
||||
subNameLabel.Text = ToolBox.LimitString(MainSub.Info.Name, subNameLabel.Font, subNameLabel.Rect.Width);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -2408,12 +2445,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) =>
|
||||
@@ -2433,6 +2473,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,
|
||||
@@ -2705,40 +2770,31 @@ namespace Barotrauma
|
||||
new GUICustomComponent(new RectTransform(Vector2.Zero, saveInPackageLayout.RectTransform),
|
||||
onUpdate: (f, component) =>
|
||||
{
|
||||
bool canCreateNewPackage = true;
|
||||
foreach (GUIComponent contentChild in packageToSaveInList.Content.Children)
|
||||
{
|
||||
contentChild.Visible = !(contentChild.UserData is ContentPackage p)
|
||||
|| !string.Equals(p.Name, nameBox.Text, StringComparison.OrdinalIgnoreCase);
|
||||
canCreateNewPackage &= contentChild.Visible;
|
||||
contentChild.Visible &= !(contentChild.GetChild<GUILayoutGroup>()?.GetChild<GUITextBlock>() is GUITextBlock tb &&
|
||||
!tb.Text.Contains(packToSaveInFilter.Text, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
if (newPackageListIcon.Style.Identifier != "NewContentPackageIcon" && canCreateNewPackage)
|
||||
{
|
||||
GUIStyle.Apply(newPackageListIcon, "NewContentPackageIcon");
|
||||
newPackageListText.Text = TextManager.Get("CreateNewLocalPackage");
|
||||
}
|
||||
if (newPackageListIcon.Style.Identifier != "WorkshopMenu.EditButton" && !canCreateNewPackage)
|
||||
{
|
||||
GUIStyle.Apply(newPackageListIcon, "WorkshopMenu.EditButton");
|
||||
newPackageListText.Text = TextManager.GetWithVariable("UpdateExistingLocalPackage", "[mod]", nameBox.Text);
|
||||
}
|
||||
});
|
||||
packageToSaveInList.Select(0);
|
||||
ContentPackage ownerPkg = null;
|
||||
if (MainSub?.Info != null) { ownerPkg = GetLocalPackageThatOwnsSub(MainSub.Info); }
|
||||
foreach (var p in ContentPackageManager.LocalPackages)
|
||||
{
|
||||
addItemToPackageToSaveList(p.Name, p);
|
||||
var packageListItem = addItemToPackageToSaveList(p.Name, p);
|
||||
if (p == ownerPkg)
|
||||
{
|
||||
var packageListIcon = packageListItem.GetChild<GUIFrame>();
|
||||
var packageListText = packageListItem.GetChild<GUITextBlock>();
|
||||
GUIStyle.Apply(packageListIcon, "WorkshopMenu.EditButton");
|
||||
packageListText.Text = TextManager.GetWithVariable("UpdateExistingLocalPackage", "[mod]", p.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (ownerPkg != null && !string.Equals(ownerPkg.Name, nameBox.Text, StringComparison.OrdinalIgnoreCase))
|
||||
if (ownerPkg != null)
|
||||
{
|
||||
packageToSaveInList.Select(ownerPkg);
|
||||
packageToSaveInList.ScrollToElement(packageToSaveInList.SelectedComponent);
|
||||
var element = packageToSaveInList.Content.FindChild(ownerPkg);
|
||||
element?.RectTransform.SetAsFirstChild();
|
||||
}
|
||||
packageToSaveInList.Select(0);
|
||||
|
||||
var requiredContentPackagesLayout = new GUILayoutGroup(new RectTransform(Vector2.One,
|
||||
horizontalArea.RectTransform, Anchor.BottomRight))
|
||||
@@ -2968,7 +3024,7 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (char illegalChar in Path.GetInvalidFileNameChars())
|
||||
foreach (char illegalChar in Path.GetInvalidFileNameCharsCrossPlatform())
|
||||
{
|
||||
if (nameBox.Text.Contains(illegalChar))
|
||||
{
|
||||
@@ -3343,23 +3399,21 @@ namespace Barotrauma
|
||||
{
|
||||
if (!(userData is XElement element)) { return; }
|
||||
|
||||
#warning TODO: revise
|
||||
#warning TODO: revise
|
||||
string filePath = element.GetAttributeStringUnrestricted("file", "");
|
||||
if (string.IsNullOrWhiteSpace(filePath)) { return; }
|
||||
|
||||
var loadedSub = Submarine.Load(new SubmarineInfo(filePath), true);
|
||||
|
||||
// set the submarine file path to the "default" value
|
||||
var unspecifiedFileName = TextManager.Get("UnspecifiedSubFileName");
|
||||
loadedSub.Info.FilePath = Path.Combine(ContentPackage.LocalModsDir, unspecifiedFileName.Value, $"{unspecifiedFileName}.sub");
|
||||
loadedSub.Info.Name = unspecifiedFileName.Value;
|
||||
try
|
||||
{
|
||||
loadedSub.Info.Name = loadedSub.Info.SubmarineElement.GetAttributeString("name", loadedSub.Info.Name);
|
||||
loadedSub.Info.Name = loadedSub.Info.SubmarineElement.GetAttributeString("name", loadedSub.Info.Name);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to find a name for the submarine.", e);
|
||||
var unspecifiedFileName = TextManager.Get("UnspecifiedSubFileName");
|
||||
loadedSub.Info.Name = unspecifiedFileName.Value;
|
||||
}
|
||||
MainSub = loadedSub;
|
||||
MainSub.SetPrevTransform(MainSub.Position);
|
||||
@@ -3396,7 +3450,8 @@ namespace Barotrauma
|
||||
{
|
||||
if (GetWorkshopPackageThatOwnsSub(selectedSubInfo) is ContentPackage workshopPackage)
|
||||
{
|
||||
if (publishedWorkshopItemIds.Contains(workshopPackage.SteamWorkshopId))
|
||||
if (workshopPackage.TryExtractSteamWorkshopId(out var workshopId)
|
||||
&& publishedWorkshopItemIds.Contains(workshopId.Value))
|
||||
{
|
||||
AskLoadPublishedSub(selectedSubInfo, workshopPackage);
|
||||
}
|
||||
@@ -3732,7 +3787,6 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
List<ContextMenuOption> availableLayerOptions = new List<ContextMenuOption>
|
||||
{
|
||||
new ContextMenuOption("editor.layer.nolayer", true, onSelected: () => { MoveToLayer(null, targets); })
|
||||
@@ -3775,7 +3829,8 @@ namespace Barotrauma
|
||||
{
|
||||
if (!me.Removed) { me.Remove(); }
|
||||
}
|
||||
}));
|
||||
}),
|
||||
new ContextMenuOption(TextManager.Get("editortip.shiftforextraoptions") + '\n' + TextManager.Get("editortip.altforruler"), isEnabled: false, onSelected: null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4263,7 +4318,7 @@ namespace Barotrauma
|
||||
MapEntity.SelectedList.Clear();
|
||||
MapEntity.FilteredSelectedList.Clear();
|
||||
MapEntity.SelectEntity(itemContainer);
|
||||
dummyCharacter.SelectedConstruction = itemContainer;
|
||||
dummyCharacter.SelectedItem = itemContainer;
|
||||
FilterEntities(entityFilterBox.Text);
|
||||
}
|
||||
|
||||
@@ -4274,9 +4329,9 @@ namespace Barotrauma
|
||||
{
|
||||
if (dummyCharacter == null) { return; }
|
||||
//nothing to close -> return
|
||||
if (DraggedItemPrefab == null && dummyCharacter?.SelectedConstruction == null && OpenedItem == null) { return; }
|
||||
if (DraggedItemPrefab == null && dummyCharacter?.SelectedItem == null && OpenedItem == null) { return; }
|
||||
DraggedItemPrefab = null;
|
||||
dummyCharacter.SelectedConstruction = null;
|
||||
dummyCharacter.SelectedItem = null;
|
||||
OpenedItem?.Drop(dummyCharacter);
|
||||
OpenedItem?.SetTransform(oldItemPosition, 0f);
|
||||
OpenedItem = null;
|
||||
@@ -4353,9 +4408,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (dummyCharacter?.SelectedConstruction != null)
|
||||
if (dummyCharacter?.SelectedItem != null)
|
||||
{
|
||||
var inv = dummyCharacter?.SelectedConstruction?.OwnInventory;
|
||||
var inv = dummyCharacter?.SelectedItem?.OwnInventory;
|
||||
if (inv != null)
|
||||
{
|
||||
switch (obj)
|
||||
@@ -4785,9 +4840,9 @@ namespace Barotrauma
|
||||
if (dummyCharacter != null)
|
||||
{
|
||||
CharacterHUD.AddToGUIUpdateList(dummyCharacter);
|
||||
if (dummyCharacter.SelectedConstruction != null)
|
||||
if (dummyCharacter.SelectedItem != null)
|
||||
{
|
||||
dummyCharacter.SelectedConstruction.AddToGUIUpdateList();
|
||||
dummyCharacter.SelectedItem.AddToGUIUpdateList();
|
||||
}
|
||||
else if (WiringMode && MapEntity.SelectedList.FirstOrDefault() is Item item && item.GetComponent<Wire>() != null)
|
||||
{
|
||||
@@ -5014,6 +5069,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;
|
||||
@@ -5149,7 +5208,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (dummyCharacter != null)
|
||||
{
|
||||
if (dummyCharacter.SelectedConstruction == null)
|
||||
if (dummyCharacter.SelectedItem == null)
|
||||
{
|
||||
foreach (var entity in MapEntity.mapEntityList)
|
||||
{
|
||||
@@ -5193,6 +5252,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (toggleEntityListBind != GameSettings.CurrentConfig.KeyMap.Bindings[InputType.ToggleInventory])
|
||||
{
|
||||
toggleEntityMenuButton.ToolTip = RichString.Rich($"{TextManager.Get("EntityMenuToggleTooltip")}\n‖color:125,125,125‖{GameSettings.CurrentConfig.KeyMap.Bindings[InputType.ToggleInventory].Name}‖color:end‖");
|
||||
toggleEntityListBind = GameSettings.CurrentConfig.KeyMap.Bindings[InputType.ToggleInventory];
|
||||
}
|
||||
if (GameSettings.CurrentConfig.KeyMap.Bindings[InputType.ToggleInventory].IsHit() && mode == Mode.Default)
|
||||
{
|
||||
toggleEntityMenuButton.OnClicked?.Invoke(toggleEntityMenuButton, toggleEntityMenuButton.UserData);
|
||||
@@ -5291,7 +5355,7 @@ namespace Barotrauma
|
||||
me.IsHighlighted = false;
|
||||
}
|
||||
|
||||
if (dummyCharacter.SelectedConstruction == null)
|
||||
if (dummyCharacter.SelectedItem == null)
|
||||
{
|
||||
List<Wire> wires = new List<Wire>();
|
||||
foreach (Item item in Item.ItemList)
|
||||
@@ -5314,8 +5378,8 @@ namespace Barotrauma
|
||||
});
|
||||
}
|
||||
|
||||
if (dummyCharacter.SelectedConstruction == null ||
|
||||
dummyCharacter.SelectedConstruction.GetComponent<Pickable>() != null)
|
||||
if (dummyCharacter.SelectedItem == null ||
|
||||
dummyCharacter.SelectedItem.GetComponent<Pickable>() != null)
|
||||
{
|
||||
if (WiringMode && PlayerInput.IsShiftDown())
|
||||
{
|
||||
@@ -5347,7 +5411,7 @@ namespace Barotrauma
|
||||
TeleportDummyCharacter(oldItemPosition);
|
||||
}
|
||||
|
||||
if (WiringMode && dummyCharacter?.SelectedConstruction == null)
|
||||
if (WiringMode && dummyCharacter?.SelectedItem == null)
|
||||
{
|
||||
TeleportDummyCharacter(FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition));
|
||||
}
|
||||
@@ -5364,7 +5428,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
// Deposit item from our "infinite stack" into inventory slots
|
||||
var inv = dummyCharacter?.SelectedConstruction?.OwnInventory;
|
||||
var inv = dummyCharacter?.SelectedItem?.OwnInventory;
|
||||
if (inv?.visualSlots != null && !PlayerInput.IsCtrlDown())
|
||||
{
|
||||
var dragginMouse = MouseDragStart != Vector2.Zero && Vector2.Distance(PlayerInput.MousePosition, MouseDragStart) >= GUI.Scale * 20;
|
||||
@@ -5529,8 +5593,10 @@ namespace Barotrauma
|
||||
MouseDragStart = Vector2.Zero;
|
||||
}
|
||||
|
||||
if (!saveAssemblyFrame.Rect.Contains(PlayerInput.MousePosition) && !snapToGridFrame.Rect.Contains(PlayerInput.MousePosition) &&
|
||||
dummyCharacter?.SelectedConstruction == null && !WiringMode && GUI.MouseOn == null)
|
||||
if (!saveAssemblyFrame.Rect.Contains(PlayerInput.MousePosition)
|
||||
&& !snapToGridFrame.Rect.Contains(PlayerInput.MousePosition)
|
||||
&& dummyCharacter?.SelectedItem == null && !WiringMode
|
||||
&& (GUI.MouseOn == null || MapEntity.SelectedAny || MapEntity.SelectionPos != Vector2.Zero))
|
||||
{
|
||||
if (layerList is { Visible: true } && GUI.KeyboardDispatcher.Subscriber == layerList)
|
||||
{
|
||||
@@ -5555,9 +5621,9 @@ namespace Barotrauma
|
||||
|
||||
if (!WiringMode)
|
||||
{
|
||||
bool shouldCloseHud = dummyCharacter?.SelectedConstruction != null && HUD.CloseHUD(dummyCharacter.SelectedConstruction.Rect) && DraggedItemPrefab == null;
|
||||
bool shouldCloseHud = dummyCharacter?.SelectedItem != null && HUD.CloseHUD(dummyCharacter.SelectedItem.Rect) && DraggedItemPrefab == null;
|
||||
|
||||
if (MapEntityPrefab.Selected != null && GUI.MouseOn == null)
|
||||
if (MapEntityPrefab.Selected != null)
|
||||
{
|
||||
MapEntityPrefab.Selected.UpdatePlacing(cam);
|
||||
}
|
||||
@@ -5571,7 +5637,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dummyCharacter?.SelectedConstruction == null)
|
||||
if (dummyCharacter?.SelectedItem == null)
|
||||
{
|
||||
CreateContextMenu();
|
||||
}
|
||||
@@ -5628,11 +5694,11 @@ namespace Barotrauma
|
||||
wire?.Update((float)deltaTime, cam);
|
||||
}
|
||||
|
||||
if (dummyCharacter.SelectedConstruction != null)
|
||||
if (dummyCharacter.SelectedItem != null)
|
||||
{
|
||||
if (MapEntity.SelectedList.Contains(dummyCharacter.SelectedConstruction) || WiringMode)
|
||||
if (MapEntity.SelectedList.Contains(dummyCharacter.SelectedItem) || WiringMode)
|
||||
{
|
||||
dummyCharacter.SelectedConstruction?.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
|
||||
dummyCharacter.SelectedItem?.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5709,7 +5775,7 @@ namespace Barotrauma
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, transformMatrix: cam.Transform);
|
||||
Submarine.DrawFront(spriteBatch, editing: true, e => !IsSubcategoryHidden(e.Prefab?.Subcategory));
|
||||
if (!WiringMode && !IsMouseOnEditorGUI())
|
||||
if (!WiringMode)
|
||||
{
|
||||
MapEntityPrefab.Selected?.DrawPlacing(spriteBatch, cam);
|
||||
MapEntity.DrawSelecting(spriteBatch, cam);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Items.Components;
|
||||
@@ -14,18 +13,14 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
*/
|
||||
namespace Barotrauma
|
||||
{
|
||||
class TestScreen : EditorScreen
|
||||
internal sealed class TestScreen : EditorScreen
|
||||
{
|
||||
public override Camera Cam { get; }
|
||||
|
||||
private Item? miniMapItem;
|
||||
|
||||
private Submarine? submarine;
|
||||
public static Character? dummyCharacter;
|
||||
public static Effect? BlueprintEffect;
|
||||
private GUIFrame? container;
|
||||
|
||||
private TabMenu? tabMenu;
|
||||
|
||||
public TestScreen()
|
||||
{
|
||||
@@ -43,14 +38,11 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
container = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "InnerGlow", color: Color.Black);
|
||||
var tab = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform), color: Color.Black * 0.9f);
|
||||
if (dummyCharacter is { Removed: false })
|
||||
{
|
||||
dummyCharacter?.Remove();
|
||||
@@ -61,30 +53,50 @@ namespace Barotrauma
|
||||
dummyCharacter.Info.Name = "Galldren";
|
||||
dummyCharacter.Inventory.CreateSlots();
|
||||
|
||||
miniMapItem = new Item(ItemPrefab.Find(null, "deconstructor".ToIdentifier()), Vector2.Zero, null, 1337, false);
|
||||
|
||||
foreach (ItemComponent component in miniMapItem.Components)
|
||||
{
|
||||
component.OnItemLoaded();
|
||||
}
|
||||
Character.Controlled = dummyCharacter;
|
||||
GameMain.World.ProcessChanges();
|
||||
tabMenu = new TabMenu();
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
Frame.AddToGUIUpdateList();
|
||||
container?.AddToGUIUpdateList();
|
||||
tabMenu?.AddToGUIUpdateList();
|
||||
// CharacterHUD.AddToGUIUpdateList(dummyCharacter);
|
||||
// dummyCharacter?.SelectedConstruction?.AddToGUIUpdateList();
|
||||
CharacterHUD.AddToGUIUpdateList(dummyCharacter);
|
||||
dummyCharacter?.SelectedItem?.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
|
||||
if (dummyCharacter is { } dummy)
|
||||
if (dummyCharacter is { } dummy && miniMapItem is { } item)
|
||||
{
|
||||
if (dummy.SelectedItem != item)
|
||||
{
|
||||
dummy.SelectedItem = item;
|
||||
}
|
||||
|
||||
dummy.SelectedItem?.UpdateHUD(Cam, dummy, (float)deltaTime);
|
||||
Vector2 pos = FarseerPhysics.ConvertUnits.ToSimUnits(item.Position);
|
||||
|
||||
foreach (Limb limb in dummy.AnimController.Limbs)
|
||||
{
|
||||
limb.body.SetTransform(pos, 0.0f);
|
||||
}
|
||||
|
||||
if (dummy.AnimController?.Collider is { } collider)
|
||||
{
|
||||
collider.SetTransform(pos, 0);
|
||||
}
|
||||
|
||||
dummy.ControlLocalPlayer((float)deltaTime, Cam, false);
|
||||
dummy.Control((float)deltaTime, Cam);
|
||||
}
|
||||
tabMenu?.Update((float)deltaTime);
|
||||
}
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
@@ -93,12 +105,13 @@ namespace Barotrauma
|
||||
graphics.Clear(BackgroundColor);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, transformMatrix: Cam.Transform);
|
||||
// miniMapItem?.Draw(spriteBatch, false);
|
||||
// if (dummyCharacter is { } dummy)
|
||||
// {
|
||||
// dummyCharacter.DrawFront(spriteBatch, Cam);
|
||||
// dummyCharacter.Draw(spriteBatch, Cam);
|
||||
// }
|
||||
miniMapItem?.Draw(spriteBatch, false);
|
||||
if (dummyCharacter is { } dummy)
|
||||
{
|
||||
dummyCharacter.DrawFront(spriteBatch, Cam);
|
||||
dummyCharacter.Draw(spriteBatch, Cam);
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState);
|
||||
|
||||
Reference in New Issue
Block a user