コード例 #1
0
        /// <summary>
        /// Encodes the file bytes
        /// </summary>
        /// <param name="fileData">The bytes to encode</param>
        /// <param name="fileEntry">The file entry for the file to encode</param>
        /// <returns>The encoded bytes</returns>
        public byte[] EncodeFile(byte[] fileData, object fileEntry)
        {
            // Get the file entry
            var file = fileEntry.CastTo <UbiArtIPKFileEntry>();

            // Set the file size
            file.Size = (uint)fileData.Length;

            // Return the data as is if the file should not be compressed
            if (!Config.ShouldCompress(file))
            {
                return(fileData);
            }

            // Compress the bytes
            var compressedBytes = UbiArtIpkData.GetEncoder(file.IPKVersion, file.Size).Encode(fileData);

            RL.Logger?.LogTraceSource($"The file {file.Path.FileName} has been compressed");

            // Set the compressed file size
            file.CompressedSize = (uint)compressedBytes.Length;

            // Return the compressed bytes
            return(compressedBytes);
        }
コード例 #2
0
        /// <summary>
        /// Gets a new archive from a collection of modified files
        /// </summary>
        /// <param name="files">The files to import</param>
        /// <returns>The archive creation data</returns>
        public ArchiveCreationData GetArchive(IEnumerable <FileSystemPath> files)
        {
            // Create the data
            var data = new UbiArtIpkData();

            // Configure the data
            Config.ConfigureIpkData(data);

            // Create the entry data for each file
            var fileEntries = files.Select(x => new ArchiveCreationData.FileEntryImportData(new UbiArtIPKFileEntry()
            {
                IPKVersion = data.Version,
                Path       = new UbiArtPath(x),
            }, x)).ToArray();

            // Set the files
            data.Files      = fileEntries.Select(x => x.FileEntry.CastTo <UbiArtIPKFileEntry>()).ToArray();
            data.FilesCount = (uint)data.Files.Length;

            return(new ArchiveCreationData(data, fileEntries));
        }
コード例 #3
0
        /// <summary>
        /// Configures the .ipk data with the default settings for the current settings
        /// </summary>
        /// <param name="data">The .ipk data to configure</param>
        public void ConfigureIpkData(UbiArtIpkData data)
        {
            // Set default properties based on settings
            switch (Settings.Game)
            {
            case UbiArtGame.RaymanOrigins:

                switch (Settings.Platform)
                {
                case Rayman.Platform.Wii:
                    data.Version       = 3;
                    data.Unknown1      = 6;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 1698768603;
                    data.EngineVersion = 0;
                    break;

                case Rayman.Platform.Nintendo3DS:
                    data.Version       = 4;
                    data.Unknown1      = 5;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 1635089726;
                    data.EngineVersion = 0;
                    break;

                case Rayman.Platform.PlayStation3:
                    data.Version       = 3;
                    data.Unknown1      = 3;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 1698768603;
                    data.EngineVersion = 0;
                    break;

                case Rayman.Platform.PSVita:
                    data.Version       = 3;
                    data.Unknown1      = 7;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 559042371;
                    data.EngineVersion = 0;
                    break;

                case Rayman.Platform.PC:
                    data.Version       = 3;
                    data.Unknown1      = 0;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 877930951;
                    data.EngineVersion = 0;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(Settings.Platform), Settings.Platform, null);
                }

                break;

            case UbiArtGame.RaymanLegends:

                switch (Settings.Platform)
                {
                case Rayman.Platform.WiiU:
                    data.Version       = 5;
                    data.Unknown1      = 6;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 78992;
                    data.Unknown7      = 2697850994;
                    data.EngineVersion = 84435;
                    break;

                case Rayman.Platform.NintendoSwitch:
                    data.Version       = 7;
                    data.Unknown1      = 10;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 2514498303;
                    data.EngineVersion = 0;
                    break;

                case Rayman.Platform.PSVita:
                    data.Version       = 5;
                    data.Unknown1      = 6;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 2869177618;
                    data.EngineVersion = 0;
                    break;

                case Rayman.Platform.PlayStation4:
                    data.Version       = 7;
                    data.Unknown1      = 8;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 80253;
                    data.Unknown7      = 2973796970;
                    data.EngineVersion = 117321;
                    break;

                case Rayman.Platform.PC:
                    data.Version       = 5;
                    data.Unknown1      = 0;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 1274838019;
                    data.EngineVersion = 0;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(Settings.Platform), Settings.Platform, null);
                }

                break;

            case UbiArtGame.RaymanAdventures:

                switch (Settings.Platform)
                {
                case Rayman.Platform.Android:
                    data.Version       = 8;
                    data.Unknown1      = 12;
                    data.Unknown2      = 11;
                    data.Unknown3      = true;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 127901;
                    data.Unknown7      = 3037303110;
                    data.EngineVersion = 277220;
                    break;

                case Rayman.Platform.iOS:
                    data.Version       = 8;
                    data.Unknown1      = 12;
                    data.Unknown2      = 19;
                    data.Unknown3      = true;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 127895;
                    data.Unknown7      = 3037303110;
                    data.EngineVersion = 277216;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(Settings.Platform), Settings.Platform, null);
                }

                break;

            case UbiArtGame.RaymanMini:

                switch (Settings.Platform)
                {
                case Rayman.Platform.Mac:
                    data.Version       = 8;
                    data.Unknown1      = 12;
                    data.Unknown2      = 11;
                    data.Unknown3      = true;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 4533;
                    data.Unknown7      = 2293139714;
                    data.EngineVersion = 4533;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(Settings.Platform), Settings.Platform, null);
                }

                break;

            case UbiArtGame.JustDance2017:

                switch (Settings.Platform)
                {
                case Rayman.Platform.WiiU:
                    data.Version       = 5;
                    data.Unknown1      = 8;
                    data.Unknown2      = 0;
                    data.Unknown3      = false;
                    data.Unknown4      = false;
                    data.Unknown5      = false;
                    data.Unknown6      = 0;
                    data.Unknown7      = 3346979248;
                    data.EngineVersion = 241478;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(Settings.Platform), Settings.Platform, null);
                }

                break;

            case UbiArtGame.ValiantHearts:

                switch (Settings.Platform)
                {
                case Rayman.Platform.Android:
                    data.Version       = 7;
                    data.Unknown1      = 10;
                    data.Unknown2      = 0;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown9      = 0;
                    data.Unknown7      = 3713665533;
                    data.EngineVersion = 0;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(Settings.Platform), Settings.Platform, null);
                }

                break;

            case UbiArtGame.ChildOfLight:

                switch (Settings.Platform)
                {
                // NOTE: This is based on the demo
                case Rayman.Platform.PC:
                    data.Version       = 7;
                    data.Unknown1      = 0;
                    data.Unknown2      = 0;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 3669482532;
                    data.EngineVersion = 30765;
                    break;

                case Rayman.Platform.PSVita:
                    data.Version       = 7;
                    data.Unknown1      = 6;
                    data.Unknown2      = 0;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 19689438;
                    data.EngineVersion = 0;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(Settings.Platform), Settings.Platform, null);
                }

                break;

            case UbiArtGame.GravityFalls:

                switch (Settings.Platform)
                {
                case Rayman.Platform.Nintendo3DS:
                    data.Version       = 7;
                    data.Unknown1      = 10;
                    data.Unknown2      = 0;
                    data.Unknown3      = false;
                    data.Unknown4      = true;
                    data.Unknown5      = true;
                    data.Unknown6      = 0;
                    data.Unknown7      = 4160251604;
                    data.EngineVersion = 0;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(Settings.Platform), Settings.Platform, null);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(Settings.Game), Settings.Game, null);
            }
        }