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