Example #1
0
        private void GenerateModFile(string game, SonicRetro.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"));

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

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

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

            default:
                break;
            }
        }
Example #2
0
        // TODO: newProj - Swap to using Async instead of Background Worker?
        #region Background Worker
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            using (splitProgress = new SonicRetro.SAModel.SAEditorCommon.UI.ProgressDialog("Creating project"))
            {
                Invoke((Action)splitProgress.Show);

                splitGame(gameName, splitProgress);

                Invoke((Action)splitProgress.Close);
            }
        }
Example #3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            using (SonicRetro.SAModel.SAEditorCommon.UI.ProgressDialog progress = new SonicRetro.SAModel.SAEditorCommon.UI.ProgressDialog("Building Project"))
            {
                Action showProgress = () =>
                {
                    Invoke((Action)progress.Show);
                };

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

                AutoBuild(showProgress, stepProgress);
            }
        }
Example #4
0
        private void splitMdlFiles(Templates.SplitEntryMDL splitMDL, SonicRetro.SAModel.SAEditorCommon.UI.ProgressDialog progress, string gameFolder, string outputFolder)
        {
            string filePath         = Path.Combine(gameFolder, splitMDL.ModelFile);
            string fileOutputFolder = Path.Combine(outputFolder, "figure\\bin");

            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

            sa2MDL.Split(splitMDL.BigEndian, filePath,
                         fileOutputFolder, splitMDL.MotionFiles.ToArray());
        }
Example #5
0
        void splitGame(string game, SonicRetro.SAModel.SAEditorCommon.UI.ProgressDialog progress)
        {
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            string iniFolder;

            progress.SetMaxSteps(setProgressMaxStep());

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

            progress.SetTask("Splitting Game Content");
            foreach (Templates.SplitEntry splitEntry in splitEntries)
            {
                splitFiles(splitEntry, progress, gamePath, iniFolder, projFolder);
            }

            switch (game)
            {
            case "SADXPC":
                progress.SetTask("Finalizing Moddable Project Setup");
                makeProjectFolders(projFolder, progress, gameName);
                progress.StepProgress();
                progress.SetStep("Copying Object Definitions");
                string objdefsPath       = GetObjDefsDirectory();
                string outputObjdefsPath = Path.Combine(projFolder, "objdefs");
                if (Directory.Exists(objdefsPath))
                {
                    CopyFolder(objdefsPath, outputObjdefsPath);
                    File.Copy(Path.Combine(iniFolder, "sadxlvl.ini"), Path.Combine(projFolder, "sadxlvl.ini"));
                    File.Copy(Path.Combine(iniFolder, "objdefs.ini"), Path.Combine(projFolder, "objdefs.ini"));
                }
                else
                {
                    MessageBox.Show(("Path to objdefs is missing\n\nPress OK to abort."), "Split Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    throw new Exception(SplitERRORVALUE.UnhandledException.ToString());
                }
                break;

            case "SA2PC":
                if (splitMdlEntries.Count > 0)
                {
                    progress.SetTask("Splitting Character Models");
                    foreach (Templates.SplitEntryMDL splitMDL in splitMdlEntries)
                    {
                        splitMdlFiles(splitMDL, progress, gamePath, projFolder);
                    }
                }

                break;
            }
            if (game == "SADXPC" || game == "SA2PC")
            {
                progress.SetTask("Finalizing Project Setup");
                makeProjectFolders(projFolder, progress, game);
                GenerateModFile(game, progress, projFolder, Path.GetFileNameWithoutExtension(projName));
            }
        }
Example #6
0
        private void splitFiles(Templates.SplitEntry splitData, SonicRetro.SAModel.SAEditorCommon.UI.ProgressDialog progress, string gameFolder, string iniFolder, string outputFolder)
        {
            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 ("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;
            }

            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(SA_Tools.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(SA_Tools.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":
                SA_Tools.SplitDLL.SplitDLL.SplitDLLFile(datafilename, inifilename, projectFolderName);
                break;

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

            default:
                SA_Tools.Split.Split.SplitFile(datafilename, inifilename, projectFolderName);
                break;
            }
        }
Example #7
0
        private void makeProjectFolders(string projFolder, SonicRetro.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;
            }
        }