"Are you sure" prompt when trying to delete subs in the editor
This commit is contained in:
@@ -550,23 +550,13 @@ namespace Barotrauma
|
|||||||
deleteButton.UserData = "delete";
|
deleteButton.UserData = "delete";
|
||||||
deleteButton.OnClicked = (btn, userdata) =>
|
deleteButton.OnClicked = (btn, userdata) =>
|
||||||
{
|
{
|
||||||
if (subList.Selected!=null)
|
if (subList.Selected != null)
|
||||||
{
|
{
|
||||||
Submarine sub = subList.Selected.UserData as Submarine;
|
TryDeleteSub(subList.Selected.UserData as Submarine);
|
||||||
try
|
|
||||||
{
|
|
||||||
File.Delete(sub.FilePath);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
DebugConsole.ThrowError("Couldn't delete file \""+sub.FilePath+"\"!", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteButton.Enabled = false;
|
deleteButton.Enabled = false;
|
||||||
|
|
||||||
CreateLoadScreen();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -603,6 +593,29 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TryDeleteSub(Submarine sub)
|
||||||
|
{
|
||||||
|
if (sub == null) return;
|
||||||
|
|
||||||
|
var msgBox = new GUIMessageBox("Delete file?", "Are you sure you want to delete \"" + sub.Name + "\"", new string[] { "OK", "Cancel" });
|
||||||
|
msgBox.Buttons[0].OnClicked += (btn, userData) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sub.Remove();
|
||||||
|
File.Delete(sub.FilePath);
|
||||||
|
CreateLoadScreen();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Couldn't delete file \"" + sub.FilePath + "\"!", e);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
msgBox.Buttons[0].OnClicked += msgBox.Close;
|
||||||
|
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||||
|
}
|
||||||
|
|
||||||
private bool SelectTab(GUIButton button, object obj)
|
private bool SelectTab(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
if (characterMode) ToggleCharacterMode();
|
if (characterMode) ToggleCharacterMode();
|
||||||
|
|||||||
Reference in New Issue
Block a user