Skip to content

Commit be380fb

Browse files
committed
Refactored the Cloud Save status messages
1 parent 8f51403 commit be380fb

File tree

4 files changed

+45
-102
lines changed

4 files changed

+45
-102
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# GameVault App Changelog
22

3+
## 1.16.1
4+
Recommended Gamevault Server Version: `v14.1.0`
5+
### Changes
6+
7+
- Bug fix: Custom Cloud Save config is not applied to 'find' action
8+
- Bug fix: Cloud Save Backup/Restore not working on windows username with space in it
9+
310
## 1.16.0
411
Recommended Gamevault Server Version: `v14.1.0`
512
### Changes

gamevault/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//(used if a resource is not found in the page,
1212
// app, or any theme specific resource dictionaries)
1313
)]
14-
[assembly: AssemblyVersion("1.16.0.0")]
14+
[assembly: AssemblyVersion("1.16.1.0")]
1515
[assembly: AssemblyCopyright("© Phalcode™. All Rights Reserved.")]
1616
#if DEBUG
1717
[assembly: XmlnsDefinition("debug-mode", "Namespace")]

gamevault/Helper/Integrations/SaveGameHelper.cs

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ internal SaveGameHelper()
5555
{
5656
zipHelper = new SevenZipHelper();
5757
}
58-
internal async Task<CloudSaveStatus> RestoreBackup(int gameId, string installationDir)
58+
internal async Task<string> RestoreBackup(int gameId, string installationDir)
5959
{
6060
if (!LoginManager.Instance.IsLoggedIn() || !SettingsViewModel.Instance.License.IsActive())
61-
return CloudSaveStatus.Failed;
61+
return CloudSaveStatus.RestoreFailed;
6262

6363
if (!SettingsViewModel.Instance.CloudSaves)
6464
return CloudSaveStatus.SettingDisabled;
@@ -109,7 +109,7 @@ internal async Task<CloudSaveStatus> RestoreBackup(int gameId, string installati
109109
process.WaitForExit();
110110
ProcessShepherd.Instance.RemoveProcess(process);
111111
Directory.Delete(tempFolder, true);
112-
return CloudSaveStatus.Success;
112+
return CloudSaveStatus.RestoreSuccess;
113113
}
114114
else
115115
{
@@ -122,15 +122,15 @@ internal async Task<CloudSaveStatus> RestoreBackup(int gameId, string installati
122122
string statusCode = WebExceptionHelper.GetServerStatusCode(ex);
123123
if (statusCode == "405")
124124
{
125-
MainWindowViewModel.Instance.AppBarText = "Cloud Saves are not enabled on this Server.";
125+
MainWindowViewModel.Instance.AppBarText = CloudSaveStatus.ServerSettingDisabled;
126126
}
127127
else if (statusCode != "404")
128128
{
129-
MainWindowViewModel.Instance.AppBarText = "Failed to restore cloud save";
129+
MainWindowViewModel.Instance.AppBarText = CloudSaveStatus.RestoreFailed;
130130
}
131131
}
132132
}
133-
return CloudSaveStatus.Failed;
133+
return CloudSaveStatus.RestoreFailed;
134134
}
135135
private string GetGameInstallationId(string installationDir)
136136
{
@@ -148,46 +148,25 @@ internal async Task BackupSaveGamesFromIds(List<int> gameIds)
148148
var removedIds = runningGameIds.Except(gameIds).ToList();
149149

150150
foreach (var removedId in removedIds)
151-
{
151+
{
152152
if (!SettingsViewModel.Instance.CloudSaves || !SettingsViewModel.Instance.License.IsActive())
153153
{
154154
break;
155155
}
156156
if (!LoginManager.Instance.IsLoggedIn())
157157
{
158-
MainWindowViewModel.Instance.AppBarText = "Can not synchronize the cloud saves, because you are offline";
158+
MainWindowViewModel.Instance.AppBarText = CloudSaveStatus.Offline;
159159
break;
160160
}
161161
try
162162
{
163163
MainWindowViewModel.Instance.AppBarText = "Uploading Savegame to the Server...";
164-
CloudSaveStatus status = await BackupSaveGame(removedId);
165-
switch (status)
166-
{
167-
case CloudSaveStatus.Success:
168-
{
169-
MainWindowViewModel.Instance.AppBarText = "Successfully synchronized the cloud saves";
170-
break;
171-
}
172-
case CloudSaveStatus.BackupCreationFailed:
173-
{
174-
MainWindowViewModel.Instance.AppBarText = "Failed to create a copy of your Savegame";
175-
break;
176-
}
177-
case CloudSaveStatus.BackupUploadFailed:
178-
{
179-
MainWindowViewModel.Instance.AppBarText = "Failed to upload your Savegame to the Server";
180-
break;
181-
}
182-
case CloudSaveStatus.Failed:
183-
{
184-
MainWindowViewModel.Instance.AppBarText = "Something went wrong during the Backup";
185-
break;
186-
}
187-
}
164+
string status = await BackupSaveGame(removedId);
165+
MainWindowViewModel.Instance.AppBarText = status;
188166
}
189167
catch (Exception ex)
190168
{
169+
MainWindowViewModel.Instance.AppBarText = CloudSaveStatus.BackupFailed;
191170
}
192171
}
193172

@@ -198,13 +177,13 @@ internal async Task BackupSaveGamesFromIds(List<int> gameIds)
198177
// Remove IDs that are no longer in the new list
199178
runningGameIds = runningGameIds.Intersect(gameIds).ToList();
200179
}
201-
internal async Task<CloudSaveStatus> BackupSaveGame(int gameId)
180+
internal async Task<string> BackupSaveGame(int gameId)
202181
{
203182
if (!SettingsViewModel.Instance.CloudSaves)
204183
return CloudSaveStatus.SettingDisabled;
205184

206185
if (!SettingsViewModel.Instance.License.IsActive())
207-
return CloudSaveStatus.Failed;
186+
return CloudSaveStatus.BackupFailed;
208187

209188
var installedGame = InstallViewModel.Instance?.InstalledGames?.FirstOrDefault(g => g.Key?.ID == gameId);
210189
string gameMetadataTitle = installedGame?.Key?.Metadata?.Title ?? "";
@@ -214,7 +193,7 @@ internal async Task<CloudSaveStatus> BackupSaveGame(int gameId)
214193
PrepareConfigFile(installedGame?.Value!, Path.Combine(AppFilePath.CloudSaveConfigDir, "config.yaml"));
215194
string title = await SearchForLudusaviGameTitle(gameMetadataTitle);
216195
if (string.IsNullOrEmpty(title))
217-
return CloudSaveStatus.Failed;
196+
return CloudSaveStatus.BackupFailed;
218197

219198
string tempFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
220199
Directory.CreateDirectory(tempFolder);
@@ -229,9 +208,9 @@ internal async Task<CloudSaveStatus> BackupSaveGame(int gameId)
229208

230209
bool success = await UploadSavegame(archive, gameId, installationDir);
231210
Directory.Delete(tempFolder, true);
232-
return success ? CloudSaveStatus.Success : CloudSaveStatus.BackupUploadFailed;
211+
return success ? CloudSaveStatus.BackupSuccess : CloudSaveStatus.BackupUploadFailed;
233212
}
234-
return CloudSaveStatus.Failed;
213+
return CloudSaveStatus.BackupFailed;
235214
}
236215
public void PrepareConfigFile(string installationPath, string yamlPath)
237216
{
@@ -402,14 +381,20 @@ private ProcessStartInfo CreateProcessHeader(bool redirectConsole = false)
402381
return info;
403382
}
404383
}
405-
public enum CloudSaveStatus
384+
public struct CloudSaveStatus
406385
{
407-
Success,
408-
Failed,
409-
UpToDate,
410-
SettingDisabled,
411-
BackupCreationFailed,
412-
BackupUploadFailed
386+
public static string BackupSuccess = "Successfully synchronized the cloud saves";
387+
public static string BackupFailed = "Something went wrong during the Backup";
388+
public static string BackupCreationFailed = "Failed to create a copy of your Savegame";
389+
public static string BackupUploadFailed = "Failed to upload your Savegame to the Server";
390+
391+
public static string RestoreSuccess = "Successfully synchronized the cloud save";
392+
public static string RestoreFailed = "Failed to restore the Savegame";
393+
public static string UpToDate = "Your Savegame is up to date";
394+
395+
public static string SettingDisabled = "Activate Cloud Saves under Settings -> GameVault+ -> Cloud Saves";
396+
public static string ServerSettingDisabled = "Cloud Saves are not enabled on this Server";
397+
public static string Offline = "Can not synchronize the cloud saves, because you are offline";
413398
}
414399
public class LudusaviManifestEntry
415400
{

gamevault/UserControls/GameViewUserControl.xaml.cs

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ private void Share_Click(object sender, RoutedEventArgs e)
407407
private async void BackupCloudSaves_Click(object sender, RoutedEventArgs e)
408408
{
409409
try
410-
{
410+
{
411411
if (!SettingsViewModel.Instance.License.IsActive())
412412
{
413413
MainWindowViewModel.Instance.SetActiveControl(MainControl.Settings);
@@ -416,44 +416,17 @@ private async void BackupCloudSaves_Click(object sender, RoutedEventArgs e)
416416
}
417417
if (!LoginManager.Instance.IsLoggedIn())
418418
{
419-
MainWindowViewModel.Instance.AppBarText = "Can not synchronize the cloud saves, because you are offline";
419+
MainWindowViewModel.Instance.AppBarText = CloudSaveStatus.Offline;
420420
return;
421421
}
422422
MainWindowViewModel.Instance.AppBarText = "Uploading Savegame to the Server...";
423423
((FrameworkElement)sender).IsEnabled = false;
424-
CloudSaveStatus status = await SaveGameHelper.Instance.BackupSaveGame(ViewModel!.Game!.ID);
425-
switch (status)
426-
{
427-
case CloudSaveStatus.Success:
428-
{
429-
MainWindowViewModel.Instance.AppBarText = "Successfully synchronized the cloud saves";
430-
break;
431-
}
432-
case CloudSaveStatus.BackupCreationFailed:
433-
{
434-
MainWindowViewModel.Instance.AppBarText = "Failed to get your Savegame";
435-
break;
436-
}
437-
case CloudSaveStatus.BackupUploadFailed:
438-
{
439-
MainWindowViewModel.Instance.AppBarText = "Failed to upload your Savegame to the Server";
440-
break;
441-
}
442-
case CloudSaveStatus.SettingDisabled:
443-
{
444-
MainWindowViewModel.Instance.AppBarText = "Activate Cloud Saves under Settings -> GameVault+ -> Cloud Saves";
445-
break;
446-
}
447-
case CloudSaveStatus.Failed:
448-
{
449-
MainWindowViewModel.Instance.AppBarText = "Something went wrong during the backup";
450-
break;
451-
}
452-
}
424+
string status = await SaveGameHelper.Instance.BackupSaveGame(ViewModel!.Game!.ID);
425+
MainWindowViewModel.Instance.AppBarText = status;
453426
}
454427
catch
455428
{
456-
MainWindowViewModel.Instance.AppBarText = "Failed to Upload your Savegame to the Server";
429+
MainWindowViewModel.Instance.AppBarText = CloudSaveStatus.BackupFailed;
457430
}
458431
((FrameworkElement)sender).IsEnabled = true;
459432
}
@@ -470,34 +443,12 @@ private async void RestoreCloudSaves_Click(object sender, RoutedEventArgs e)
470443
MainWindowViewModel.Instance.AppBarText = $"Syncing cloud save...";
471444
((FrameworkElement)sender).IsEnabled = false;
472445
string installationDir = InstallViewModel.Instance.InstalledGames.First(g => g.Key.ID == ViewModel!.Game!.ID).Value;
473-
CloudSaveStatus status = await SaveGameHelper.Instance.RestoreBackup(ViewModel!.Game!.ID, installationDir);
474-
switch (status)
475-
{
476-
case CloudSaveStatus.Success:
477-
{
478-
MainWindowViewModel.Instance.AppBarText = "Successfully synchronized the cloud save";
479-
break;
480-
}
481-
case CloudSaveStatus.UpToDate:
482-
{
483-
MainWindowViewModel.Instance.AppBarText = "Your Savegame is up to date";
484-
break;
485-
}
486-
case CloudSaveStatus.SettingDisabled:
487-
{
488-
MainWindowViewModel.Instance.AppBarText = "Activate Cloud Saves under Settings -> GameVault+ -> Cloud Saves";
489-
break;
490-
}
491-
case CloudSaveStatus.Failed:
492-
{
493-
MainWindowViewModel.Instance.AppBarText = "Failed to restore the Savegame";
494-
break;
495-
}
496-
}
446+
string status = await SaveGameHelper.Instance.RestoreBackup(ViewModel!.Game!.ID, installationDir);
447+
MainWindowViewModel.Instance.AppBarText = status;
497448
}
498449
catch
499450
{
500-
MainWindowViewModel.Instance.AppBarText = "Failed to restore the Savegame";
451+
MainWindowViewModel.Instance.AppBarText = CloudSaveStatus.RestoreFailed;
501452
}
502453
((FrameworkElement)sender).IsEnabled = true;
503454
}

0 commit comments

Comments
 (0)