Make AM2R Saves on Flatpak specific to it + transfer them over to not loose them.

pull/45/head
Miepee 3 years ago
parent 8e1fbc14f3
commit fc2a500abd

@ -133,18 +133,39 @@ public partial class MainForm : Form
#region MAIN TAB #region MAIN TAB
/// <summary> /// <summary>
/// After the <see cref="playButton"/> has been loaded, git pull if a repo has been cloned already. /// After the <see cref="playButton"/> has been loaded, git pull if a repo has been cloned already. Also transfer non-flatpak saves to flatpak
/// </summary> /// </summary>
private async void PlayButtonLoadComplete(object sender, EventArgs e) private async void PlayButtonLoadComplete(object sender, EventArgs e)
{ {
//Only pull if Patchdata is cloned and user wants it updated
LoadProfilesAndAdjustLists(); LoadProfilesAndAdjustLists();
// Transfer saves on flatpak from non-flatpak save to flatpak save
if (OS.IsThisRunningFromFlatpak)
{
string oldHomePath = CrossPlatformOperations.Home;
Environment.SetEnvironmentVariable("HOME", $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify)}/AM2RProfileSaves");
string newHomePath = CrossPlatformOperations.Home;
// TEMPORARY transfer from main saves into Flatpak saves - TODO: remove in about half a year or so
// Only do this if the directory for the new saves does not exist yet.
foreach (var profile in profileList)
{
string oldSavePath = profile.SaveLocation.Replace("~", oldHomePath);
string newSavePath = profile.SaveLocation.Replace("~", newHomePath);
if (Directory.Exists(newSavePath)) continue;
log.Info($"Transfering save data for {profile.Name} from {oldSavePath} to {newSavePath} ...");
HelperMethods.DirectoryCopy(oldSavePath, newSavePath);
}
}
//Only pull if Patchdata is cloned and user wants it updated
if (!Profile.IsPatchDataCloned() || !autoUpdateAM2RCheck.Checked.Value) if (!Profile.IsPatchDataCloned() || !autoUpdateAM2RCheck.Checked.Value)
return; return;
SetPlayButtonState(PlayButtonState.Downloading); SetPlayButtonState(PlayButtonState.Downloading);
EnableProgressBarAndLabel(); EnableProgressBarAndLabel();
// Try to pull // Try to pull
try try
{ {

@ -25,7 +25,7 @@ public static class CrossPlatformOperations
/// <summary> /// <summary>
/// Path to the Home Folder. /// Path to the Home Folder.
/// </summary> /// </summary>
public static readonly string Home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); public static string Home => Environment.GetFolderPath(Environment.SpecialFolder.UserProfile, Environment.SpecialFolderOption.Create);
/// <summary> /// <summary>
/// Config file path for *nix based systems. <br/> /// Config file path for *nix based systems. <br/>

Loading…
Cancel
Save