예제 #1
0
        /// <summary>
        /// Splits data from a SplitEntryMDL.
        /// </summary>
        public static void SplitTemplateMDLEntry(Templates.SplitEntryMDL splitMDL, SAModel.SAEditorCommon.UI.ProgressDialog progress, string gameFolder, string outputFolder, bool overwrite = true)
        {
            string filePath         = Path.Combine(gameFolder, splitMDL.ModelFile);
            string fileOutputFolder = Path.Combine(outputFolder, "figure\\bin");

            if (progress != null)
            {
                progress.StepProgress();
                progress.SetStep("Splitting models from " + splitMDL.ModelFile);
            }

            #region Validating Inputs
            if (!File.Exists(filePath))
            {
                MessageBox.Show((filePath + " is missing.\n\nPress OK to abort."), "Split Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                throw new Exception(SplitERRORVALUE.NoSourceFile.ToString());
                //return (int)ERRORVALUE.NoSourceFile;
            }
            #endregion

            if (overwrite)
            {
                sa2MDL.Split(splitMDL.BigEndian, filePath, fileOutputFolder, splitMDL.MotionFiles.ToArray());
            }
        }
예제 #2
0
        private void GenerateModFile(string game, SAModel.SAEditorCommon.UI.ProgressDialog progress, string projectFolder, string name)
        {
            progress.StepProgress();
            progress.SetStep("Generating mod.ini");
            string outputPath;

            switch (game)
            {
            case ("SADXPC"):
                SADXModInfo modInfoSADX = new SADXModInfo
                {
                    Name = name
                };
                outputPath = Path.Combine(projectFolder, string.Format("mod.ini"));

                SplitTools.IniSerializer.Serialize(modInfoSADX, outputPath);
                break;

            case ("SA2PC"):
                SA2ModInfo modInfoSA2PC = new SA2ModInfo
                {
                    Name = name
                };
                outputPath = Path.Combine(projectFolder, string.Format("mod.ini"));

                SplitTools.IniSerializer.Serialize(modInfoSA2PC, outputPath);
                break;

            default:
                break;
            }
        }
예제 #3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            using (SAModel.SAEditorCommon.UI.ProgressDialog progress = new SAModel.SAEditorCommon.UI.ProgressDialog("Building Project"))
            {
                Action showProgress = () =>
                {
                    Invoke((Action)progress.Show);
                };

                Action <int> setSteps = (int count) =>
                {
                    progress.SetMaxSteps(count);
                };

                Action <string> stepProgress = (string update) =>
                {
                    progress.StepProgress();
                    progress.SetStep(update);
                };

                AutoBuild(showProgress, setSteps, stepProgress);
            }
        }
예제 #4
0
        /// <summary>
        /// Splits data from a SplitEntry.
        /// </summary>
        public static void SplitTemplateEntry(Templates.SplitEntry splitData, SAModel.SAEditorCommon.UI.ProgressDialog progress, string gameFolder, string iniFolder, string outputFolder, bool overwrite = true, bool nometa = false, bool nolabel = false)
        {
            string datafilename;

            switch (splitData.SourceFile)
            {
            case ("system/chrmodels.dll"):
                if (File.Exists(Path.Combine(gameFolder, "system/chrmodels_orig.dll")))
                {
                    datafilename = Path.Combine(gameFolder, "system/chrmodels_orig.dll");
                }
                else
                {
                    datafilename = Path.Combine(gameFolder, splitData.SourceFile);
                }
                break;

            case ("Data_DLL.dll"):
                if (File.Exists(Path.Combine(gameFolder, "resource/gd_PC/DLL/Win32/Data_DLL_orig.dll")))
                {
                    datafilename = Path.Combine(gameFolder, "resource/gd_PC/DLL/Win32/Data_DLL_orig.dll");
                }
                else
                {
                    datafilename = Path.Combine(gameFolder, "resource/gd_PC/DLL/Win32/Data_DLL.dll");
                }
                break;

            default:
                datafilename = Path.Combine(gameFolder, splitData.SourceFile);
                break;
            }
            string inifilename       = Path.Combine(iniFolder, (splitData.IniFile.ToLower() + ".ini"));
            string projectFolderName = (outputFolder + "\\");

            string splitItem;

            if (splitData.CmnName != null)
            {
                splitItem = splitData.CmnName;
            }
            else
            {
                splitItem = splitData.IniFile;
            }

            if (progress != null)
            {
                progress.StepProgress();
                progress.SetStep("Splitting " + splitItem + " from " + splitData.SourceFile);
            }

            #region Validating Inputs
            if (!File.Exists(datafilename))
            {
                MessageBox.Show((datafilename + " is missing.\n\nPress OK to abort."), "Split Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                throw new Exception(SplitTools.Split.SplitERRORVALUE.NoSourceFile.ToString());
                //return (int)ERRORVALUE.NoSourceFile;
            }

            if (!File.Exists(inifilename))
            {
                MessageBox.Show((inifilename + " is missing.\n\nPress OK to abort."), "Split Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                throw new Exception(SplitTools.Split.SplitERRORVALUE.NoDataMapping.ToString());
                //return (int)ERRORVALUE.NoDataMapping;
            }
            #endregion

            // switch on file extension - if dll, use dll splitter
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(datafilename);
            string             ext      = fileInfo.Extension;

            switch (ext.ToLower())
            {
            case ".dll":
                SplitTools.SplitDLL.SplitDLL.SplitDLLFile(datafilename, inifilename, projectFolderName, nometa, nolabel, overwrite, true);
                break;

            case ".nb":
                SplitTools.Split.SplitNB.SplitNBFile(datafilename, false, projectFolderName, 0, inifilename, overwrite);
                break;

            default:
                SplitTools.Split.SplitBinary.SplitFile(datafilename, inifilename, projectFolderName, nometa, nolabel, overwrite, true);
                break;
            }
        }
예제 #5
0
        ProjectSplitResult splitGame(string game, SAModel.SAEditorCommon.UI.ProgressDialog progress, DoWorkEventArgs e)
        {
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            string iniFolder;

            progress.SetMaxSteps(setProgressMaxStep());

            if (Directory.Exists(Path.Combine(appPath, "GameConfig", dataFolder)))
            {
                iniFolder = Path.Combine(appPath, "GameConfig", dataFolder);
            }
            else
            {
                iniFolder = Path.Combine(appPath, "..\\GameConfig", dataFolder);
            }

            progress.SetTask("Splitting Game Content");
            // Delete log if it exists
            if (File.Exists(Path.Combine(projFolder, "SplitLog.log")))
            {
                File.Delete(Path.Combine(projFolder, "SplitLog.log"));
            }
            foreach (Templates.SplitEntry splitEntry in splitEntries)
            {
                if (backgroundWorker1.CancellationPending == true)
                {
                    e.Cancel = true;
                    return(ProjectSplitResult.Cancelled);
                }
                ProjectFunctions.SplitTemplateEntry(splitEntry, progress, gamePath, iniFolder, projFolder, nometa: comboBoxLabels.SelectedIndex == 2, nolabel: comboBoxLabels.SelectedIndex != 1);
                if (File.Exists(Path.Combine(projFolder, "SplitLog.log")))
                {
                    return(ProjectSplitResult.ItemFailure);
                }
            }
            // SALVL stuff
            if (File.Exists(Path.Combine(iniFolder, "sadxlvl.ini")))
            {
                progress.SetStep("Copying Object Definitions");
                string objdefsPath       = GetObjDefsDirectory();
                string outputObjdefsPath = Path.Combine(projFolder, "objdefs");
                if (Directory.Exists(objdefsPath))
                {
                    CopyFolder(objdefsPath, outputObjdefsPath);
                }
                progress.SetTask("Finalizing SALVL Supported Setup");
                File.Copy(Path.Combine(iniFolder, "sadxlvl.ini"), Path.Combine(projFolder, "sadxlvl.ini"), true);
                File.Copy(Path.Combine(iniFolder, "objdefs.ini"), Path.Combine(projFolder, "objdefs.ini"), true);
            }
            if (File.Exists(Path.Combine(iniFolder, "sa2lvl.ini")))
            {
                progress.SetStep("Copying Object Definitions");
                string objdefsPath       = GetObjDefsDirectory(true);
                string outputObjdefsPath = Path.Combine(projFolder, "objdefs");
                if (Directory.Exists(objdefsPath))
                {
                    CopyFolder(objdefsPath, outputObjdefsPath);
                }
                progress.SetTask("Finalizing SALVL Supported Setup");
                File.Copy(Path.Combine(iniFolder, "sa2lvl.ini"), Path.Combine(projFolder, "sa2lvl.ini"), true);
                File.Copy(Path.Combine(iniFolder, "objdefs.ini"), Path.Combine(projFolder, "objdefs.ini"), true);
            }
            // Split MDL files for SA2
            if (splitMdlEntries.Count > 0)
            {
                progress.SetTask("Splitting Character Models");
                foreach (Templates.SplitEntryMDL splitMDL in splitMdlEntries)
                {
                    if (backgroundWorker1.CancellationPending == true)
                    {
                        e.Cancel = true;
                        return(ProjectSplitResult.Cancelled);
                    }
                    ProjectFunctions.SplitTemplateMDLEntry(splitMDL, progress, gamePath, projFolder);
                }
            }
            // Project folders for buildable PC games
            if (game == "SADXPC" || game == "SA2PC")
            {
                progress.SetTask("Finalizing Project Setup");
                makeProjectFolders(projFolder, progress, game);
                GenerateModFile(game, progress, projFolder, Path.GetFileNameWithoutExtension(projName));
                progress.StepProgress();
            }

            return(ProjectSplitResult.Success);
        }
예제 #6
0
        private void makeProjectFolders(string projFolder, SAModel.SAEditorCommon.UI.ProgressDialog progress, string game)
        {
            progress.StepProgress();
            progress.SetStep("Making Additional Mod Folders");
            string[] readMeSADX =
            {
                "Welcome to your new SADX Mod! The info below will assist with some additional folders created for your Mod.\n\n" +
                "Code - You can store your source Code here.\n" +
                "system - SADX's system folder. Store your textures (PVM) here. Stage object layouts are stored here as well.\n" +
                "textures - You can store PVMX and Texture Pack Archives here.\n\n" +
                "Please refer to the Help drop down in the SA Tools Hub for additional resources or you can reach members for help in the X-Hax Discord."
            };

            string[] readMeSA2PC =
            {
                "Welcome to your new SA2PC Mod! The info below will assist with some additional folders created for your Mod.\n\n" +
                "Code - You can store your source Code here.\n" +
                "gd_PC - SA2's system folder. Store your textures (GVM/PAK) here. Stage object layouts are stored here as well.\n\n" +
                "Please refer to the Help drop down in the SA Tools Hub for additional resources or you can reach members for help in the X-Hax Discord."
            };

            string systemPath;
            // Source Folder
            string sourceFolderPath = Path.Combine(projFolder, "Code");

            if (!Directory.Exists(sourceFolderPath))
            {
                Directory.CreateDirectory(sourceFolderPath);
            }

            // Game System Folder
            string projReadMePath = Path.Combine(projFolder, "ReadMe.txt");

            switch (game)
            {
            case ("SADXPC"):
                systemPath = Path.Combine(projFolder, "system");
                if (!Directory.Exists(systemPath))
                {
                    Directory.CreateDirectory(systemPath);
                }
                string texturesPath = Path.Combine(projFolder, "textures");
                if (!Directory.Exists(texturesPath))
                {
                    Directory.CreateDirectory(texturesPath);
                }

                File.WriteAllLines(projReadMePath, readMeSADX);
                break;

            case ("SA2PC"):
                systemPath = Path.Combine(projFolder, "gd_PC");
                if (!Directory.Exists(systemPath))
                {
                    Directory.CreateDirectory(systemPath);
                }
                File.WriteAllLines(projReadMePath, readMeSA2PC);
                break;

            default:
                break;
            }
        }