internal void RegisterEvents() { // Register Events // run buttons runXCOM2ToolStripMenuItem.Click += (a, b) => { RunVanilla(); }; runWarOfTheChosenToolStripMenuItem.Click += (a, b) => { RunWotC(); }; runChallengeModeToolStripMenuItem.Click += (a, b) => { RunChallengeMode(); }; runChimeraSquadToolStripMenuItem.Click += (sender, args) => RunChimeraSquad(); #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"); if (IsModUpdateTaskRunning) { ShowModUpdateRunningMessageBox(); return; } var importedMods = Settings.ImportMods(); if (importedMods.Any()) { UpdateMods(importedMods, () => { Invoke(new Action(() => { RefreshModList(); modlist_ListObjectListView.EnsureModelVisible(importedMods.FirstOrDefault()); })); }); } }; updateEntriesToolStripMenuItem.Click += delegate { Log.Info("Menu->File->Update mod info"); if (IsModUpdateTaskRunning) { ShowModUpdateRunningMessageBox(); return; } SetStatus("Updating all mods..."); var mods = Settings.Mods.All.ToList(); UpdateMods(mods); }; exitToolStripMenuItem.Click += (sender, e) => { Log.Info("Menu->Close"); Close(); }; #region Menu->File->Open Log amlLogFileToolStripMenuItem1.Click += delegate { Tools.StartProcess(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ?? string.Empty, "AML.log")); }; x2LogFileToolStripMenuItem.Visible = Program.XEnv.Game == GameId.X2; x2LogFileToolStripMenuItem.Click += delegate { if (Program.XEnv is Xcom2Env env) { Tools.StartProcess(env.LogFilePath); } }; wotcLogFileToolStripMenuItem.Visible = Program.XEnv.Game == GameId.X2; wotcLogFileToolStripMenuItem.Click += delegate { if (Program.XEnv is Xcom2Env env) { Tools.StartProcess(env.LogFilePathWotC); } }; chimeraLogFileToolStripMenuItem.Visible = Program.XEnv.Game == GameId.ChimeraSquad; chimeraLogFileToolStripMenuItem.Click += delegate { if (Program.XEnv is XComChimeraSquadEnv env) { Tools.StartProcess(env.LogFilePath); } }; #endregion #region Menu->File->Open Folder folderToAmlToolStripMenuItem.Click += delegate { Tools.StartProcess("explorer", Path.GetDirectoryName(Application.ExecutablePath)); }; folderToX2InstallToolStripMenuItem.Visible = Program.XEnv.Game == GameId.X2; folderToX2InstallToolStripMenuItem.Click += delegate { if (Program.XEnv is Xcom2Env env) { Tools.StartProcess("explorer", env.GameDir); } }; folderToX2DataToolStripMenuItem.Visible = Program.XEnv.Game == GameId.X2; folderToX2DataToolStripMenuItem.Click += delegate { if (Program.XEnv is Xcom2Env env) { Tools.StartProcess("explorer", env.DataDir); } }; folderToWotcDataToolStripMenuItem.Visible = Program.XEnv.Game == GameId.X2; folderToWotcDataToolStripMenuItem.Click += delegate { if (Program.XEnv is Xcom2Env env) { Tools.StartProcess("explorer", env.DataDirWotC); } }; folderToChimeraInstallToolStripMenuItem.Visible = Program.XEnv.Game == GameId.ChimeraSquad; folderToChimeraInstallToolStripMenuItem.Click += delegate { if (Program.XEnv is XComChimeraSquadEnv env) { Tools.StartProcess("explorer", env.GameDir); } }; folderToChimeraDataToolStripMenuItem.Visible = Program.XEnv.Game == GameId.ChimeraSquad; folderToChimeraDataToolStripMenuItem.Click += delegate { if (Program.XEnv is XComChimeraSquadEnv env) { Tools.StartProcess("explorer", env.DataDir); } }; #endregion #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) { // If the duplicate mod workaround is disabled, make sure that all mod info files are enabled. if (!Settings.EnableDuplicateModIdWorkaround) { foreach (var mod in Mods.All) { mod.EnableModFile(); } Mods.MarkDuplicates(); } // refresh/update settings dependent functions RefreshModList(); InitMainGui(Settings); InitQuickArgumentsMenu(Settings); 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 { if (Program.XEnv is Xcom2Env x2Env) { x2Env.UseWotC = false; Log.Info("Menu->Tools->Import vanilla"); Program.XEnv.ImportActiveMods(Settings); RefreshModList(); } }; importFromWotCToolStripMenuItem.Click += delegate { if (Program.XEnv is Xcom2Env x2Env) { x2Env.UseWotC = true; Log.Info("Menu->Tools->Import WotC"); Program.XEnv.ImportActiveMods(Settings); RefreshModList(); } }; importFromChimeraSquadToolStripMenuItem.Click += delegate { if (Program.XEnv.Game == GameId.ChimeraSquad) { Log.Info("Menu->Tools->Import Chimera Squad"); Program.XEnv.ImportActiveMods(Settings); 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(); if (modsToDownload.Count == 0) { MessageBox.Show("No uninstalled workshop mods were found.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ResubscribeToMods(modsToDownload); }; #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; // Steam Events Workshop.OnItemDownloaded += Resubscribe_OnItemDownloaded; // Main Tabs // Export export_workshop_link_checkbox.CheckedChanged += ExportCheckboxCheckedChanged; export_group_checkbox.CheckedChanged += ExportCheckboxCheckedChanged; export_save_button.Click += ExportSaveButtonClick; export_load_button.Click += ExportLoadButtonClick; horizontal_splitcontainer.Paint += (sender, args) => { if (sender is SplitContainer s) { // Make the "splitter" from the SplitContainer slightly visible. args.Graphics.FillRectangle(new SolidBrush(SystemColors.Control), s.SplitterRectangle); } }; }
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; }
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; }