Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into unstable
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user