예제 #1
0
        public static void DisableTogglePack(string packName)
        {
            // Disable

            CustomWorldStructs.RegionPack pack = CustomWorldMod.installedPacks[packName];
            pack.activated = !pack.activated;
            CustomWorldMod.SerializePackInfoJSON(CRExtras.BuildPath(pack.folderName, CRExtras.CustomFolder.None, file: "packInfo.json"), pack);
            CustomWorldMod.LoadCustomWorldResources();
        }
예제 #2
0
        public void Init(string arguments, string executableName)
        {
            // Delete old folder
            if (CustomWorldMod.installedPacks.ContainsKey(this.packName))
            {
                string folderName       = CustomWorldMod.installedPacks[this.packName].folderName;
                string pathToPackFolder = CRExtras.BuildPath(folderName, CRExtras.CustomFolder.None);
                CustomWorldMod.Log($"Updating pack, check if folder exists at: [{pathToPackFolder}]...", false, CustomWorldMod.DebugLevel.MEDIUM);
                if (Directory.Exists(pathToPackFolder))
                {
                    try
                    {
                        Directory.Delete(pathToPackFolder, true);
                    }
                    catch (Exception e)
                    {
                        CustomWorldMod.Log(e.ToString(), true);
                    }
                }
            }

            base.Init();
            Log($"Executing console app [{executableName}]");

            ProcessStartInfo processStartInfo = new ProcessStartInfo(executableName, arguments);

            processStartInfo.UseShellExecute = false;
            processStartInfo.ErrorDialog     = false;
            processStartInfo.CreateNoWindow  = true;
            //processStartInfo.RedirectStandardInput = true;
            processStartInfo.RedirectStandardOutput = true;
            //processStartInfo.RedirectStandardError = true;


            // Start the process
            process           = new Process();
            process.StartInfo = processStartInfo;
            bool processStarted = process.Start();

            process.BeginOutputReadLine();

            captureOutput = new StringBuilder();
            process.OutputDataReceived += Process_OutputDataReceived;
        }