(bf037f9b0) Don't allow deleting vanilla subs or subs that are a part of some content package
This commit is contained in:
@@ -416,6 +416,21 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsVanillaSubmarine()
|
||||||
|
{
|
||||||
|
var vanilla = GameMain.VanillaContent;
|
||||||
|
if (vanilla != null)
|
||||||
|
{
|
||||||
|
var vanillaSubs = vanilla.GetFilesOfType(ContentType.Submarine);
|
||||||
|
string pathToCompare = filePath.Replace(@"\", @"/").ToLowerInvariant();
|
||||||
|
if (vanillaSubs.Any(sub => sub.Replace(@"\", @"/").ToLowerInvariant() == pathToCompare))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void CheckForErrors()
|
public void CheckForErrors()
|
||||||
{
|
{
|
||||||
List<string> errorMsgs = new List<string>();
|
List<string> errorMsgs = new List<string>();
|
||||||
|
|||||||
@@ -1278,7 +1278,11 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
OnSelected = (GUIComponent selected, object userData) =>
|
OnSelected = (GUIComponent selected, object userData) =>
|
||||||
{
|
{
|
||||||
if (paddedLoadFrame.FindChild("delete") is GUIButton deleteBtn) deleteBtn.Enabled = true;
|
Submarine sub = userData as Submarine;
|
||||||
|
if (paddedLoadFrame.FindChild("delete") is GUIButton deleteBtn)
|
||||||
|
{
|
||||||
|
deleteBtn.Enabled = !sub.IsVanillaSubmarine();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1397,7 +1401,23 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private void TryDeleteSub(Submarine sub)
|
private void TryDeleteSub(Submarine sub)
|
||||||
{
|
{
|
||||||
if (sub == null) return;
|
if (sub == null) { return; }
|
||||||
|
|
||||||
|
if (sub.IsVanillaSubmarine())
|
||||||
|
{
|
||||||
|
GUI.AddMessage(TextManager.Get("CannotEditVanillaSubs"), Color.Red, font: GUI.LargeFont);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string pathToCompare = sub.FilePath.Replace(@"\", @"/").ToLowerInvariant();
|
||||||
|
foreach (ContentPackage cp in ContentPackage.List)
|
||||||
|
{
|
||||||
|
if (cp.Files.Any(f => f.Path.Replace(@"\", @"/").ToLowerInvariant() == pathToCompare))
|
||||||
|
{
|
||||||
|
new GUIMessageBox("", TextManager.Get("CannotRemoveContentPackageSub").Replace("[contentpackage]", cp.Name));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var msgBox = new GUIMessageBox(
|
var msgBox = new GUIMessageBox(
|
||||||
TextManager.Get("DeleteDialogLabel"),
|
TextManager.Get("DeleteDialogLabel"),
|
||||||
|
|||||||
Reference in New Issue
Block a user