- Autorestart works in campaign mode.

- The server select a random destination when the campaign starts and after each round, so the campaign can be played even if there's no host/client to choose the destinations. (TODO: make it possible to vote for the destination?)
- Reverting to the previous save if the entire crew is dead works correctly now.
- Clients load the campaign saves after receiving them (-> discovered locations/connections are synced with clients).
This commit is contained in:
Joonas Rikkonen
2017-09-19 22:05:42 +03:00
parent e26600d088
commit f291a22976
12 changed files with 207 additions and 168 deletions
@@ -156,8 +156,12 @@ namespace Barotrauma
if (spMode != null)
{
button = new GUIButton(new Rectangle(0, y, 0, 30), "Load previous", Alignment.CenterX, "", pauseMenu);
button.OnClicked += TogglePauseMenu;
button.OnClicked += GameMain.GameSession.LoadPrevious;
button.OnClicked += (btn, userData) =>
{
TogglePauseMenu(btn, userData);
GameMain.GameSession.LoadPrevious();
return true;
};
y += 60;
}
@@ -219,8 +219,13 @@ namespace Barotrauma
summaryScreen.RemoveChild(summaryScreen.children.Find(c => c is GUIButton));
var okButton = new GUIButton(new Rectangle(-120, 0, 100, 30), "Load game", Alignment.BottomRight, "", summaryScreen);
okButton.OnClicked += GameMain.GameSession.LoadPrevious;
okButton.OnClicked += (GUIButton button, object obj) => { GUIMessageBox.MessageBoxes.Remove(GUIMessageBox.VisibleBox); return true; };
okButton.OnClicked += (GUIButton button, object obj) =>
{
GameMain.GameSession.LoadPrevious();
GameMain.LobbyScreen.Select();
GUIMessageBox.MessageBoxes.Remove(GUIMessageBox.VisibleBox);
return true;
};
var quitButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Quit", Alignment.BottomRight, "", summaryScreen);
quitButton.OnClicked += GameMain.LobbyScreen.QuitToMainMenu;
@@ -322,7 +327,7 @@ namespace Barotrauma
GameMain.GameSession.CrewManager = new CrewManager(subElement);
break;
case "map":
campaign.map = Map.Load(subElement);
campaign.map = Map.LoadNew(subElement);
break;
}
}
@@ -15,17 +15,6 @@ namespace Barotrauma
get { return roundSummary; }
}
public bool LoadPrevious(GUIButton button, object obj)
{
Submarine.Unload();
SaveUtil.LoadGame(savePath);
GameMain.LobbyScreen.Select();
return true;
}
private bool ToggleInfoFrame(GUIButton button, object obj)
{
if (infoFrame == null)
@@ -11,6 +11,8 @@ namespace Barotrauma
private static Texture2D iceCraters;
private static Texture2D iceCrack;
private Location highlightedLocation;
public void Update(float deltaTime, Rectangle rect, float scale = 1.0f)
{
Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y);
@@ -1118,15 +1118,11 @@ namespace Barotrauma.Networking
if (GameMain.GameSession.Submarine == null)
{
var gameSessionDoc = SaveUtil.LoadGameSessionDoc(GameMain.GameSession.SavePath);
string subPath = Path.Combine(SaveUtil.TempPath, ToolBox.GetAttributeString(gameSessionDoc.Root, "submarine", "")) + ".sub";
string subPath = Path.Combine(SaveUtil.TempPath, ToolBox.GetAttributeString(gameSessionDoc.Root, "submarine", "")) + ".sub";
GameMain.GameSession.Submarine = new Submarine(subPath, "");
}
else
{
SaveUtil.DecompressToDirectory(GameMain.GameSession.SavePath, SaveUtil.TempPath, null);
}
SaveUtil.LoadGame(GameMain.GameSession.SavePath, GameMain.GameSession);
break;
}
}
@@ -201,6 +201,15 @@ namespace Barotrauma.Networking
void FinishUPnP()
{
upnpBox.Close(null, null);
if (server.UPnP.Status == UPnPStatus.NotAvailable)
{
new GUIMessageBox("Error", "UPnP not available");
}
else if (server.UPnP.Status == UPnPStatus.Discovering)
{
new GUIMessageBox("Error", "UPnP discovery timed out");
}
}
public bool StartGameClicked(GUIButton button, object obj)
@@ -1181,6 +1181,10 @@ namespace Barotrauma
var moneyText = new GUITextBlock(new Rectangle(120,0,200,20), "Money", "", Alignment.BottomLeft, Alignment.TopLeft, campaignContainer);
moneyText.TextGetter = campaignUI.GetMoney;
var restartText = new GUITextBlock(new Rectangle(-250, -20, 100, 30), "", "", Alignment.BottomRight, Alignment.BottomLeft, campaignContainer);
restartText.Font = GUI.SmallFont;
restartText.TextGetter = AutoRestartText;
}
modeList.Select(2, true);
}