Ejemplo n.º 1
0
        void UpdateModLoader(string modName)
        {
            string modLoaderIniPath = Path.Combine(SAToolsHub.gameDirectory, modLoaderINI);

            switch (SAToolsHub.setGame)
            {
            case ("SADXPC"):
                SADXLoaderInfo dxLoaderIni = SplitTools.IniSerializer.Deserialize <SADXLoaderInfo>(modLoaderIniPath);

                if (!dxLoaderIni.Mods.Contains(modName))
                {
                    dxLoaderIni.Mods.Add(modName);
                }

                SplitTools.IniSerializer.Serialize(dxLoaderIni, modLoaderIniPath);
                break;

            case ("SA2PC"):
                SA2LoaderInfo sa2LoaderIni = SplitTools.IniSerializer.Deserialize <SA2LoaderInfo>(modLoaderIniPath);

                if (!sa2LoaderIni.Mods.Contains(modName))
                {
                    sa2LoaderIni.Mods.Add(modName);
                }

                SplitTools.IniSerializer.Serialize(sa2LoaderIni, modLoaderIniPath);
                break;
            }
        }
Ejemplo n.º 2
0
        private void PlayMod()
        {
            List <string> otherMods = new List <string>();

            string projectSettingsPath = Path.Combine(projectFolder, "ProjectSettings.ini");

            if (File.Exists(projectSettingsPath))
            {
                ProjectSettings projectSettings = SA_Tools.IniSerializer.Deserialize <ProjectSettings>(projectSettingsPath);
                foreach (string otherMod in projectSettings.OtherModsToRun)
                {
                    if (otherMod.Length == 0)
                    {
                        continue;                                           // skip empty mod entries/newlines
                    }
                    string otherModClean = System.Text.RegularExpressions.Regex.Replace(otherMod, @"\t\n\r", "");

                    string modIniPath = Path.Combine(Program.Settings.GetGamePath(game), string.Format("mods/{0}/mod.ini", otherModClean));

                    if (File.Exists(modIniPath))
                    {
                        otherMods.Add(otherMod);
                    }
                }
            }
            string modLoaderConfig = "";

            switch (game)
            {
            case SA_Tools.Game.SADX:
                modLoaderConfig = Path.Combine(Program.Settings.SADXPCPath, "mods/SADXModLoader.ini");

                SADXLoaderInfo sadxLoaderInfo = SA_Tools.IniSerializer.Deserialize <SADXLoaderInfo>(modLoaderConfig);

                sadxLoaderInfo.Mods.Clear();
                sadxLoaderInfo.Mods.Add(projectName);

                foreach (string otherMod in otherMods)
                {
                    string otherModClean = System.Text.RegularExpressions.Regex.Replace(otherMod, @"\t\n\r", "");

                    sadxLoaderInfo.Mods.Add(otherModClean);
                }

                SA_Tools.IniSerializer.Serialize(sadxLoaderInfo, modLoaderConfig);
                break;

            case SA_Tools.Game.SA2B:
                modLoaderConfig = Path.Combine(Program.Settings.SA2PCPath, "mods/SA2ModLoader.ini");

                SA2LoaderInfo sa2LoaderInfo = SA_Tools.IniSerializer.Deserialize <SA2LoaderInfo>(modLoaderConfig);
                sa2LoaderInfo.Mods.Clear();
                sa2LoaderInfo.Mods.Add(projectName);

                foreach (string otherMod in otherMods)
                {
                    sa2LoaderInfo.Mods.Add(otherMod);
                }

                SA_Tools.IniSerializer.Serialize(sa2LoaderInfo, modLoaderConfig);
                break;

            default:
                break;
            }

            string environmentDirectory = Environment.CurrentDirectory;

            string gameExecutable = Path.Combine(Program.Settings.GetGamePath(game), Program.Settings.GetExecutableForGame(game));

            Environment.CurrentDirectory = Path.GetDirectoryName(gameExecutable);

            System.Diagnostics.Process gameProcess = System.Diagnostics.Process.Start(gameExecutable);

            Environment.CurrentDirectory = environmentDirectory;             // restore the old directory in case any other code relies upon it
        }