(44694344e) Don't allow deleting vanilla subs in the sub editor
This commit is contained in:
@@ -847,6 +847,20 @@ namespace Barotrauma
|
||||
GameMain.World.ProcessChanges();
|
||||
}
|
||||
|
||||
private bool IsVanillaSub(Submarine sub)
|
||||
{
|
||||
if (sub == null) { return false; }
|
||||
|
||||
var vanilla = GameMain.VanillaContent;
|
||||
if (vanilla != null)
|
||||
{
|
||||
var vanillaSubs = vanilla.GetFilesOfType(ContentType.Submarine);
|
||||
string pathToCompare = sub.FilePath.Replace(@"\", @"/").ToLowerInvariant();
|
||||
return (vanillaSubs.Any(s => s.Replace(@"\", @"/").ToLowerInvariant() == pathToCompare));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool SaveSub(GUIButton button, object obj)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(nameBox.Text))
|
||||
@@ -1328,7 +1342,14 @@ namespace Barotrauma
|
||||
ScrollBarVisible = true,
|
||||
OnSelected = (GUIComponent selected, object userData) =>
|
||||
{
|
||||
if (deleteButtonHolder.FindChild("delete") is GUIButton deleteBtn) deleteBtn.Enabled = true;
|
||||
if (deleteButtonHolder.FindChild("delete") is GUIButton deleteBtn)
|
||||
{
|
||||
#if DEBUG
|
||||
deleteBtn.Enabled = true;
|
||||
#else
|
||||
deleteBtn.Enabled = !IsVanillaSub(userData as Submarine);
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user