Esempio n. 1
0
        public void Dispose()
        {
            autoCompleteSource.Clear();

            List <uint> assetList = new List <uint>();

            assetList.AddRange(assetDictionary.Keys);

            if (assetList.Count == 0)
            {
                return;
            }

            ProgressBar progressBar = new ProgressBar("Closing Archive");

            progressBar.Show();
            progressBar.SetProgressBar(0, assetList.Count, 1);

            foreach (uint assetID in assetList)
            {
                DisposeOfAsset(assetID, true);
                progressBar.PerformStep();
            }

            HIPA = null;
            PACK = null;
            DICT = null;
            STRM = null;
            currentlyOpenFilePath = null;

            progressBar.Close();
        }
Esempio n. 2
0
        public bool New()
        {
            HipSection[] hipFile = NewArchive.GetNewArchive(out bool OK, out Platform platform, out Game game);

            if (OK)
            {
                Dispose();

                currentlySelectedAssets = new List <Asset>();
                currentlyOpenFilePath   = null;

                foreach (HipSection i in hipFile)
                {
                    if (i is Section_HIPA hipa)
                    {
                        HIPA = hipa;
                    }
                    else if (i is Section_PACK pack)
                    {
                        PACK = pack;
                    }
                    else if (i is Section_DICT dict)
                    {
                        DICT = dict;
                    }
                    else if (i is Section_STRM strm)
                    {
                        STRM = strm;
                    }
                    else
                    {
                        throw new Exception();
                    }
                }

                currentPlatform = platform;
                currentGame     = game;

                if (currentPlatform == Platform.Unknown)
                {
                    new ChoosePlatformDialog().ShowDialog();
                }

                foreach (Section_AHDR AHDR in DICT.ATOC.AHDRList)
                {
                    AddAssetToDictionary(AHDR, true);
                }
                RecalculateAllMatrices();
            }

            return(OK);
        }
Esempio n. 3
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            OK = true;

            Section_HIPA HIPA = new Section_HIPA();
            Section_PACK PACK = new Section_PACK();
            Section_DICT DICT = new Section_DICT
            {
                ATOC = new Section_ATOC()
                {
                    AINF = new Section_AINF(0)
                },
                LTOC = new Section_LTOC()
                {
                    LINF = new Section_LINF(0)
                },
            };
            Section_STRM STRM = new Section_STRM
            {
                DHDR = new Section_DHDR(-1),
                DPAK = new Section_DPAK()
            };

            PACK.PMOD = new Section_PMOD((int)dateTimePicker1.Value.ToBinary());
            PACK.PCRT = new Section_PCRT((int)dateTimePicker1.Value.ToBinary(), textBoxPCRT.Text);
            PACK.PCNT = new Section_PCNT(0, 0, 0, 0, 0);
            PACK.PFLG = new Section_PFLG(46);

            if (game != Game.Scooby)
            {
                PACK.PVER = new Section_PVER(2, 655375, 1);
                PACK.PLAT = new Section_PLAT
                {
                    regionFormat = "NTSC"
                };
            }

            switch (game)
            {
            case Game.Scooby:
                PACK.PVER = new Section_PVER(2, 262150, 1);
                break;

            case Game.BFBB:
                PACK.PLAT.language   = "US Common";
                PACK.PLAT.targetGame = "Sponge Bob";
                switch (platform)
                {
                case Platform.GameCube:
                    PACK.PFLG = new Section_PFLG(36241454);
                    PACK.PLAT.targetPlatform     = "GC";
                    PACK.PLAT.targetPlatformName = "GameCube";
                    platform = Platform.GameCube;
                    break;

                case Platform.PS2:
                    PACK.PFLG = new Section_PFLG(36438062);
                    PACK.PLAT.targetPlatform     = "P2";
                    PACK.PLAT.targetPlatformName = "PlayStation 2";
                    platform = Platform.PS2;
                    break;

                case Platform.Xbox:
                    PACK.PFLG = new Section_PFLG(36306990);
                    PACK.PLAT.targetPlatform     = "XB";
                    PACK.PLAT.targetPlatformName = "Xbox";
                    platform = Platform.Xbox;
                    break;
                }
                break;

            case Game.Incredibles:
                PACK.PLAT.language   = "US";
                PACK.PLAT.targetGame = "Incredibles";
                switch (platform)
                {
                case Platform.Xbox:
                    PACK.PLAT.targetPlatform = "BX";
                    platform = Platform.Xbox;
                    break;

                case Platform.GameCube:
                    PACK.PLAT.targetPlatform = "GC";
                    platform = Platform.GameCube;
                    break;

                case Platform.PS2:
                    PACK.PLAT.targetPlatform = "PS2";
                    platform = Platform.PS2;
                    break;
                }
                break;
            }

            result = new HipSection[] { HIPA, PACK, DICT, STRM };

            Close();
        }
Esempio n. 4
0
        public void OpenFile(string fileName)
        {
            allowRender = false;

            Dispose();
            ProgressBar progressBar = new ProgressBar("Opening Archive");

            progressBar.Show();

            assetDictionary = new Dictionary <uint, Asset>();

            currentlySelectedAssets = new List <Asset>();
            currentlyOpenFilePath   = fileName;

            foreach (HipSection i in HipFileToHipArray(fileName))
            {
                if (i is Section_HIPA hipa)
                {
                    HIPA = hipa;
                }
                else if (i is Section_PACK pack)
                {
                    PACK = pack;
                }
                else if (i is Section_DICT dict)
                {
                    DICT = dict;
                }
                else if (i is Section_STRM strm)
                {
                    STRM = strm;
                }
                else
                {
                    progressBar.Close();
                    throw new Exception();
                }
            }

            progressBar.SetProgressBar(0, DICT.ATOC.AHDRList.Count, 1);

            if (currentPlatform == Platform.Unknown)
            {
                new ChoosePlatformDialog().ShowDialog();
            }

            List <string> autoComplete = new List <string>();

            foreach (Section_AHDR AHDR in DICT.ATOC.AHDRList)
            {
                AddAssetToDictionary(AHDR, true);

                autoComplete.Add(AHDR.ADBG.assetName);

                progressBar.PerformStep();
            }

            autoCompleteSource.AddRange(autoComplete.ToArray());

            if (GetAssetsOfType(AssetType.RWTX).Any())
            {
                SetupTextureDisplay();
            }

            RecalculateAllMatrices();

            progressBar.Close();

            allowRender = true;
        }
Esempio n. 5
0
        public Patch Commit(string root)
        {
            Patch uninstall = new Patch();

            uninstall.isUninstall = true;

            Console.WriteLine();
            Console.WriteLine("Patching...");
            Console.WriteLine();

            foreach (AddedFile file in addedFiles)
            {
                string path = root + file.path;

                DeletedFile backup = new DeletedFile(file.path);
                uninstall.deletedFiles.Add(backup);

                File.WriteAllBytes(path, file.data);

                PrintFile(PatchType.ADD, file.path);
            }

            foreach (ModifiedFile file in modifiedFiles)
            {
                string path = root + file.path;

                if (File.Exists(path))
                {
                    byte[]       data   = File.ReadAllBytes(path);
                    ModifiedFile backup = new ModifiedFile(file.path, data);
                    uninstall.modifiedFiles.Add(backup);
                }

                File.WriteAllBytes(path, file.data);

                PrintFile(PatchType.MODIFY, file.path);
            }

            foreach (DeletedFile file in deletedFiles)
            {
                string path = root + file.path;

                if (File.Exists(path))
                {
                    byte[]    data   = File.ReadAllBytes(path);
                    AddedFile backup = new AddedFile(file.path, data);
                    uninstall.addedFiles.Add(backup);
                }

                File.Delete(path);

                PrintFile(PatchType.DELETE, file.path);
            }

            foreach (HipFile file in hipFiles)
            {
                string path = root + file.path;

                HipFile      backup = new HipFile(file.path);
                HipSection[] hip    = HipFileToHipArray(path);

                Section_HIPA hipa = (Section_HIPA)hip[0];
                Section_PACK pack = (Section_PACK)hip[1];
                Section_DICT dict = (Section_DICT)hip[2];
                Section_STRM strm = (Section_STRM)hip[3];

                List <Section_AHDR> ahdrList = dict.ATOC.AHDRList;
                List <Section_LHDR> lhdrList = dict.LTOC.LHDRList;

                Dictionary <uint, Section_AHDR> ahdrDict = ahdrList.ToDictionary(s => s.assetID);

                PrintFile(PatchType.MODIFY, file.path);

                foreach (AddedAsset asset in file.addedAssets)
                {
                    Section_ADBG adbg = new Section_ADBG(asset.alignment, asset.name, asset.filename, asset.checksum);
                    Section_AHDR ahdr = new Section_AHDR(asset.id, new string(asset.type), (AHDRFlags)asset.flags, adbg);

                    ahdr.data = asset.data;

                    DeletedAsset backupAsset = new DeletedAsset(asset);
                    backup.deletedAssets.Add(backupAsset);

                    ahdrList.Add(ahdr);

                    Section_LHDR lhdr = lhdrList[asset.layer];
                    lhdr.assetIDlist.Add(asset.id);

                    PrintAsset(PatchType.ADD, asset.name);
                }

                foreach (ModifiedAsset asset in file.modifiedAssets)
                {
                    if (!ahdrDict.ContainsKey(asset.id))
                    {
                        break;
                    }

                    Section_ADBG adbg = new Section_ADBG(asset.alignment, asset.name, asset.filename, asset.checksum);
                    Section_AHDR ahdr = new Section_AHDR(asset.id, new string(asset.type), (AHDRFlags)asset.flags, adbg);

                    ahdr.data = asset.data;

                    Section_AHDR oldAHDR = ahdrDict[asset.id];
                    ahdrList.Remove(oldAHDR);
                    ahdrList.Add(ahdr);

                    ModifiedAsset backupAsset = new ModifiedAsset(oldAHDR, hip);
                    backup.modifiedAssets.Add(backupAsset);

                    PrintAsset(PatchType.MODIFY, asset.name);
                }

                foreach (DeletedAsset asset in file.deletedAssets)
                {
                    if (!ahdrDict.ContainsKey(asset.id))
                    {
                        break;
                    }

                    Section_AHDR ahdr = ahdrDict[asset.id];

                    ahdrList.Remove(ahdr);

                    AddedAsset backupAsset = new AddedAsset(ahdr, hip);
                    backup.addedAssets.Add(backupAsset);

                    Section_LHDR lhdr = lhdrList[asset.layer];
                    lhdr.assetIDlist.Remove(asset.id);

                    PrintAsset(PatchType.DELETE, asset.name);
                }

                pack.PCNT.AHDRCount = ahdrList.Count;

                hip = SetupStream(ref hipa, ref pack, ref dict, ref strm);
                File.WriteAllBytes(path, HipArrayToFile(hip));

                uninstall.hipFiles.Add(backup);
            }

            Console.WriteLine("Done patching.");
            Console.WriteLine();

            return(uninstall);
        }