@@ -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 {
0 commit comments