Show() public static method

public static Show ( string WindowTitle, string ProgressText, System.Action WorkerFunction ) : void
WindowTitle string
ProgressText string
WorkerFunction System.Action
return void
Beispiel #1
0
        private void SavePreset()
        {
            SaveFileDialog savePreset = new SaveFileDialog();

            savePreset.Filter = "MGSV Preset File|*.MGSVPreset";
            DialogResult saveResult = savePreset.ShowDialog();

            if (saveResult != DialogResult.OK)
            {
                return;
            }

            string presetPath = savePreset.FileName;

            log.ClearPage();
            SetVisiblePage(log);
            bool success = false;

            ProgressWindow.Show("Saving Preset", "Saving Preset, please wait...", new Action((MethodInvoker) delegate { success = PresetManager.SavePreset(presetPath); }), log);
            if (success)
            {
                MessageBox.Show(string.Format("'{0}' Saved.", Path.GetFileName(presetPath)), "Preset Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            RefreshInstalledMods(true);
        }
Beispiel #2
0
        /// <summary>
        /// command-line install.
        /// </summary>
        internal void ProcessInstallMod(List <string> installPaths, bool skipConflictChecks, bool skipCleanup)
        {
            List <string> InstallFileList = new List <string>();

            foreach (string installModPath in installPaths)
            {
                if (File.Exists(installModPath) && installModPath.Contains(".mgsv"))
                {
                    InstallFileList.Add(installModPath);
                }
                else
                {
                    if (Directory.Exists(installModPath))
                    {
                        var folderFiles = Directory.GetFiles(installModPath, "*.mgsv");
                        foreach (string mgsv in folderFiles)
                        {
                            InstallFileList.Add(mgsv);
                        }
                        if (InstallFileList.Count == 0)
                        {
                            Debug.LogLine($"[Install] Could not find any .mgsv files in {installModPath}.", Debug.LogLevel.Basic);
                        }
                        InstallFileList.Sort();
                    }
                    else
                    {
                        Debug.LogLine($"[Install] Could not find file or directory {installModPath}.", Debug.LogLevel.Basic);
                    }
                }
            }
            if (InstallFileList.Count == 0)
            {
                Debug.LogLine($"[Install] Could not find any .mgsv files in installPaths.", Debug.LogLevel.Basic);
                return;
            }
            if (!skipConflictChecks)
            {
                foreach (string modPath in InstallFileList)
                {
                    if (!PreinstallManager.CheckConflicts(modPath))
                    {
                        return;
                    }
                }
            }
            string displayPath = InstallFileList[0];

            if (InstallFileList.Count > 1)
            {
                displayPath = $"{displayPath} and {InstallFileList.Count} mods";
            }
            ProgressWindow.Show("Installing Mod", $"Installing {displayPath}...",
                                new Action((MethodInvoker) delegate { InstallManager.InstallMods(InstallFileList, skipCleanup); }
                                           ), log);
            this.Invoke((MethodInvoker) delegate { RefreshInstalledMods(); });
        }
Beispiel #3
0
 private void picModToggle_Click(object sender, EventArgs e)
 {
     if (BackupManager.ModsDisabled())
     {
         ProgressWindow.Show("Working", "Enabling mods, please wait...", new Action(BackupManager.SwitchToMods), log);
     }
     else
     {
         ProgressWindow.Show("Working", "Disabling mods, please wait...", new Action(BackupManager.SwitchToOriginal), log);
     }
     UpdateModToggle();
 }
Beispiel #4
0
        public void ProcessUninstallMod(ModEntry mod)// command-line uninstall. This checks the mod it was passed, and puts it in a 1-item list to be uninstalled.
        {
            for (int i = 0; i < listInstalledMods.Items.Count; i++)
            {
                listInstalledMods.SetItemCheckState(i, CheckState.Unchecked);
            }
            var mods = manager.GetInstalledMods();

            listInstalledMods.SetItemCheckState(mods.IndexOf(mod), CheckState.Checked);
            CheckedListBox.CheckedIndexCollection checkedModIndex = listInstalledMods.CheckedIndices;
            ProgressWindow.Show("Uninstalling Mod", "Uninstalling...", new Action((MethodInvoker) delegate { ModManager.UninstallMod(checkedModIndex); }));
        }
Beispiel #5
0
 private void picModToggle_Click(object sender, EventArgs e)
 {
     if (BackupManager.ModsDisabled())
     {
         ProgressWindow.Show("Working", "Enabling mods, please wait...", new Action(BackupManager.SwitchToMods));
     }
     else
     {
         ProgressWindow.Show("Working", "Disabling mods, please wait...\n\nNote:\n You will not have access to the Mod Menu\nwhile mods are disabled.", new Action(BackupManager.SwitchToOriginal));
     }
     UpdateModToggle();
 }
Beispiel #6
0
        /// <summary>
        /// command-line install.
        /// </summary>
        internal void ProcessInstallMod(string installModPath, bool skipConflictChecks, bool skipCleanup)
        {
            List <string> InstallFileList = null;

            if (File.Exists(installModPath) && installModPath.Contains(".mgsv"))
            {
                InstallFileList = new List <string> {
                    installModPath
                };
            }
            else
            {
                if (Directory.Exists(installModPath))
                {
                    InstallFileList = Directory.GetFiles(installModPath, "*.mgsv").ToList();
                    if (InstallFileList.Count == 0)
                    {
                        Debug.LogLine($"[Install] Could not find any .mgsv files in {installModPath}.", Debug.LogLevel.Basic);
                        return;
                    }
                }
                else
                {
                    Debug.LogLine($"[Install] Could not find file or directory {installModPath}.", Debug.LogLevel.Basic);
                    return;
                }
            }
            if (InstallFileList == null)
            {
                return;
            }
            if (!skipConflictChecks)
            {
                foreach (string modPath in InstallFileList)
                {
                    if (!PreinstallManager.CheckConflicts(modPath))
                    {
                        return;
                    }
                }
            }
            ProgressWindow.Show("Installing Mod", $"Installing {installModPath}...",
                                new Action((MethodInvoker) delegate { InstallManager.InstallMods(InstallFileList, skipCleanup); }
                                           ), log);
            this.Invoke((MethodInvoker) delegate { RefreshInstalledMods(); });
        }
Beispiel #7
0
        public void ProcessInstallMod(string ModFile, bool ignoreConflicts = false)
        {
            var metaData = Tools.ReadMetaData(ModFile);

            if (metaData == null)
            {
                return;
            }

            if (!ModManager.CheckConflicts(ModFile, ignoreConflicts))
            {
                return;
            }

            ProgressWindow.Show("Installing Mod", String.Format("Installing {0}, please wait...", metaData.Name), new Action((MethodInvoker) delegate { ModManager.InstallMod(ModFile); }));

            this.Invoke((MethodInvoker) delegate { RefreshInstalledMods(); });
        }
Beispiel #8
0
        //TODO: not enough info in ModEntry to match uninstall using passed in filename
        public void ProcessUninstallMod(List <string> modPaths, bool skipcleanup)// command-line uninstall using list of mod names
        {
            for (int i = 0; i < listInstalledMods.Items.Count; i++)
            {
                listInstalledMods.SetItemCheckState(i, CheckState.Unchecked);
            }

            var mods = manager.GetInstalledMods();

            foreach (string modPath in modPaths)
            {
                ModEntry mod = mods.FirstOrDefault(entry => entry.Name == modPath); // select mod
                if (mod != null)
                {
                    listInstalledMods.SetItemCheckState(mods.IndexOf(mod), CheckState.Checked);
                }
            }
            CheckedListBox.CheckedIndexCollection checkedModIndices = listInstalledMods.CheckedIndices;
            ProgressWindow.Show("Uninstalling Mod", "Uninstalling...", new Action((MethodInvoker) delegate { UninstallManager.UninstallMods(checkedModIndices, skipcleanup); }), log);
        }
Beispiel #9
0
        private void buttonUninstall_Click(object sender, EventArgs e) //sends checked indices to ModManager for uninstallation.
        {
            // Get the indices of all checked mods, and their names.
            CheckedListBox.CheckedIndexCollection checkedModIndices = listInstalledMods.CheckedIndices;
            CheckedListBox.CheckedItemCollection  checkedModItems   = listInstalledMods.CheckedItems;
            string markedModNames = "";

            foreach (object mod in checkedModItems)
            {
                markedModNames += "\n" + mod.ToString();
            }
            if (!(MessageBox.Show("The following mods will be uninstalled:\n" + markedModNames, "SnakeBite", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK))
            {
                return;
            }

            ProgressWindow.Show("Uninstalling Mod(s)", "Uninstalling...\n\nNote:\nThe uninstall time depends greatly on\nthe mod's contents, the number of mods being uninstalled\nand the mods that are still installed.", new Action((MethodInvoker) delegate { ModManager.UninstallMod(checkedModIndices); }));
            // Update installed mod list
            RefreshInstalledMods(true);
        }
Beispiel #10
0
        private void buttonUninstall_Click(object sender, EventArgs e) //sends checked indices to ModManager for uninstallation.
        {
            // Get the indices of all checked mods, and their names.
            CheckedListBox.CheckedIndexCollection checkedModIndices = listInstalledMods.CheckedIndices;
            CheckedListBox.CheckedItemCollection  checkedModItems   = listInstalledMods.CheckedItems;
            string markedModNames = "";

            foreach (object mod in checkedModItems)
            {
                markedModNames += "\n" + mod.ToString();
            }
            if (!(MessageBox.Show("The following mods will be uninstalled:\n" + markedModNames, "SnakeBite", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK))
            {
                return;
            }
            log.ClearPage();
            SetVisiblePage(log);
            ProgressWindow.Show("Uninstalling Mod(s)", "Uninstalling, please wait...", new Action((MethodInvoker) delegate { UninstallManager.UninstallMods(checkedModIndices); }), log);

            RefreshInstalledMods(true);
        }
Beispiel #11
0
        internal void ProcessInstallMod(string installFile, bool skipCleanup)// command-line install.
        {
            var metaData = Tools.ReadMetaData(installFile);

            if (metaData == null)
            {
                return;
            }
            List <string> InstallFileList = new List <string>();

            InstallFileList.Add(installFile);

            if (!PreinstallManager.CheckConflicts(installFile))
            {
                return;
            }

            ProgressWindow.Show("Installing Mod", String.Format("Installing {0}...", metaData.Name), new Action((MethodInvoker) delegate { ModManager.InstallMod(InstallFileList, skipCleanup); }));

            this.Invoke((MethodInvoker) delegate { RefreshInstalledMods(); });
        }
Beispiel #12
0
        private void menuItemLoadPreset_Click(object sender, EventArgs e)
        {
            OneTimePresetHelp();

            /* This might be useful but I'm worried that the user might mistake the prompt and end up overwriting the preset that they wanted to load
             * DialogResult saveModsResult = MessageBox.Show("Would you like to save your current mods as a Preset before loading a new Preset?", "Save current mods?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
             * if (saveModsResult == DialogResult.Yes) SavePreset();
             * else if (saveModsResult == DialogResult.Cancel) return;
             */
            OpenFileDialog getPresetFile = new OpenFileDialog();

            getPresetFile.Filter      = "MGSV Preset File|*.MGSVPreset|All Files|*.*";
            getPresetFile.Multiselect = true;

            DialogResult getPresetResult = getPresetFile.ShowDialog();

            if (getPresetResult != DialogResult.OK)
            {
                return;
            }
            string   presetPath     = getPresetFile.FileName;
            Settings presetSettings = PresetManager.ReadSnakeBiteSettings(presetPath);

            bool success = false;

            try
            {
                if (!PresetManager.isPresetUpToDate(presetSettings))
                {
                    if (MessageBox.Show(string.Format("This Preset file is intended for Game Version {0}, but your current Game Version is {1}. Loading this preset will likely cause crashes, infinite loading screens or other significant problems in-game.", presetSettings.MGSVersion.AsVersion(), ModManager.GetMGSVersion()) +
                                        "\n\nAre you sure you want to load this preset?", "Preset Version Mismatch", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                string modsToInstall = "This Preset will contain the following mods:\n";
                if (presetSettings.ModEntries.Count != 0)
                {
                    foreach (var mod in presetSettings.ModEntries)
                    {
                        modsToInstall += string.Format("\n{0}", mod.Name);
                    }
                }
                else
                {
                    modsToInstall += "\n[NONE]";
                }
                if (MessageBox.Show(modsToInstall, "Install Preset", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
                log.ClearPage();
                SetVisiblePage(log);
                ProgressWindow.Show("Loading Preset", "Loading Preset, please wait...", new Action((MethodInvoker) delegate { success = PresetManager.LoadPreset(presetPath); }), log);
            }
            catch (Exception f)
            {
                MessageBox.Show("An error has occurred and the .MGSVPreset could not be loaded. Maybe the Preset file was packed improperly, or is being used by another program?\nException: " + f);
                success = false;
            }
            RefreshInstalledMods(true);
            if (success)
            {
                MessageBox.Show(string.Format("'{0}' Loaded", Path.GetFileName(presetPath)), "Preset Loaded", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #13
0
 public void ProcessUninstallMod(ModEntry mod)
 {
     ProgressWindow.Show("Uninstalling Mod", String.Format("Uninstalling {0}, please wait...", mod.Name), new Action((MethodInvoker) delegate { ModManager.UninstallMod(mod); }));
 }