コード例 #1
0
        /// <summary>
        /// Imports an exported save slot to the save slot from the specified path
        /// </summary>
        /// <param name="inputFilePath">The input file path</param>
        /// <returns>The task</returns>
        protected override Task ImportSaveDataAsync(FileSystemPath inputFilePath)
        {
            // Deserialize the input data
            var data = JsonHelpers.DeserializeFromFile <RaymanMPCSaveData>(inputFilePath);

            // Import the data
            BinarySerializableHelpers.WriteToFile(data, SaveSlotFilePath, OpenSpaceSettings.GetDefaultSettings(OpenSpaceGame.RaymanM, Platform.PC), RCPServices.App.GetBinarySerializerLogger());

            return(Task.CompletedTask);
        }
        /// <summary>
        /// Imports an exported save slot to the save slot from the specified path
        /// </summary>
        /// <param name="inputFilePath">The input file path</param>
        /// <returns>The task</returns>
        protected override Task ImportSaveDataAsync(FileSystemPath inputFilePath)
        {
            // Get the serialized data
            var data = BinarySerializableHelpers.ReadFromFile <JungleRunPCSaveData>(SaveSlotFilePath, UbiArtSettings.GetSaveSettings(UbiArtGame.RaymanJungleRun, Platform.PC), RCPServices.App.GetBinarySerializerLogger());

            // Deserialize the input data
            data.Levels = JsonHelpers.DeserializeFromFile <JungleRunPCSaveDataLevel[]>(inputFilePath);

            // Import the data
            BinarySerializableHelpers.WriteToFile(data, SaveSlotFilePath, UbiArtSettings.GetSaveSettings(UbiArtGame.RaymanJungleRun, Platform.PC), RCPServices.App.GetBinarySerializerLogger());

            return(Task.CompletedTask);
        }
        /// <summary>
        /// Imports a JSON file to a localization file
        /// </summary>
        /// <returns>The task</returns>
        public async Task ImportToLocAsync()
        {
            // Get the input file
            var inputResult = await Services.BrowseUI.BrowseFileAsync(new FileBrowserViewModel()
            {
                Title           = Resources.ImportSelectionHeader,
                ExtensionFilter = new FileFilterItem("*.json", Resources.FileFilterDescription_JSON).StringRepresentation,
                DefaultName     = "localisation.json"
            });

            if (inputResult.CanceledByUser)
            {
                return;
            }

            // Get the localization file
            var outputResult = await Services.BrowseUI.BrowseFileAsync(new FileBrowserViewModel()
            {
                Title           = Resources.UbiArtU_LocalizationConverterImportDestinationSelectionHeader,
                DefaultName     = inputResult.SelectedFile.ChangeFileExtension(LocalizationFileExtension).Name,
                ExtensionFilter = new FileFilterItem($"*{LocalizationFileExtension}", Resources.UbiArtU_LocalizationConverterLocFilterDescription).StringRepresentation,
            });

            if (outputResult.CanceledByUser)
            {
                return;
            }

            try
            {
                // Deserialize the JSON input file
                var data = JsonHelpers.DeserializeFromFile <DataType>(inputResult.SelectedFile);

                // Serialize the data to the output localization file
                Serialize(outputResult.SelectedFile, data);

                await Services.MessageUI.DisplaySuccessfulActionMessageAsync(Resources.UbiArtU_LocalizationConverterImportSuccess);
            }
            catch (Exception ex)
            {
                ex.HandleError("Importing JSON to localization file");
                await Services.MessageUI.DisplayExceptionMessageAsync(ex, Resources.UbiArtU_LocalizationConverterImportError);
            }
        }
コード例 #4
0
        /// <summary>
        /// Imports an exported save slot to the save slot from the specified path
        /// </summary>
        /// <param name="inputFilePath">The input file path</param>
        /// <returns>The task</returns>
        protected override Task ImportSaveDataAsync(FileSystemPath inputFilePath)
        {
            // Deserialize the input data
            var data = JsonHelpers.DeserializeFromFile <Rayman1PCSaveData>(inputFilePath);

            // Create streams
            using var decodedDataStream = new MemoryStream();
            using var saveFileStream    = File.Create(SaveSlotFilePath);

            // Import the data
            BinarySerializableHelpers.WriteToStream(data, decodedDataStream, Ray1Settings.GetDefaultSettings(Ray1Game.Rayman1, Platform.PC), RCPServices.App.GetBinarySerializerLogger());

            // Set position to 0
            decodedDataStream.Position = 0;

            // Encode the data to the file
            new Rayman12PCSaveDataEncoder().Encode(decodedDataStream, saveFileStream);

            return(Task.CompletedTask);
        }
コード例 #5
0
 /// <summary>
 /// Deserializes data as JSON from a file
 /// </summary>
 /// <typeparam name="T">The type of data</typeparam>
 /// <param name="filePath">The file path to save to</param>
 protected T DeserializeJSON <T>(FileSystemPath filePath)
 {
     // Deserialize the data
     return(JsonHelpers.DeserializeFromFile <T>(filePath));
 }