Skip to content

Commit

Permalink
Merge pull request #10 from elpatron68/next-version-from-1.0.5.1
Browse files Browse the repository at this point in the history
Next version from 1.0.5.1
  • Loading branch information
elpatron68 authored Oct 23, 2022
2 parents 0524d14 + 07b5cda commit 3983f20
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SnowRunner-Tool Changes

## v1.0.5.2 ()
- Delete files using system´s recycle bin
- Copy a save game slot to another (empty) one

## v1.0.5.1 (16.10.2022)
- Fixed a bug which deleted backup files while moving old backups to new location at the first start of v1.0.5.0
- Fixed a bug preventing the tool to start if Steam client is not installed
Expand Down
12 changes: 12 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ or all slots)
- Rename backup files from the UI
- Cheat the amount of money you have in your pocket
- Cheat your experience points (XP)
- Copy one save game to another

![SnowRunner-Tool](images/SnowRunner-Tool_Screenshot.png)

## Installation
Expand Down Expand Up @@ -69,6 +71,16 @@ After the start, *SnowRunner-Tool* discovers if you own the Steam- or Epic Games
2. Hit the function key `F2` for an instant backup while you play the game without leaving the game.
3. Let the tool create *regular backups* in the background while playing the game.

### Copy a save game slot to another

Copying a save game slot to another one may be useful. E.g. I use it if I want to play my single player fleet in a multiplayer game hosted by a friend.

To copy a save game slot to another, open the *File* menu and select *Copy save game*. Select a game slot as source and navigate to the submenu of the destination slot you want it to be copied to:

![Copy Save Game](images/Copy_save_game.png)

Note, that only existing game slot are selectable as source, and only empty slots as destination. If all destination slots are greyed out, use the game´s own function to delete a save game slot prior to copying.

#### Notes

- **Backups can usually be created while the game is running**. If you have to master a risky maneuver, just switch to your *SnowRunner-Tool* and make a backup before you fail. Or even easier: Let the tool run in the background and use the instant-hotkey-backup (`F2`).
Expand Down
63 changes: 62 additions & 1 deletion SnowRunner-Tool/CheatGame.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Serilog;
using ControlzEx.Standard;
using Serilog;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -181,5 +182,65 @@ public static string UnzipToTemp(string zipFile, string platform)
}
return returnPath;
}

/// <summary>
/// Copy a save game slot to another. Slots are 1-based integer.
/// </summary>
/// <param name="slot1"></param>
/// <param name="slot2"></param>
/// <param name="SRProfile"></param>
public static bool CopySlotToOtherSlot(int slot1, int slot2, string SRProfile, string platform)
{
string sourcefile;
string destinationfile;
string filename;
string oldtext;
string newtext;
string extension;
if (platform == "steam")
{
extension = "cfg";
}
else
{
extension = "dat";
}

if (slot1 > 1)
{
filename = string.Format("CompleteSave{0}.{1}", (slot1 - 1).ToString(), extension);
oldtext = string.Format("CompleteSave{0}", (slot1 - 1).ToString());
}
else
{
filename = string.Format("CompleteSave.{0}", extension);
oldtext = "CompleteSave";
}
sourcefile = Path.Combine(SRProfile, filename);

if (slot2 > 1)
{
filename = string.Format("CompleteSave{0}.{1}", (slot2 - 1).ToString(), extension);
newtext = string.Format("CompleteSave{0}", (slot2 - 1).ToString());
}
else
{
filename = string.Format("CompleteSave.{0}", extension);
newtext = "CompleteSave";
}
destinationfile = Path.Combine(SRProfile, filename);

string text = File.ReadAllText(sourcefile);
text = Regex.Replace(text, oldtext, newtext, RegexOptions.IgnoreCase);
try
{
File.WriteAllText(Path.Combine(SRProfile, destinationfile), text);
return true;
}
catch
{
return false;
}
}
}
}
96 changes: 96 additions & 0 deletions SnowRunner-Tool/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,102 @@
<iconPacks:PackIconMaterial Kind="ContentSaveOutline" />
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame"
Header="_Copy save game"
>
<MenuItem.Icon>
<iconPacks:PackIconMaterial Kind="ContentCopy" />
</MenuItem.Icon>
<MenuItem x:Name="MnCopySaveGame1"
Header="from slot _1"
IsEnabled="False"
>
<MenuItem x:Name="MnCopySaveGame1To2"
Header="to slot _2"
IsEnabled="False"
Click="MnCopySaveGame1To2_Click"
>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame1To3"
Header="to slot _3"
IsEnabled="False"
Click="MnCopySaveGame1To3_Click"
>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame1To4"
Header="to slot _4"
IsEnabled="False"
Click="MnCopySaveGame1To4_Click"
>
</MenuItem>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame2"
Header="from slot _2"
>
<MenuItem x:Name="MnCopySaveGame2To1"
Header="to slot _1"
IsEnabled="False"
Click="MnCopySaveGame2To1_Click"
>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame2To3"
Header="to slot _3"
IsEnabled="False"
Click="MnCopySaveGame2To3_Click"
>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame2To4"
Header="to slot _4"
IsEnabled="False"
Click="MnCopySaveGame2To4_Click"
>
</MenuItem>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame3"
Header="from slot _3"
>
<MenuItem x:Name="MnCopySaveGame3To1"
Header="to slot _1"
IsEnabled="False"
Click="MnCopySaveGame3To1_Click"
>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame3To2"
Header="to slot _2"
IsEnabled="False"
Click="MnCopySaveGame3To2_Click"
>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame3To4"
Header="to slot _4"
IsEnabled="False"
Click="MnCopySaveGame3To4_Click"
>
</MenuItem>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame4"
Header="from slot _4"
>
<MenuItem x:Name="MnCopySaveGame4To1"
Header="to slot _1"
IsEnabled="False"
Click="MnCopySaveGame4To1_Click"
>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame4To2"
Header="to slot _2"
IsEnabled="False"
Click="MnCopySaveGame4To2_Click"
>
</MenuItem>
<MenuItem x:Name="MnCopySaveGame4To3"
Header="to slot _3"
IsEnabled="False"
Click="MnCopySaveGame4To3_Click"
>
</MenuItem>
</MenuItem>
</MenuItem>
<MenuItem x:Name="MnReload"
Header="_Reload backup table"
Click="MnuReload_Click"
Expand Down
111 changes: 108 additions & 3 deletions SnowRunner-Tool/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,22 +235,38 @@ private void UpdateSaveGameSlotMenus()

saveFile = SRProfile + @"\CompleteSave." + SavegameExtension;
saveGameExists = File.Exists(saveFile);
MnMoneyCheat1.IsEnabled = saveGameExists;
MnMoneyCheat1.IsEnabled = saveGameExists;
MnCopySaveGame1.IsEnabled = saveGameExists;
MnCopySaveGame2To1.IsEnabled = !saveGameExists;
MnCopySaveGame3To1.IsEnabled = !saveGameExists;
MnCopySaveGame4To1.IsEnabled = !saveGameExists;
MnXp1.IsEnabled = saveGameExists;

saveFile = SRProfile + @"\CompleteSave1." + SavegameExtension; ;
saveGameExists = File.Exists(saveFile);
MnMoneyCheat2.IsEnabled = saveGameExists;
MnCopySaveGame2.IsEnabled = saveGameExists;
MnCopySaveGame1To2.IsEnabled = !saveGameExists;
MnCopySaveGame3To2.IsEnabled = !saveGameExists;
MnCopySaveGame4To2.IsEnabled = !saveGameExists;
MnXp2.IsEnabled = saveGameExists;

saveFile = SRProfile + @"\CompleteSave2." + SavegameExtension; ;
saveGameExists = File.Exists(saveFile);
MnMoneyCheat3.IsEnabled = saveGameExists;
MnCopySaveGame3.IsEnabled = saveGameExists;
MnCopySaveGame1To3.IsEnabled = !saveGameExists;
MnCopySaveGame2To3.IsEnabled = !saveGameExists;
MnCopySaveGame4To3.IsEnabled = !saveGameExists;
MnXp3.IsEnabled = saveGameExists;

saveFile = SRProfile + @"\CompleteSave3." + SavegameExtension; ;
saveGameExists = File.Exists(saveFile);
MnMoneyCheat4.IsEnabled = saveGameExists;
MnCopySaveGame4.IsEnabled = saveGameExists;
MnCopySaveGame1To4.IsEnabled = !saveGameExists;
MnCopySaveGame2To4.IsEnabled = !saveGameExists;
MnCopySaveGame3To4.IsEnabled = !saveGameExists;
MnXp4.IsEnabled = saveGameExists;
}

Expand Down Expand Up @@ -633,7 +649,7 @@ private void MnDeleteBackup_Click(object sender, RoutedEventArgs e)
string f = MyBackupDir + @"\" + ((Backup)row).BackupName;
try
{
File.Delete(f);
NativeMethods.DeleteFileOrFolder(f);
changedList = true;
}
catch (IOException ex)
Expand Down Expand Up @@ -762,11 +778,11 @@ private void FileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
//Wait a second, just to be sure
Thread.Sleep(1000);
autoSaveCounter += 1;
ReadBackups();
if (autoSaveCounter == Settings.Default.autobackupinterval)
{
autoSaveCounter = 0;
_ = Backup.BackupCurrentSavegame(SRProfile, MyBackupDir, "auto-bak");
ReadBackups();
_logger.Debug("FSW-backup created");
}
}
Expand Down Expand Up @@ -837,5 +853,94 @@ private void MnShowLogFiles_Click(object sender, RoutedEventArgs e)
string logfiledir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\SRT\";
Process.Start("explorer.exe", logfiledir);
}

private void MnCopySaveGame1To2_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(1, 2, SRProfile, Platform);
CopyFinishMessage(1, 2, result);
}

private void MnCopySaveGame1To3_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(1, 3, SRProfile, Platform);
CopyFinishMessage(1, 3, result);
}

private void MnCopySaveGame1To4_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(1, 4, SRProfile, Platform);
CopyFinishMessage(1, 4, result);
}

private void MnCopySaveGame2To1_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(2, 1, SRProfile, Platform);
CopyFinishMessage(2, 1, result);
}

private void MnCopySaveGame2To3_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(2, 3, SRProfile, Platform);
CopyFinishMessage(2, 3, result);
}

private void MnCopySaveGame2To4_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(2, 4, SRProfile, Platform);
CopyFinishMessage(2, 4, result);
}

private void MnCopySaveGame3To1_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(3, 1, SRProfile, Platform);
CopyFinishMessage(3, 1, result);
}

private void MnCopySaveGame3To2_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(3, 2, SRProfile, Platform);
CopyFinishMessage(3, 2, result);
}

private void MnCopySaveGame3To4_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(3, 4, SRProfile, Platform);
CopyFinishMessage(3, 4, result);
}

private void MnCopySaveGame4To1_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(4, 1, SRProfile, Platform);
CopyFinishMessage(4, 1, result);
}

private void MnCopySaveGame4To2_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(4, 2, SRProfile, Platform);
CopyFinishMessage(4, 2, result);
}

private void MnCopySaveGame4To3_Click(object sender, RoutedEventArgs e)
{
bool result = CheatGame.CopySlotToOtherSlot(4, 3, SRProfile, Platform);
CopyFinishMessage(4, 3, result);
}

private void CopyFinishMessage(int slot1, int slot2, bool result)
{
_logger.Information(string.Format("Save game copy: Source: {0}, destination: {1}, result: {2}",
slot1.ToString(), slot2.ToString(), result.ToString()));

if (result)
{
_ = MetroMessage("Save game copied", string.Format("Save game slot {0} has been copied to save game slot {1}.",
slot1.ToString(), slot2.ToString()));
}
else
{
_ = MetroMessage("Save game copy failed", string.Format("Copying save game slot {0} to save game slot {1} failed.",
slot1.ToString(), slot2.ToString()));
}
}
}
}
Loading

0 comments on commit 3983f20

Please sign in to comment.