/// <summary>
        /// Converts from the format
        /// </summary>
        /// <returns>The task</returns>
        public override async Task ConvertFromAsync()
        {
            var attr     = GameModeSelection.SelectedValue.GetAttribute <UbiArtGameModeInfoAttribute>();
            var settings = UbiArtSettings.GetDefaultSettings(attr.Game, attr.Platform);

            if (GameModeSelection.SelectedValue == UbiArtGameMode.RaymanFiestaRunPC)
            {
                await ConvertFromAsync <FiestaRunLocalizationData>(settings, (data, filePath) =>
                {
                    // Save the data
                    SerializeJSON(data, filePath);
                }, new FileFilterItem("*.loc", "LOC").ToString(), new[]
                {
                    ".json"
                }, Games.RaymanFiestaRun.GetInstallDir(false));
            }
            else
            {
                var fileExtension = Equals(settings.StringEncoding, Encoding.UTF8) ? new FileFilterItem("*.loc8", "LOC8") : new FileFilterItem("*.loc", "LOC");

                await ConvertFromAsync <UbiArtLocalizationData>(settings, (data, filePath) =>
                {
                    // Save the data
                    SerializeJSON(data, filePath);
                }, fileExtension.ToString(), new[]
                {
                    ".json"
                }, GameModeSelection.SelectedValue.GetGame()?.GetInstallDir(false));
            }
        }
        /// <summary>
        /// Opens the archive explorer
        /// </summary>
        /// <returns>The task</returns>
        public async Task OpenAsync()
        {
            var attr     = GameMode.GetAttribute <UbiArtGameModeInfoAttribute>();
            var settings = UbiArtSettings.GetDefaultSettings(attr.Game, attr.Platform);

            // Show the archive explorer
            await RCPServices.UI.ShowArchiveExplorerAsync(new UbiArtIPKArchiveExplorerDataManager(settings), ArchiveFiles.Where(x => x.FileExists));
        }
        /// <summary>
        /// Serializes the data to the localization file
        /// </summary>
        /// <param name="file">The localization file</param>
        /// <param name="data">The data</param>
        protected override void Serialize(FileSystemPath file, UbiArtLocStringValuePair[] data)
        {
            // Read the current data to get the remaining bytes
            var currentData = BinarySerializableHelpers.ReadFromFile <UbiArtLocalizationData>(file, UbiArtSettings.GetDefaultSettings(UbiArtGame.RaymanOrigins, Platform.PC), RCPServices.App.GetBinarySerializerLogger());

            // Replace the string data
            currentData.Strings = data;

            // Serialize the data
            BinarySerializableHelpers.WriteToFile(currentData, file, UbiArtSettings.GetDefaultSettings(UbiArtGame.RaymanOrigins, Platform.PC), RCPServices.App.GetBinarySerializerLogger());
        }
        /// <summary>
        /// Converts to the format
        /// </summary>
        /// <returns>The task</returns>
        public override async Task ConvertToAsync()
        {
            var attr     = GameModeSelection.SelectedValue.GetAttribute <UbiArtGameModeInfoAttribute>();
            var settings = UbiArtSettings.GetDefaultSettings(attr.Game, attr.Platform);

            if (GameModeSelection.SelectedValue == UbiArtGameMode.RaymanFiestaRunPC)
            {
                await ConvertToAsync <FiestaRunLocalizationData>(settings, (filePath, format) =>
                {
                    // Read the data
                    return(DeserializeJSON <FiestaRunLocalizationData>(filePath));
                }, new FileFilterItem("*.json", "JSON").ToString(), new FileExtension(".loc"));
            }
            else
            {
                var fileExtension = new FileExtension(Equals(settings.StringEncoding, Encoding.UTF8) ? ".loc8" : ".loc");

                await ConvertToAsync <UbiArtLocalizationData>(settings, (filePath, format) =>
                {
                    // Read the data
                    return(DeserializeJSON <UbiArtLocalizationData>(filePath));
                }, new FileFilterItem("*.json", "JSON").ToString(), fileExtension);
            }
        }
 /// <summary>
 /// Deserializes the localization file
 /// </summary>
 /// <param name="file">The localization file</param>
 /// <returns>The data</returns>
 protected override UbiArtLocStringValuePair[] Deserialize(FileSystemPath file)
 {
     return(BinarySerializableHelpers.ReadFromFile <UbiArtLocalizationData>(file, UbiArtSettings.GetDefaultSettings(UbiArtGame.RaymanOrigins, Platform.PC), RCPServices.App.GetBinarySerializerLogger()).Strings);
 }
Пример #6
0
        /// <summary>
        /// Gets the patch infos for each <see cref="Patch"/>
        /// </summary>
        /// <param name="ipkStream">The IPK file stream</param>
        /// <returns>The patch infos</returns>
        protected IEnumerable <PatchInfo> GetPatchInfos(Stream ipkStream)
        {
            // Deserialize the IPK file
            var ipk = BinarySerializableHelpers.ReadFromStream <UbiArtIpkData>(ipkStream, UbiArtSettings.GetDefaultSettings(UbiArtGame.RaymanLegends, Platform.PC), RCPServices.App.GetBinarySerializerLogger());

            // Enumerate every patch
            foreach (var patchGroup in GetPatches.GroupBy(x => x.FileName))
            {
                // Get the file
                var file = ipk.Files.FindItem(x => x.Path.FileName == patchGroup.Key);

                // Make sure we found the file
                if (file == null)
                {
                    throw new Exception("Patch file not found");
                }

                // Make sure it's not compressed
                if (file.IsCompressed)
                {
                    throw new Exception("The configuration file is compressed and can not be edited");
                }

                // Get the offsets
                foreach (Patch patch in patchGroup)
                {
                    // Get the offset of the byte in the file to change
                    yield return(new PatchInfo(patch, (long)(ipk.BaseOffset + file.Offsets.First() + (uint)patch.FileOffset)));
                }
            }
        }