Campaign saving fixes
This commit is contained in:
@@ -214,7 +214,6 @@
|
||||
<Compile Include="Source\Sprite\Sprite.cs" />
|
||||
<Compile Include="Source\Sprite\SpriteSheet.cs" />
|
||||
<Compile Include="Source\Utils\MathUtils.cs" />
|
||||
<Compile Include="Source\Utils\SaveUtil.cs" />
|
||||
<Compile Include="Source\Utils\TextureLoader.cs" />
|
||||
<Compile Include="Source\Utils\ToolBox.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (button.UserData as string == "save")
|
||||
{
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SaveFile);
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
|
||||
}
|
||||
|
||||
if (GameMain.NetworkMember != null)
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Barotrauma
|
||||
|
||||
if (!savedOnStart)
|
||||
{
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SaveFile);
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
|
||||
savedOnStart = true;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace Barotrauma
|
||||
Map.MoveToNextLocation();
|
||||
}
|
||||
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SaveFile);
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Barotrauma
|
||||
{
|
||||
Submarine.Unload();
|
||||
|
||||
SaveUtil.LoadGame(saveFile);
|
||||
SaveUtil.LoadGame(savePath);
|
||||
|
||||
GameMain.LobbyScreen.Select();
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
StartNewGame?.Invoke(selectedSub, saveNameBox.Text, seedBox.Text);
|
||||
string savePath = SaveUtil.CreateSavePath(isMultiplayer ? SaveUtil.SaveType.Multiplayer : SaveUtil.SaveType.Singleplayer, saveNameBox.Text);
|
||||
StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text);
|
||||
|
||||
return true;
|
||||
};
|
||||
@@ -81,7 +82,8 @@ namespace Barotrauma
|
||||
|
||||
public void CreateDefaultSaveName()
|
||||
{
|
||||
saveNameBox.Text = SaveUtil.CreateSavePath();
|
||||
string savePath = SaveUtil.CreateSavePath(isMultiplayer ? SaveUtil.SaveType.Multiplayer : SaveUtil.SaveType.Singleplayer);
|
||||
saveNameBox.Text = Path.GetFileNameWithoutExtension(savePath);
|
||||
}
|
||||
|
||||
public void UpdateSubList()
|
||||
|
||||
@@ -76,13 +76,11 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
locationTitle.Text = "Location: " + campaign.Map.CurrentLocation.Name;
|
||||
|
||||
if (campaignUI == null)
|
||||
{
|
||||
campaignUI = new CampaignUI(campaign, bottomPanel);
|
||||
campaignUI.StartRound = StartRound;
|
||||
campaignUI.OnLocationSelected = SelectLocation;
|
||||
}
|
||||
|
||||
bottomPanel.ClearChildren();
|
||||
campaignUI = new CampaignUI(campaign, bottomPanel);
|
||||
campaignUI.StartRound = StartRound;
|
||||
campaignUI.OnLocationSelected = SelectLocation;
|
||||
campaignUI.UpdateCharacterLists();
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Barotrauma
|
||||
Map.MoveToNextLocation();
|
||||
}
|
||||
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SaveFile);
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Barotrauma
|
||||
//two locations used as the start and end in the MP mode
|
||||
private Location[] dummyLocations;
|
||||
|
||||
private string saveFile;
|
||||
private string savePath;
|
||||
|
||||
private Submarine submarine;
|
||||
|
||||
@@ -76,12 +76,12 @@ namespace Barotrauma
|
||||
set { submarine = value; }
|
||||
}
|
||||
|
||||
public string SaveFile
|
||||
public string SavePath
|
||||
{
|
||||
get { return saveFile; }
|
||||
get { return savePath; }
|
||||
}
|
||||
|
||||
public GameSession(Submarine submarine, string saveFile, GameModePreset gameModePreset = null, string missionType = "")
|
||||
public GameSession(Submarine submarine, string savePath, GameModePreset gameModePreset = null, string missionType = "")
|
||||
{
|
||||
Submarine.MainSub = submarine;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Barotrauma
|
||||
|
||||
EventManager = new EventManager(this);
|
||||
|
||||
this.saveFile = saveFile;
|
||||
this.savePath = savePath;
|
||||
|
||||
#if CLIENT
|
||||
CrewManager = new CrewManager();
|
||||
|
||||
@@ -114,6 +114,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetSavePath(SaveType saveType, string saveName)
|
||||
{
|
||||
|
||||
string folder = saveType == SaveType.Singleplayer ? SaveFolder : MultiplayerSaveFolder;
|
||||
return Path.Combine(folder, saveName);
|
||||
}
|
||||
|
||||
public static string[] GetSaveFiles(SaveType saveType)
|
||||
{
|
||||
string folder = saveType == SaveType.Singleplayer ? SaveFolder : MultiplayerSaveFolder;
|
||||
@@ -140,17 +147,24 @@ namespace Barotrauma
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
public static string CreateSavePath(string fileName = "Save")
|
||||
|
||||
public static string CreateSavePath(SaveType saveType, string fileName = "Save")
|
||||
{
|
||||
string folder = saveType == SaveType.Singleplayer ? SaveFolder : MultiplayerSaveFolder;
|
||||
|
||||
if (!Directory.Exists(SaveFolder))
|
||||
{
|
||||
DebugConsole.ThrowError("Save folder \"" + SaveFolder + "\" not found. Created new folder");
|
||||
Directory.CreateDirectory(SaveFolder);
|
||||
DebugConsole.ThrowError("Save folder \"" + folder + "\" not found. Created new folder");
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
|
||||
string extension = ".save";
|
||||
string pathWithoutExtension = Path.Combine(SaveFolder, fileName);
|
||||
string pathWithoutExtension = Path.Combine(folder, fileName);
|
||||
|
||||
if (!File.Exists(pathWithoutExtension + extension))
|
||||
{
|
||||
return pathWithoutExtension + extension;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(pathWithoutExtension + " " + i + extension))
|
||||
@@ -158,7 +172,7 @@ namespace Barotrauma
|
||||
i++;
|
||||
}
|
||||
|
||||
return pathWithoutExtension + " " + i;
|
||||
return pathWithoutExtension + " " + i + extension;
|
||||
}
|
||||
|
||||
public static void CompressStringToFile(string fileName, string value)
|
||||
|
||||
Reference in New Issue
Block a user