/// <summary> /// Exports the save slot from the specified path /// </summary> /// <returns>The task</returns> public async Task ExportAsync() { // Get the output file var outputResult = await Services.BrowseUI.SaveFileAsync(new SaveFileViewModel() { Title = Resources.ExportDestinationSelectionHeader, DefaultName = SaveSlotFilePath.ChangeFileExtension(new FileExtension(".json")).Name, Extensions = new FileFilterItem("*.json", Resources.FileFilterDescription_JSON).StringRepresentation }); if (outputResult.CanceledByUser) { return; } RL.Logger?.LogInformationSource($"Progression data for slot {SlotName} is being exported..."); try { // Export await ExportSaveDataAsync(outputResult.SelectedFileLocation); RL.Logger?.LogInformationSource($"Progression data has been exported"); await Services.MessageUI.DisplaySuccessfulActionMessageAsync(Resources.Progression_ExportSuccess); } catch (Exception ex) { ex.HandleError("Exporting progression slot to JSON"); await Services.MessageUI.DisplayExceptionMessageAsync(ex, Resources.Progression_ExportError); } }
/// <summary> /// Imports an exported save slot to the save slot /// </summary> /// <returns>The task</returns> public async Task ImportAsync() { // Get the input file var inputResult = await Services.BrowseUI.BrowseFileAsync(new FileBrowserViewModel() { Title = Resources.ImportSelectionHeader, ExtensionFilter = new FileFilterItem("*.json", Resources.FileFilterDescription_JSON).StringRepresentation, DefaultName = SaveSlotFilePath.ChangeFileExtension(new FileExtension(".json")).Name }); if (inputResult.CanceledByUser) { return; } RL.Logger?.LogInformationSource($"Progression data for slot {SlotName} is being imported..."); try { // Import await ImportSaveDataAsync(inputResult.SelectedFile); RL.Logger?.LogInformationSource($"Progression data has been imported"); } catch (Exception ex) { ex.HandleError("Importing JSON to progression slot file"); await Services.MessageUI.DisplayExceptionMessageAsync(ex, Resources.Progression_ImportError); return; } try { // Reload data await ProgressionViewModel.LoadDataAsync(); RL.Logger?.LogInformationSource($"Progression data has been reloaded"); } catch (Exception ex) { ex.HandleError("Reload game progression view model"); } await Services.MessageUI.DisplaySuccessfulActionMessageAsync(Resources.Progression_ImportSuccess); }