WIP dockingport/multisub saving in single player mode

This commit is contained in:
Regalis
2016-07-02 14:59:49 +03:00
parent 17197a442d
commit cafeceb6d2
8 changed files with 402 additions and 200 deletions

View File

@@ -53,7 +53,7 @@ namespace Barotrauma
endShiftButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 220, 20, 200, 25), "End shift", Alignment.TopLeft, GUI.Style);
endShiftButton.Font = GUI.SmallFont;
endShiftButton.OnClicked = EndShift;
endShiftButton.OnClicked = TryEndShift;
for (int i = 0; i < 3; i++)
{
@@ -236,6 +236,39 @@ namespace Barotrauma
Submarine.Unload();
}
private bool TryEndShift(GUIButton button, object obj)
{
int subsNotDocked = Submarine.Loaded.Count(s => s != Submarine.MainSub && !s.DockedTo.Contains(Submarine.MainSub));
if (subsNotDocked > 0)
{
string msg = "";
if (subsNotDocked == 1)
{
msg = "One of of your vessels hasn't been docked to " + Submarine.MainSub.Name
+ ". If you leave now, you will permanently lose it."
+ " Do you want to leave the vessel behind?";
}
else
{
msg = "Some of of your vessels hasn't been docked to " + Submarine.MainSub.Name
+ ". If you leave now, you will permanently lose them."
+ " Do you want to leave the vessels behind?";
}
var msgBox = new GUIMessageBox("Warning", msg, new string[] {"Yes", "No"});
msgBox.Buttons[0].OnClicked += EndShift;
msgBox.Buttons[0].OnClicked += msgBox.Close;
msgBox.Buttons[1].OnClicked += msgBox.Close;
}
else
{
EndShift(button, obj);
}
return true;
}
private bool EndShift(GUIButton button, object obj)
{
isRunning = false;