Example #1
0
 private void LoadINIFile(string fileName)
 {
     iniData = StructConverter.LoadINI(fileName, ref itemsToExport);
     UpdateListView();
 }
Example #2
0
        private void AutoBuild(Action showProgress, Action <string> updateProgress)
        {
            showProgress();

            Dictionary <string, SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType> assemblies =
                new Dictionary <string, SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType>();

            string modFolder = Path.Combine(Program.Settings.GetModPathForGame(game),
                                            projectName);

            Directory.CreateDirectory(modFolder);

            updateProgress("Getting Assemblies");
            switch (game)
            {
            case SA_Tools.Game.SADX:
                List <String> sadxAssemblyNames = GetSADXAssemblyNames();

                // check for chrmodels or chrmodels_orig
                string chrmodels     = "chrmodels";
                string chrmodelsOrig = "chrmodels_orig";

                string chrmodelsCompletePath     = Path.Combine(projectFolder, chrmodels + "_data.ini");
                string chrmodelsOrigCompletePath = Path.Combine(projectFolder, chrmodelsOrig + "_data.ini");

                if (File.Exists(chrmodelsCompletePath))
                {
                    sadxAssemblyNames.Add(chrmodels);
                }
                else
                {
                    sadxAssemblyNames.Add(chrmodelsOrig);
                }

                assemblies.Add("sonic", SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType.Exe);

                foreach (string assemblyName in sadxAssemblyNames)
                {
                    assemblies.Add(assemblyName, SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType.DLL);
                }
                break;

            case SA_Tools.Game.SA2B:
                // dll
                assemblies.Add("Data_DLL_orig", SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType.DLL);

                // exe
                assemblies.Add("sonic2app", SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType.Exe);
                break;

            default:
                break;
            }

            // export only the modified items in each assembly
            updateProgress("Exporting Assembies");

            foreach (KeyValuePair <string, SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType> assembly in
                     assemblies)
            {
                string iniPath = Path.Combine(projectFolder, assembly.Key + "_data.ini");

                Dictionary <string, bool> itemsToExport = new Dictionary <string, bool>();

                switch (assembly.Value)
                {
                case SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType.Exe:
                    SA_Tools.IniData iniData = SonicRetro.SAModel.SAEditorCommon.StructConverter.StructConverter.LoadINI(iniPath, ref itemsToExport);

                    SonicRetro.SAModel.SAEditorCommon.StructConverter.StructConverter.ExportINI(iniData,
                                                                                                itemsToExport, Path.Combine(modFolder, assembly.Key + "_data.ini"));
                    break;

                case SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType.DLL:
                    SA_Tools.SplitDLL.DllIniData dllIniData =
                        SonicRetro.SAModel.SAEditorCommon.DLLModGenerator.DLLModGen.LoadINI(iniPath, ref itemsToExport);

                    SonicRetro.SAModel.SAEditorCommon.DLLModGenerator.DLLModGen.ExportINI(dllIniData,
                                                                                          itemsToExport, Path.Combine(modFolder, assembly.Key + "_data.ini"));
                    break;

                default:
                    break;
                }
            }

            // copy system folder
            updateProgress("Copying System Folder");
            CopySystemFolder(modFolder);

            // generate final mod.ini based off of one in project folder
            updateProgress("Creating Mod.ini");

            string       baseModIniPath   = Path.Combine(projectFolder, "mod.ini");
            string       outputModIniPath = Path.Combine(modFolder, "mod.ini");
            const string dataSuffix       = "_data.ini";

            switch (game)
            {
            case SA_Tools.Game.SADX:
                SADXModInfo sadxModInfo = SA_Tools.IniSerializer.Deserialize <SADXModInfo>(baseModIniPath);

                // set all of our assemblies properly
                string ADV00MODELS               = "ADV00MODELS";
                string ADV01CMODELS              = "ADV01CMODELS";
                string ADV01MODELS               = "ADV01MODELS";
                string ADV02MODELS               = "ADV02MODELS";
                string ADV03MODELS               = "ADV03MODELS";
                string BOSSCHAOS0MODELS          = "BOSSCHAOS0MODELS";
                string CHAOSTGGARDEN02MR_DAYTIME = "CHAOSTGGARDEN02MR_DAYTIME";
                string CHAOSTGGARDEN02MR_EVENING = "CHAOSTGGARDEN02MR_EVENING";
                string CHAOSTGGARDEN02MR_NIGHT   = "CHAOSTGGARDEN02MR_NIGHT";

                if (assemblies.ContainsKey(ADV00MODELS))
                {
                    sadxModInfo.ADV00MODELSData = ADV00MODELS + dataSuffix;
                }
                if (assemblies.ContainsKey(ADV01CMODELS))
                {
                    sadxModInfo.ADV01CMODELSData = ADV01CMODELS + dataSuffix;
                }
                if (assemblies.ContainsKey(ADV01MODELS))
                {
                    sadxModInfo.ADV01MODELSData = ADV01MODELS + dataSuffix;
                }
                if (assemblies.ContainsKey(ADV02MODELS))
                {
                    sadxModInfo.ADV02MODELSData = ADV02MODELS + dataSuffix;
                }
                if (assemblies.ContainsKey(ADV03MODELS))
                {
                    sadxModInfo.ADV03MODELSData = ADV03MODELS + dataSuffix;
                }
                if (assemblies.ContainsKey(BOSSCHAOS0MODELS))
                {
                    sadxModInfo.BOSSCHAOS0MODELSData = BOSSCHAOS0MODELS + dataSuffix;
                }
                if (assemblies.ContainsKey(CHAOSTGGARDEN02MR_DAYTIME))
                {
                    sadxModInfo.CHAOSTGGARDEN02MR_DAYTIMEData = CHAOSTGGARDEN02MR_DAYTIME + dataSuffix;
                }
                if (assemblies.ContainsKey(CHAOSTGGARDEN02MR_EVENING))
                {
                    sadxModInfo.CHAOSTGGARDEN02MR_EVENINGData = CHAOSTGGARDEN02MR_EVENING + dataSuffix;
                }
                if (assemblies.ContainsKey(CHAOSTGGARDEN02MR_NIGHT))
                {
                    sadxModInfo.CHAOSTGGARDEN02MR_NIGHTData = CHAOSTGGARDEN02MR_NIGHT + dataSuffix;
                }
                if (assemblies.ContainsKey("sonic"))
                {
                    sadxModInfo.EXEData = "sonic_data.ini";
                }

                // save our output
                SA_Tools.IniSerializer.Serialize(sadxModInfo, outputModIniPath);
                break;

            case SA_Tools.Game.SA2B:
                SA2ModInfo sa2ModInfo = SA_Tools.IniSerializer.Deserialize <SA2ModInfo>(baseModIniPath);

                if (assemblies.ContainsKey("Data_DLL_orig"))
                {
                    sa2ModInfo.DLLData = "Data_DLL_orig" + dataSuffix;
                }
                if (assemblies.ContainsKey("sonic2app"))
                {
                    sa2ModInfo.EXEData = "sonic2app_data.ini";
                }

                // save our output
                SA_Tools.IniSerializer.Serialize(sa2ModInfo, outputModIniPath);
                break;

            default:
                break;
            }

            // execute our post-build script
            string projectSettingsPath = Path.Combine(projectFolder, "ProjectSettings.ini");

            if (File.Exists(projectSettingsPath))
            {
                ProjectSettings projectSettings = SA_Tools.IniSerializer.Deserialize <ProjectSettings>(projectSettingsPath);

                string storedEnvironmentDirectory = Environment.CurrentDirectory;

                if (File.Exists(projectSettings.PostBuildScript))
                {
                    System.Diagnostics.ProcessStartInfo procStartInfo =
                        new System.Diagnostics.ProcessStartInfo(projectSettings.PostBuildScript);

                    System.Diagnostics.Process process = System.Diagnostics.Process.Start(procStartInfo);

                    while (!process.HasExited)
                    {
                        System.Threading.Thread.Sleep(100);
                    }

                    Environment.CurrentDirectory = storedEnvironmentDirectory;
                }
            }
        }
Example #3
0
        void genAssemblies()
        {
            SA_Tools.IniData             EXEiniData       = new SA_Tools.IniData();
            SA_Tools.SplitDLL.DllIniData DLLiniData       = new SA_Tools.SplitDLL.DllIniData();
            Dictionary <string, bool>    itemsEXEToExport = new Dictionary <string, bool>();
            Dictionary <string, bool>    itemsDLLToExport = new Dictionary <string, bool>();

            foreach (KeyValuePair <string, SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType> assembly in assemblies)
            {
                string iniPath = Path.Combine(SAToolsHub.projectDirectory.ToString(), assembly.Key + "_data.ini");

                Dictionary <string, bool> itemsToExport = new Dictionary <string, bool>();

                switch (assembly.Value)
                {
                case SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType.Exe:
                    iniEXEFiles.Add(iniPath);
                    break;

                case SonicRetro.SAModel.SAEditorCommon.ManualBuildWindow.AssemblyType.DLL:
                    if (SAToolsHub.setGame == "SA2PC")
                    {
                        iniDLLFiles.Add(iniPath);
                    }
                    else
                    {
                        SA_Tools.SplitDLL.DllIniData dllIniData =
                            SonicRetro.SAModel.SAEditorCommon.DLLModGenerator.DLLModGen.LoadINI(iniPath, ref itemsToExport);

                        SonicRetro.SAModel.SAEditorCommon.DLLModGenerator.DLLModGen.ExportINI(dllIniData,
                                                                                              itemsToExport, Path.Combine(modFolder, assembly.Key + "_data.ini"));
                    }
                    break;

                default:
                    break;
                }
            }

            if (iniEXEFiles.Count > 0)
            {
                EXEiniData = SonicRetro.SAModel.SAEditorCommon.StructConverter.StructConverter.LoadMultiINI(iniEXEFiles, ref itemsEXEToExport);

                SonicRetro.SAModel.SAEditorCommon.StructConverter.StructConverter.ExportINI(EXEiniData,
                                                                                            itemsEXEToExport, Path.Combine(modFolder, gameEXE + "_data.ini"));
            }

            if (iniDLLFiles.Count > 0)
            {
                DLLiniData = SonicRetro.SAModel.SAEditorCommon.DLLModGenerator.DLLModGen.LoadMultiINI(iniDLLFiles, ref itemsDLLToExport);

                SonicRetro.SAModel.SAEditorCommon.DLLModGenerator.DLLModGen.ExportINI(DLLiniData,
                                                                                      itemsDLLToExport, Path.Combine(modFolder, "Data_DLL_orig_data.ini"));
            }

            if (sa2MdlMtnFiles.Count > 0)
            {
                string filePath;

                if (Directory.Exists(Path.Combine(SAToolsHub.projectDirectory, "figure\\bin")))
                {
                    filePath = Path.Combine(SAToolsHub.projectDirectory, "figure\\bin");
                }
                else
                {
                    filePath = Path.Combine(SAToolsHub.projectDirectory, "resource/gd_PC");
                }

                foreach (string folder in sa2MdlMtnFiles)
                {
                    string file = Path.Combine(filePath, folder);
                    if (file.Contains("mdl"))
                    {
                        sa2MDL.Build(true, file);
                    }
                    if (file.Contains("mtn"))
                    {
                        sa2MTN.Build(true, file);
                    }
                }
            }
        }