private void RunVanilla()
        {
            Save(false);

            XCOM2.RunGame(Settings.GamePath, Settings.Arguments.ToString());

            if (Settings.CloseAfterLaunch)
            {
                Close();
            }
        }
        private void RunGame()
        {
            _updateWorker.CancelAsync();
            Save();

            XCOM2.RunGame(Settings.GamePath, Settings.Arguments.ToString());

            if (Settings.CloseAfterLaunch)
            {
                Close();
            }
        }
Exemple #3
0
        private void RunWotC()
        {
            _updateWorker.CancelAsync();
            Settings.Instance.LastLaunchedWotC = true;
            Save(true);

            XCOM2.RunWotC(Settings.GamePath, Settings.Arguments.ToString());

            if (Settings.CloseAfterLaunch)
            {
                Close();
            }
        }
Exemple #4
0
        private void RunChallengeMode()
        {
            _updateWorker.CancelAsync();
            Settings.Instance.LastLaunchedWotC = true;
            ChallengeMode = true;
            Save(true);

            XCOM2.RunWotC(Settings.GamePath, Settings.Arguments.ToLower().Replace("-allowconsole", ""));

            if (Settings.CloseAfterLaunch)
            {
                Close();
            }
        }
 private void Save(bool WotC)
 {
     try
     {
         XCOM2.SaveChanges(Settings, WotC, ChallengeMode);
         Settings.SaveFile("settings.json");
     }
     catch (Exception ex)
     {
         // lets report any issues that occur while writing the settings.json or the ini files
         Log.Warn("Failed so save/apply settings", ex);
         MessageBox.Show("An error occurred while saving changes." +
                         Environment.NewLine + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #6
0
        public static Settings InitializeSettings()
        {
            var firstRun = !File.Exists("settings.json");

            Settings settings;

            if (firstRun)
            {
                settings = new Settings();
            }

            else
            {
                try
                {
                    settings = Settings.FromFile("settings.json");
                }
                catch (JsonSerializationException)
                {
                    MessageBox.Show("settings.json could not be read.\r\nPlease delete or rename that file and try again.");
                    return(null);
                }
            }

            // Verify Game Path
            if (!Directory.Exists(settings.GamePath))
            {
                settings.GamePath = XCOM2.DetectGameDir();
            }

            if (settings.GamePath == "")
            {
                MessageBox.Show("Could not find XCOM 2 installation path. Please fill it manually in the settings.");
            }

            // Verify Mod Paths
            var oldPaths = settings.ModPaths.Where(modPath => !Directory.Exists(modPath)).ToList();

            foreach (var modPath in oldPaths)
            {
                settings.ModPaths.Remove(modPath);
            }

            foreach (var modPath in XCOM2.DetectModDirs())
            {
                if (!settings.ModPaths.Contains(modPath))
                {
                    settings.ModPaths.Add(modPath);
                }
            }


            if (settings.ModPaths.Count == 0)
            {
                MessageBox.Show("Could not find XCOM 2 mod directories. Please fill them in manually in the settings.");
            }

            if (settings.Mods.Entries.Count > 0)
            {
                // Verify categories
                var index = settings.Mods.Entries.Values.Max(c => c.Index);
                foreach (var cat in settings.Mods.Entries.Values.Where(c => c.Index == -1))
                {
                    cat.Index = ++index;
                }

                // Verify Mods
                foreach (var mod in settings.Mods.All.Where(mod => !settings.ModPaths.Any(mod.IsInModPath)))
                {
                    mod.State |= ModState.NotLoaded;
                }

                var brokenMods = settings.Mods.All.Where(m => !Directory.Exists(m.Path) || !File.Exists(m.GetModInfoFile())).ToList();
                if (brokenMods.Count > 0)
                {
                    MessageBox.Show($"{brokenMods.Count} mods no longer exists and have been removed:\r\n\r\n" + string.Join("\r\n", brokenMods.Select(m => m.Name)));

                    foreach (var m in brokenMods)
                    {
                        settings.Mods.RemoveMod(m);
                    }
                }
            }

            // import mods
            settings.ImportMods();

            return(settings);
        }
Exemple #7
0
        internal void RegisterEvents()
        {
            // Register Events
            // run buttons
            runXCOM2ToolStripMenuItem.Click          += (a, b) => { RunGame(); };
            runWarOfTheChosenToolStripMenuItem.Click += (a, b) => { RunWotC(); };
            runChallengeModeToolStripMenuItem.Click  += (a, b) => { RunChallengeMode(); };

            // save on close
            //Shown += MainForm_Shown;
            //FormClosing += MainForm_FormClosing;

            // Menu
            // -> File
            saveToolStripMenuItem.Click   += delegate { Save(Settings.Instance.LastLaunchedWotC); };
            reloadToolStripMenuItem.Click += delegate
            {
                // Confirmation dialog
                var r = MessageBox.Show("Unsaved changes will be lost.\r\nAre you sure?", "Reload mod list?", MessageBoxButtons.OKCancel);
                if (r != DialogResult.OK)
                {
                    return;
                }

                Reset();
            };
            searchForModsToolStripMenuItem.Click += delegate { Settings.ImportMods(); };
            updateEntriesToolStripMenuItem.Click += delegate
            {
                if (_updateWorker.IsBusy)
                {
                    return;
                }

                CheckSteamForUpdates();
            };
            // -> Settings
            // show hidden
            showHiddenModsToolStripMenuItem.Click += delegate
            {
                Settings.ShowHiddenElements = showHiddenModsToolStripMenuItem.Checked;
                olvcHidden.IsVisible        = showHiddenModsToolStripMenuItem.Checked;
                RefreshModList(true);
            };

            // Edit
            editOptionsToolStripMenuItem.Click += delegate
            {
                var result = new SettingsDialog(Settings).ShowDialog();

                if (result == DialogResult.OK)
                {
                    RefreshModList();
                    ShowQuickLaunchArgsBasedOnSettings();
                    showHiddenModsToolStripMenuItem.Checked = Settings.ShowHiddenElements;
                    NoRedscreensLaunchArgument.UpdateFromSettings();
                    LogLaunchArgument.UpdateFromSettings();
                }
            };

            manageCategoriesToolStripMenuItem.Click += ManageCategoriesToolStripMenuItem_Click;

            exitToolStripMenuItem.Click += (sender, e) => { Close(); };

            // -> Tools
            cleanModsToolStripMenuItem.Click        += delegate { new CleanModsForm(Settings).ShowDialog(); };
            importActiveModsToolStripMenuItem.Click += delegate
            {
                XCOM2.ImportActiveMods(Settings);
                RefreshModList();
            };

            resubscribeToModsToolStripMenuItem.Click += delegate
            {
                var modsToDownload = Mods.All.Where(m => m.State.HasFlag(ModState.NotInstalled) && m.Source == ModSource.SteamWorkshop).ToList();
                var choice         = false;

                if (modsToDownload.Count == 0)
                {
                    MessageBox.Show("No uninstalled workshop mods were found.");
                }
                else if (modsToDownload.Count == 1)
                {
                    choice = MessageBox.Show($"Are you sure you want to download the mod {modsToDownload[0].Name}?", "Confirm Download", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK;
                }
                else
                {
                    choice = MessageBox.Show($"Are you sure you want to download {modsToDownload.Count} mods?", "Confirm Download", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK;
                }

                if (choice)
                {
                    foreach (var m in modsToDownload)
                    {
                        Workshop.Subscribe((ulong)m.WorkshopID);
                        Workshop.DownloadItem((ulong)m.WorkshopID);
                    }
                    MessageBox.Show("Launch XCOM 2 after the download is finished in order to use the mod" + (modsToDownload.Count == 1 ? "." : "s."));
                }
            };

            // RichTextBox clickable links
            //modinfo_readme_RichTextBox.LinkClicked += ControlLinkClicked;
            //modinfo_info_DescriptionRichTextBox.LinkClicked += ControlLinkClicked;
            //export_richtextbox.LinkClicked += ControlLinkClicked;
            //modinfo_changelog_richtextbox.LinkClicked += ControlLinkClicked;

            // Tab Controls
            //main_tabcontrol.Selected += MainTabSelected;
            //modinfo_tabcontrol.Selected += ModInfoTabSelected;

            // Mod Updater
            _updateWorker.DoWork             += Updater_DoWork;
            _updateWorker.ProgressChanged    += Updater_ProgressChanged;
            _updateWorker.RunWorkerCompleted += Updater_RunWorkerCompleted;

            // Steam Events
            Workshop.OnItemDownloaded += Resubscribe_OnItemDownloaded;

#if DEBUG
            Workshop.OnItemDownloaded += SteamWorkshop_OnItemDownloaded;
#endif

            // Main Tabs
            // Export
            export_workshop_link_checkbox.CheckedChanged += ExportCheckboxCheckedChanged;
            export_group_checkbox.CheckedChanged         += ExportCheckboxCheckedChanged;
            export_save_button.Click += ExportSaveButtonClick;
            export_load_button.Click += ExportLoadButtonClick;
        }
        public static Settings InitializeSettings()
        {
            var firstRun = !File.Exists("settings.json");

            var settings = firstRun ? new Settings() : Settings.Instance;

            if (settings.ShowUpgradeWarning && !firstRun)
            {
                MessageBoxManager.Cancel = "Exit";
                MessageBoxManager.OK     = "Continue";
                MessageBoxManager.Register();
                var choice = MessageBox.Show(
                    "WARNING!!\n\nThis launcher is NOT COMPATIBLE with the old 'settings.json' file.\nStop NOW and launch the old version to export a profile of your mods WITH GROUPS!\nOnce that is done, move the old 'settings.json' file to a SAFE PLACE and then proceed.\nAfter loading, import the profile you saved to recover groups.\n\nIf you are not ready to do this, click 'Exit' to leave with no changes.",
                    "WARNING!", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2);
                if (choice == DialogResult.Cancel)
                {
                    Environment.Exit(0);
                }
                MessageBoxManager.Unregister();
            }
            settings.ShowUpgradeWarning = false;


            // Verify Game Path
            if (!Directory.Exists(settings.GamePath))
            {
                settings.GamePath = XCOM2.DetectGameDir();
            }

            if (settings.GamePath == "")
            {
                MessageBox.Show(@"Could not find XCOM 2 installation path. Please fill it manually in the settings.");
            }

            // Verify Mod Paths
            var pathsToEdit = settings.ModPaths.Where(m => !m.EndsWith("\\")).ToList();

            foreach (var modPath in pathsToEdit)
            {
                settings.ModPaths.Add(modPath + "\\");
                settings.ModPaths.Remove(modPath);
            }

            var oldPaths = settings.ModPaths.Where(modPath => !Directory.Exists(modPath)).ToList();

            foreach (var modPath in oldPaths)
            {
                settings.ModPaths.Remove(modPath);
            }

            foreach (var modPath in XCOM2.DetectModDirs())
            {
                if (!settings.ModPaths.Contains(modPath))
                {
                    if (!settings.ModPaths.Contains(modPath + "\\"))
                    {
                        settings.ModPaths.Add(modPath);
                    }
                }
            }


            if (settings.ModPaths.Count == 0)
            {
                MessageBox.Show(@"Could not find XCOM 2 mod directories. Please fill them in manually in the settings.");
            }

            if (settings.Mods.Entries.Count > 0)
            {
                // Verify categories
                var index = settings.Mods.Entries.Values.Max(c => c.Index);
                foreach (var cat in settings.Mods.Entries.Values.Where(c => c.Index == -1))
                {
                    cat.Index = ++index;
                }

                // Verify Mods
                foreach (var mod in settings.Mods.All)
                {
                    if (!settings.ModPaths.Any(mod.IsInModPath))
                    {
                        mod.State |= ModState.NotLoaded;
                    }
                    if (!Directory.Exists(mod.Path) || !File.Exists(mod.GetModInfoFile()))
                    {
                        mod.State |= ModState.NotInstalled;
                    }
                    // tags clean up
                    mod.Tags = mod.Tags.Where(t => settings.Tags.ContainsKey(t)).ToList();
                }

                var newlyBrokenMods = settings.Mods.All.Where(m => (m.State == ModState.NotLoaded || m.State == ModState.NotInstalled) && !m.isHidden).ToList();
                if (newlyBrokenMods.Count > 0)
                {
                    if (newlyBrokenMods.Count == 1)
                    {
                        FlexibleMessageBox.Show($"The mod '{newlyBrokenMods[0].Name}' no longer exists and has been hidden.");
                    }
                    else
                    {
                        FlexibleMessageBox.Show($"{newlyBrokenMods.Count} mods no longer exist and have been hidden:\r\n\r\n" + string.Join("\r\n", newlyBrokenMods.Select(m => m.Name)));
                    }

                    foreach (var m in newlyBrokenMods)
                    {
                        m.isHidden = true;
                    }
                    //settings.Mods.RemoveMod(m);
                }
            }

            // import mods
            settings.ImportMods();

            return(settings);
        }
 private void Save()
 {
     XCOM2.SaveChanges(Settings);
     Settings.SaveFile("settings.json");
 }
Exemple #10
0
 private void Save(bool WotC)
 {
     XCOM2.SaveChanges(Settings, WotC);
     Settings.SaveFile("settings.json");
 }
        internal void RegisterEvents()
        {
            // Register Events
            // run button
            runXCOM2ToolStripMenuItem.Click += (a, b) => { RunGame(); };

            // save on close
            //Shown += MainForm_Shown;
            //FormClosing += MainForm_FormClosing;

            // Menu
            // -> File
            saveToolStripMenuItem.Click   += delegate { Save(); };
            reloadToolStripMenuItem.Click += delegate
            {
                // Confirmation dialog
                var r = MessageBox.Show("Unsaved changes will be lost.\r\nAre you sure?", "Reload mod list?", MessageBoxButtons.OKCancel);
                if (r != DialogResult.OK)
                {
                    return;
                }

                Reset();
            };
            searchForModsToolStripMenuItem.Click += delegate { Settings.ImportMods(); };
            updateEntriesToolStripMenuItem.Click += delegate
            {
                if (_updateWorker.IsBusy)
                {
                    return;
                }

                CheckSteamForUpdates();
            };
            // -> Settings
            // show hidden
            showHiddenModsToolStripMenuItem.Click += delegate
            {
                Settings.ShowHiddenElements = showHiddenModsToolStripMenuItem.Checked;
                olvcHidden.IsVisible        = showHiddenModsToolStripMenuItem.Checked;
                RefreshModList();
            };

            // Edit
            editSettingsToolStripMenuItem.Click += delegate
            {
                new SettingsDialog(Settings).ShowDialog();
                RefreshModList();
            };

            exitToolStripMenuItem.Click += (sender, e) => { Close(); };

            // -> Tools
            cleanModsToolStripMenuItem.Click        += delegate { new CleanModsForm(Settings).ShowDialog(); };
            importActiveModsToolStripMenuItem.Click += delegate
            {
                XCOM2.ImportActiveMods(Settings);
                RefreshModList();
            };

            // RichTextBox clickable links
            //modinfo_readme_RichTextBox.LinkClicked += ControlLinkClicked;
            //modinfo_info_DescriptionRichTextBox.LinkClicked += ControlLinkClicked;
            //export_richtextbox.LinkClicked += ControlLinkClicked;
            //modinfo_changelog_richtextbox.LinkClicked += ControlLinkClicked;

            // Tab Controls
            //main_tabcontrol.Selected += MainTabSelected;
            //modinfo_tabcontrol.Selected += ModInfoTabSelected;

            // Mod Updater
            _updateWorker.DoWork             += Updater_DoWork;
            _updateWorker.ProgressChanged    += Updater_ProgressChanged;
            _updateWorker.RunWorkerCompleted += Updater_RunWorkerCompleted;

            // Steam Events
#if DEBUG
            Workshop.OnItemDownloaded += SteamWorkshop_OnItemDownloaded;
#endif

            // Main Tabs
            // Export
            export_workshop_link_checkbox.CheckedChanged += ExportCheckboxCheckedChanged;
            export_group_checkbox.CheckedChanged         += ExportCheckboxCheckedChanged;
            export_save_button.Click += ExportSaveButtonClick;
            export_load_button.Click += ExportLoadButtonClick;
        }
Exemple #12
0
        public static Settings InitializeSettings()
        {
            var firstRun = !File.Exists("settings.json");

            var settings = firstRun ? new Settings() : Settings.Instance;

            // Logic behind this:
            // If the field ShowUpgradeWarning doesn't exists in the loaded settings file; it will be initialized to its default value "true".
            // In that case, an old incompatible settings version is assumed and we report a warning.
            if (settings.ShowUpgradeWarning && !firstRun)
            {
                Log.Warn("Incompatible settings.json");

                MessageBoxManager.Cancel = "Exit";
                MessageBoxManager.OK     = "Continue";
                MessageBoxManager.Register();
                var choice = MessageBox.Show("This launcher version is NOT COMPATIBLE with the old 'settings.json' file.\n" +
                                             "Stop NOW and launch the old version to export a profile of your mods INCLUDING GROUPS!\n" +
                                             "Once that is done, move the old 'settings.json' file to a SAFE PLACE and then proceed.\n" +
                                             "After loading, import the profile you saved to recover groups.\n\n" +
                                             "If you are not ready to do this, click 'Exit' to leave with no changes.",
                                             "WARNING!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);

                if (choice == DialogResult.Cancel)
                {
                    Environment.Exit(0);
                }

                Log.Warn("User ignored incompatibility");
                MessageBoxManager.Unregister();
            }

            settings.ShowUpgradeWarning = false;

            // Verify Game Path
            if (!Directory.Exists(settings.GamePath))
            {
                settings.GamePath = XCOM2.DetectGameDir();
            }

            if (settings.GamePath == "")
            {
                Log.Warn("Unable to detect XCOM 2 installation path");
                MessageBox.Show(@"Could not find XCOM 2 installation path. Please fill it manually in the settings.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            // Make sure, that all mod paths have a trailing backslash
            var pathsWithMissingTrailingBackSlash = settings.ModPaths.Where(m => !m.EndsWith(@"\")).ToList();

            for (var i = 0; i < pathsWithMissingTrailingBackSlash.Count; i++)
            {
                pathsWithMissingTrailingBackSlash[i] += @"\";
            }

            // Check and potentially add new mod paths from XCOM ini file.
            var modPathsFromIni = XCOM2.DetectModDirs();

            if (modPathsFromIni != null)
            {
                settings.ModPaths.AddRange(modPathsFromIni.Where(modPath => !settings.ModPaths.Contains(modPath)));
            }
            else
            {
                MessageBox.Show("Unable to read mod directories from 'XComEngine.ini'. See file 'AML.log' for details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Remove obsolete mod paths
            settings.ModPaths.RemoveAll(modPath => !Directory.Exists(modPath));

            if (settings.ModPaths.Count == 0)
            {
                Log.Warn("No XCOM 2 mod directories configured");
                MessageBox.Show(@"Could not find XCOM 2 mod directories. Please fill them in manually in the settings.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (settings.Mods.Entries.Count > 0)
            {
                // Verify categories
                var index = settings.Mods.Entries.Values.Max(c => c.Index);
                foreach (var cat in settings.Mods.Entries.Values.Where(c => c.Index == -1))
                {
                    cat.Index = ++index;
                }

                // Verify Mods
                foreach (var mod in settings.Mods.All)
                {
                    if (!settings.ModPaths.Any(mod.IsInModPath))
                    {
                        Log.Warn($"The mod {mod.ID} is not located in any of the configured mod directories -> ModState.NotLoaded");
                        mod.AddState(ModState.NotLoaded);
                    }

                    if (!Directory.Exists(mod.Path))
                    {
                        Log.Warn($"The mod {mod.ID} is no longer available in the directory {mod.Path} -> ModState.NotInstalled");
                        mod.AddState(ModState.NotInstalled);
                    }
                    else if (!File.Exists(mod.GetModInfoFile()))
                    {
                        string newModInfo = settings.Mods.FindModInfo(mod.Path);
                        if (newModInfo != null)
                        {
                            mod.ID = Path.GetFileNameWithoutExtension(newModInfo);
                        }
                        else
                        {
                            Log.Warn($"The XComMod file for the mod {mod.ID} is missing -> ModState.NotInstalled");
                            mod.AddState(ModState.NotInstalled);
                        }
                    }

                    // tags clean up
                    mod.Tags = mod.Tags.Where(t => settings.Tags.ContainsKey(t.ToLower())).ToList();
                }

                var newlyBrokenMods = settings.Mods.All.Where(m => (m.State == ModState.NotLoaded || m.State == ModState.NotInstalled) && !m.isHidden).ToList();
                if (newlyBrokenMods.Count > 0)
                {
                    if (newlyBrokenMods.Count == 1)
                    {
                        FlexibleMessageBox.Show($"The mod '{newlyBrokenMods[0].Name}' no longer exists and has been hidden.");
                    }
                    else
                    {
                        FlexibleMessageBox.Show($"{newlyBrokenMods.Count} mods no longer exist and have been hidden:\r\n\r\n" + string.Join("\r\n", newlyBrokenMods.Select(m => m.Name)));
                    }

                    foreach (var m in newlyBrokenMods)
                    {
                        m.isHidden = true;
                    }
                }
            }

            // import mods
            settings.ImportMods();

            return(settings);
        }
        internal void RegisterEvents()
        {
            // Register Events
            // run buttons
            runXCOM2ToolStripMenuItem.Click          += (a, b) => { RunGame(); };
            runWarOfTheChosenToolStripMenuItem.Click += (a, b) => { RunWotC(); };
            runChallengeModeToolStripMenuItem.Click  += (a, b) => { RunChallengeMode(); };

            #region Menu->File

            saveToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->File->Save settings");
                Save(Settings.Instance.LastLaunchedWotC);
            };

            reloadToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->File->Reset settings");
                // Confirmation dialog
                var r = MessageBox.Show("Unsaved changes will be lost.\r\nAre you sure?", "Reload settings?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (r != DialogResult.OK)
                {
                    return;
                }

                Reset();
            };
            searchForModsToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->File->Search for new mods");
                Settings.ImportMods();
            };

            updateEntriesToolStripMenuItem.Click += delegate
            {
                if (_updateWorker.IsBusy)
                {
                    return;
                }

                Log.Info("Menu->File->Update mod info");
                CheckSteamForUpdates();
            };

            exitToolStripMenuItem.Click += (sender, e) =>
            {
                Log.Info("Menu->Close");
                Close();
            };

            #endregion Menu->File

            #region Menu->Options

            // show hidden
            showHiddenModsToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->File->Update mod info");
                Settings.ShowHiddenElements = showHiddenModsToolStripMenuItem.Checked;
                olvcHidden.IsVisible        = showHiddenModsToolStripMenuItem.Checked;
                RefreshModList(true);
            };

            // open Settings
            editOptionsToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->Options->Settings");
                var dialog = new SettingsDialog(Settings);

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    // refresh/update settings dependent functions
                    RefreshModList();
                    showHiddenModsToolStripMenuItem.Checked = Settings.ShowHiddenElements;
                    UpdateQuickArgumentsMenu();

                    if (dialog.IsRestartRequired)
                    {
                        appRestartPendingLabel.Visible = true;
                        MessageBox.Show("Some changes won't take effect, until after the application has been restarted.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            };

            manageCategoriesToolStripMenuItem.Click += ManageCategoriesToolStripMenuItem_Click;

            #endregion Menu->Options

            #region Menu->Tools

            // -> Tools
            cleanModsToolStripMenuItem.Click += delegate { new CleanModsForm(Settings).ShowDialog(); };

            importFromXCOM2ToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->Tools->Import vanilla");
                XCOM2.ImportActiveMods(Settings, false);
                RefreshModList();
            };

            importFromWotCToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->Tools->Import WotC");
                XCOM2.ImportActiveMods(Settings, true);
                RefreshModList();
            };

            resubscribeToModsToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->Tools->Resubscribe");
                var modsToDownload = Mods.All.Where(m => m.State.HasFlag(ModState.NotInstalled) && m.Source == ModSource.SteamWorkshop).ToList();
                var choice         = false;

                if (modsToDownload.Count == 0)
                {
                    MessageBox.Show("No uninstalled workshop mods were found.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (modsToDownload.Count == 1)
                {
                    choice = MessageBox.Show($"Are you sure you want to download the mod {modsToDownload[0].Name}?", "Confirm Download", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK;
                }
                else
                {
                    choice = MessageBox.Show($"Are you sure you want to download {modsToDownload.Count} mods?", "Confirm Download", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK;
                }

                if (choice)
                {
                    foreach (var m in modsToDownload)
                    {
                        Log.Info("Subscribe and download " + m.ID);
                        Workshop.Subscribe((ulong)m.WorkshopID);
                        Workshop.DownloadItem((ulong)m.WorkshopID);
                    }

                    MessageBox.Show("Launch XCOM 2 after the download is finished in order to use the mod" + (modsToDownload.Count == 1 ? "." : "s."), "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            };

            #endregion Menu->Tools

            #region Menu->About

            infoToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->About->About");
                AboutBox about = new AboutBox();
                about.ShowDialog();
            };

            checkForUpdatesToolStripMenuItem.Click += delegate
            {
                Log.Info("Menu->About->Check Update");

                if (!Program.CheckForUpdate())
                {
                    MessageBox.Show("No updates available", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            };

            openHomepageToolStripMenuItem.Click += delegate { Tools.StartProcess(@"https://github.com/X2CommunityCore/xcom2-launcher"); };

            amlWikiToolStripMenuItem.Click += delegate { Tools.StartProcess(@"https://github.com/X2CommunityCore/xcom2-launcher/wiki"); };

            openDiscordToolStripMenuItem.Click += delegate { Tools.StartProcess(@"https://discord.gg/QHSVGRn"); };

            #endregion

            // RichTextBox clickable links
            //modinfo_readme_RichTextBox.LinkClicked += ControlLinkClicked;
            //modinfo_info_DescriptionRichTextBox.LinkClicked += ControlLinkClicked;
            //export_richtextbox.LinkClicked += ControlLinkClicked;
            //modinfo_changelog_richtextbox.LinkClicked += ControlLinkClicked;

            // Tab Controls
            //main_tabcontrol.Selected += MainTabSelected;
            //modinfo_tabcontrol.Selected += ModInfoTabSelected;

            // Mod Updater
            _updateWorker.DoWork             += Updater_DoWork;
            _updateWorker.ProgressChanged    += Updater_ProgressChanged;
            _updateWorker.RunWorkerCompleted += Updater_RunWorkerCompleted;

            // Steam Events
            Workshop.OnItemDownloaded += Resubscribe_OnItemDownloaded;

#if DEBUG
            Workshop.OnItemDownloaded += SteamWorkshop_OnItemDownloaded;
#endif

            // Main Tabs
            // Export
            export_workshop_link_checkbox.CheckedChanged += ExportCheckboxCheckedChanged;
            export_group_checkbox.CheckedChanged         += ExportCheckboxCheckedChanged;
            export_save_button.Click += ExportSaveButtonClick;
            export_load_button.Click += ExportLoadButtonClick;
        }