예제 #1
0
        /// <summary>
        ///
        /// </summary>
        public override void Work(BackgroundWorker w)
        {
            if (!editor.FighterControl.FighterEntries.Contains(fighter))
            {
                w.ReportProgress(100);
                return;
            }

            var root = Path.GetDirectoryName(MainForm.Instance.FilePath);
            var plco = Path.Combine(root, "PlCo.dat");
            var sem  = Path.Combine(root, "audio\\us\\smash2.sem");

            if (!File.Exists(plco))
            {
                throw new FileNotFoundException("PlCo.dat was not found");
            }

            if (!File.Exists(sem))
            {
                throw new FileNotFoundException("smash2.sem was not found");
            }

            ProgressStatus = "Removing Bone Entry";
            w.ReportProgress(0);
            RemoveBoneTableEntry(plco);

            ProgressStatus = "Removing Fighter Entry";
            w.ReportProgress(20);
            editor.FighterControl.RemoveFighterEntry(internalID);

            ProgressStatus = "Removing Items";
            w.ReportProgress(40);
            RemoveMEXItems();

            ProgressStatus = "Removing Fighter Effects";
            w.ReportProgress(50);
            RemoveMEXEffects();

            ProgressStatus = "Removing Sounds";
            w.ReportProgress(60);
            RemoveSounds();

            ProgressStatus = "Removing UI";
            w.ReportProgress(70);
            RemoveUI(fighter, editor, internalID);

            // TODO: remove unused files

            ProgressStatus = "Saving Files";
            w.ReportProgress(90);
            SEM.SaveSEMFile(sem, SemEntries, editor._data);

            foreach (var v in editedFiles)
            {
                v.Item1.Save(v.Item2, v.Item3);
            }

            ProgressStatus = "Done";
            w.ReportProgress(100);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="packagePath"></param>
        public override void Work(BackgroundWorker w)
        {
            var root = Path.GetDirectoryName(MainForm.Instance.FilePath);
            var plco = Path.Combine(root, "PlCo.dat");
            var sem  = Path.Combine(root, "audio\\us\\smash2.sem");

            if (!File.Exists(plco))
            {
                throw new FileNotFoundException("PlCo.dat was not found");
            }

            if (!File.Exists(sem))
            {
                throw new FileNotFoundException("smash2.sem was not found");
            }

            using (ZipFile pack = new ZipFile(packagePath))
            {
                string fighterYAMLPath = null;

                foreach (var e in pack)
                {
                    Console.WriteLine(e.FileName);
                    if (Path.GetFileName(e.FileName).ToLower() == "fighter.yaml")
                    {
                        fighterYAMLPath = e.FileName;
                    }
                }

                if (string.IsNullOrEmpty(fighterYAMLPath))
                {
                    return;
                }

                MEXFighterEntry mexEntry = null;

                using (MemoryStream zos = new MemoryStream())
                {
                    pack[fighterYAMLPath].Extract(zos);
                    zos.Position = 0;
                    //using (StreamReader r = new StreamReader(zos))
                    //    mexEntry = MEXFighterEntry.Deserialize(r.ReadToEnd());
                }

                if (mexEntry == null)
                {
                    return;
                }

                ProgressStatus = $"Importing  {mexEntry.NameText}...";
                w.ReportProgress(0);

                var internalID = editor.FighterControl.AddEntry(mexEntry);

                ProgressStatus = "Installing Item Data"; w.ReportProgress(10);
                ImportItemData(pack, mexEntry);

                ProgressStatus = "Installing Item Data"; w.ReportProgress(20);
                GenerateEffectFile(pack, mexEntry);

                ProgressStatus = "Installing Item Data"; w.ReportProgress(30);
                ImportSoundData(pack, mexEntry, sem);

                ProgressStatus = "Installing UI"; w.ReportProgress(50);
                InstallUI(pack, mexEntry);

                ProgressStatus = "Installing Item Data"; w.ReportProgress(60);
                InjectBoneTable(pack, plco, internalID);

                //...
                ProgressStatus = "Extracting Files";
                w.ReportProgress(70);
                ExtractFiles(pack, mexEntry, editor);

                ProgressStatus = "Building new SEM";
                w.ReportProgress(80);
                if (SemEntries.Count != 0)
                {
                    SEM.SaveSEMFile(sem, SemEntries, editor._data);
                }

                ProgressStatus = "Saving Files";
                w.ReportProgress(90);
                foreach (var d in editedFiles)
                {
                    d.Item1.Save(d.Item2, d.Item3);
                }

                ProgressStatus = "Done";
                w.ReportProgress(100);
                // done
                Console.WriteLine($"Done!");
            }
        }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="path"></param>
 public void SaveSEMFile(string path, MEX_Data mex = null)
 {
     SEM.SaveSEMFile(path, Entries.ToList(), mex);
 }