diff --git a/GUI/CKAN-GUI.csproj b/GUI/CKAN-GUI.csproj index f77f547c23..a65583c2e7 100644 --- a/GUI/CKAN-GUI.csproj +++ b/GUI/CKAN-GUI.csproj @@ -1,4 +1,4 @@ - + CKAN-GUI @@ -346,6 +346,7 @@ + diff --git a/GUI/Controls/DeleteDirectories.cs b/GUI/Controls/DeleteDirectories.cs index a3bd14f012..5d89b7917e 100644 --- a/GUI/Controls/DeleteDirectories.cs +++ b/GUI/Controls/DeleteDirectories.cs @@ -79,6 +79,14 @@ public bool Wait(out HashSet toDelete) } } + /// + /// Open the user guide when the user presses F1 + /// + protected override void OnHelpRequested(HelpEventArgs evt) + { + evt.Handled = Util.TryOpenWebPage(HelpURLs.DeleteDirectories); + } + private void DirectoriesListView_ItemSelectionChanged(Object sender, ListViewItemSelectionChangedEventArgs e) { ContentsListView.Items.Clear(); diff --git a/GUI/Controls/EditModpack.cs b/GUI/Controls/EditModpack.cs index bb5d013b8b..a4156b2871 100644 --- a/GUI/Controls/EditModpack.cs +++ b/GUI/Controls/EditModpack.cs @@ -121,6 +121,14 @@ private void LoadRelationships(IRegistryQuerier registry) RelationshipsListView_ItemSelectionChanged(null, null); } + /// + /// Open the user guide when the user presses F1 + /// + protected override void OnHelpRequested(HelpEventArgs evt) + { + evt.Handled = Util.TryOpenWebPage(HelpURLs.ModPacks); + } + private void AddGroup(List relationships, ListViewGroup group, IRegistryQuerier registry) { if (relationships != null) diff --git a/GUI/Controls/PlayTime.cs b/GUI/Controls/PlayTime.cs index 4f708f6da5..09aaf27505 100755 --- a/GUI/Controls/PlayTime.cs +++ b/GUI/Controls/PlayTime.cs @@ -42,6 +42,14 @@ public void loadAllPlayTime(GameInstanceManager manager) /// public event Action Done; + /// + /// Open the user guide when the user presses F1 + /// + protected override void OnHelpRequested(HelpEventArgs evt) + { + evt.Handled = Util.TryOpenWebPage(HelpURLs.PlayTime); + } + private void ShowTotal() { if (rows != null) diff --git a/GUI/Dialogs/CloneFakeGameDialog.Designer.cs b/GUI/Dialogs/CloneFakeGameDialog.Designer.cs index 81e4042d6a..93e89d9e8a 100644 --- a/GUI/Dialogs/CloneFakeGameDialog.Designer.cs +++ b/GUI/Dialogs/CloneFakeGameDialog.Designer.cs @@ -358,6 +358,7 @@ private void InitializeComponent() this.Icon = Properties.Resources.AppIcon; this.MaximizeBox = false; this.MinimizeBox = false; + this.HelpButton = true; this.Name = "CloneFakeKspDialog"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; diff --git a/GUI/Dialogs/CloneFakeGameDialog.cs b/GUI/Dialogs/CloneFakeGameDialog.cs index cea2c10ff6..7908e6a071 100644 --- a/GUI/Dialogs/CloneFakeGameDialog.cs +++ b/GUI/Dialogs/CloneFakeGameDialog.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using System.ComponentModel; using System.Windows.Forms; using Autofac; using CKAN.Versioning; @@ -332,5 +333,22 @@ private void buttonPathBrowser_Click(object sender, EventArgs e) } } + + /// + /// Open the user guide when the user presses F1 + /// + protected override void OnHelpRequested(HelpEventArgs evt) + { + evt.Handled = Util.TryOpenWebPage(HelpURLs.CloneFakeInstances); + } + + /// + /// Open the user guide when the user clicks the help button + /// + protected override void OnHelpButtonClicked(CancelEventArgs evt) + { + evt.Cancel = Util.TryOpenWebPage(HelpURLs.CloneFakeInstances); + } + } } diff --git a/GUI/Dialogs/CompatibleGameVersionsDialog.Designer.cs b/GUI/Dialogs/CompatibleGameVersionsDialog.Designer.cs index 1c34667ba0..75f0fb1965 100644 --- a/GUI/Dialogs/CompatibleGameVersionsDialog.Designer.cs +++ b/GUI/Dialogs/CompatibleGameVersionsDialog.Designer.cs @@ -224,6 +224,7 @@ private void InitializeComponent() this.Icon = Properties.Resources.AppIcon; this.MaximizeBox = false; this.MinimizeBox = false; + this.HelpButton = true; this.Name = "CompatibleGameVersionsDialog"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Shown += new System.EventHandler(this.CompatibleGameVersionsDialog_Shown); diff --git a/GUI/Dialogs/CompatibleGameVersionsDialog.cs b/GUI/Dialogs/CompatibleGameVersionsDialog.cs index 6a8ad580dd..60f37056ff 100644 --- a/GUI/Dialogs/CompatibleGameVersionsDialog.cs +++ b/GUI/Dialogs/CompatibleGameVersionsDialog.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.IO; +using System.ComponentModel; using System.Windows.Forms; using System.Collections.Generic; using Autofac; @@ -42,6 +43,22 @@ public CompatibleGameVersionsDialog(GameInstance inst, bool centerScreen) SortAndAddVersionsToList(knownVersions, compatibleVersions); } + /// + /// Open the user guide when the user presses F1 + /// + protected override void OnHelpRequested(HelpEventArgs evt) + { + evt.Handled = Util.TryOpenWebPage(HelpURLs.CompatibleGameVersions); + } + + /// + /// Open the user guide when the user clicks the help button + /// + protected override void OnHelpButtonClicked(CancelEventArgs evt) + { + evt.Cancel = Util.TryOpenWebPage(HelpURLs.CompatibleGameVersions); + } + private void CompatibleGameVersionsDialog_Shown(object sender, EventArgs e) { if (_inst.CompatibleVersionsAreFromDifferentGameVersion) @@ -91,7 +108,7 @@ private void AddVersionToListButton_Click(object sender, EventArgs e) { return; } - if (AddVersionToListTextBox.Text.ToLower() == "any") + if (AddVersionToListTextBox.Text.ToLower() == "any") { MessageBox.Show( Properties.Resources.CompatibleGameVersionsDialogInvalidFormat, diff --git a/GUI/Dialogs/EditLabelsDialog.Designer.cs b/GUI/Dialogs/EditLabelsDialog.Designer.cs index c758c662b6..1f401219fc 100644 --- a/GUI/Dialogs/EditLabelsDialog.Designer.cs +++ b/GUI/Dialogs/EditLabelsDialog.Designer.cs @@ -336,6 +336,7 @@ private void InitializeComponent() this.Icon = Properties.Resources.AppIcon; this.MaximizeBox = false; this.MinimizeBox = false; + this.HelpButton = true; this.Name = "EditLabelsDialog"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; resources.ApplyResources(this, "$this"); diff --git a/GUI/Dialogs/EditLabelsDialog.cs b/GUI/Dialogs/EditLabelsDialog.cs index 9894c19ffc..1f2dd8d3b9 100644 --- a/GUI/Dialogs/EditLabelsDialog.cs +++ b/GUI/Dialogs/EditLabelsDialog.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Drawing; +using System.ComponentModel; using System.Windows.Forms; using log4net; @@ -72,6 +73,22 @@ private void LoadTree() LabelSelectionTree.EndUpdate(); } + /// + /// Open the user guide when the user presses F1 + /// + protected override void OnHelpRequested(HelpEventArgs evt) + { + evt.Handled = Util.TryOpenWebPage(HelpURLs.Labels); + } + + /// + /// Open the user guide when the user clicks the help button + /// + protected override void OnHelpButtonClicked(CancelEventArgs evt) + { + evt.Cancel = Util.TryOpenWebPage(HelpURLs.Labels); + } + private void LabelSelectionTree_BeforeSelect(Object sender, TreeViewCancelEventArgs e) { if (e.Node == null) diff --git a/GUI/Dialogs/InstallFiltersDialog.Designer.cs b/GUI/Dialogs/InstallFiltersDialog.Designer.cs index 72f9112f7d..a24d2ed168 100644 --- a/GUI/Dialogs/InstallFiltersDialog.Designer.cs +++ b/GUI/Dialogs/InstallFiltersDialog.Designer.cs @@ -122,6 +122,9 @@ private void InitializeComponent() this.Controls.Add(this.WarningLabel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Icon = Properties.Resources.AppIcon; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.HelpButton = true; this.Name = "InstallFiltersDialog"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Load += new System.EventHandler(this.InstallFiltersDialog_Load); diff --git a/GUI/Dialogs/InstallFiltersDialog.cs b/GUI/Dialogs/InstallFiltersDialog.cs index 83a9f6721d..0b657bc4c3 100644 --- a/GUI/Dialogs/InstallFiltersDialog.cs +++ b/GUI/Dialogs/InstallFiltersDialog.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.ComponentModel; using System.Windows.Forms; using CKAN.Configuration; @@ -15,6 +16,22 @@ public InstallFiltersDialog(IConfiguration globalConfig, GameInstance instance) this.instance = instance; } + /// + /// Open the user guide when the user presses F1 + /// + protected override void OnHelpRequested(HelpEventArgs evt) + { + evt.Handled = Util.TryOpenWebPage(HelpURLs.Filters); + } + + /// + /// Open the user guide when the user clicks the help button + /// + protected override void OnHelpButtonClicked(CancelEventArgs evt) + { + evt.Cancel = Util.TryOpenWebPage(HelpURLs.Filters); + } + private void InstallFiltersDialog_Load(object sender, EventArgs e) { GlobalFiltersTextBox.Text = string.Join(Environment.NewLine, globalConfig.GlobalInstallFilters); diff --git a/GUI/Dialogs/ManageGameInstancesDialog.Designer.cs b/GUI/Dialogs/ManageGameInstancesDialog.Designer.cs index 638a2b55aa..0bac64dbb6 100644 --- a/GUI/Dialogs/ManageGameInstancesDialog.Designer.cs +++ b/GUI/Dialogs/ManageGameInstancesDialog.Designer.cs @@ -217,6 +217,9 @@ private void InitializeComponent() this.Controls.Add(this.AddNewButton); this.Controls.Add(this.SelectButton); this.Controls.Add(this.GameInstancesListView); + this.MinimizeBox = false; + this.MaximizeBox = false; + this.HelpButton = true; this.Icon = Properties.Resources.AppIcon; this.MinimumSize = new System.Drawing.Size(560, 200); this.Name = "ManageGameInstancesDialog"; diff --git a/GUI/Dialogs/ManageGameInstancesDialog.cs b/GUI/Dialogs/ManageGameInstancesDialog.cs index e1ad839449..3220fd40d2 100644 --- a/GUI/Dialogs/ManageGameInstancesDialog.cs +++ b/GUI/Dialogs/ManageGameInstancesDialog.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.ComponentModel; using System.Windows.Forms; using System.IO; @@ -128,6 +129,22 @@ private string[] rowItems(GameInstance instance, bool includeGame, bool includeP return list.ToArray(); } + /// + /// Open the user guide when the user presses F1 + /// + protected override void OnHelpRequested(HelpEventArgs evt) + { + evt.Handled = Util.TryOpenWebPage(HelpURLs.ManageInstances); + } + + /// + /// Open the user guide when the user clicks the help button + /// + protected override void OnHelpButtonClicked(CancelEventArgs evt) + { + evt.Cancel = Util.TryOpenWebPage(HelpURLs.ManageInstances); + } + private static string FormatVersion(GameVersion v) { return v == null diff --git a/GUI/HelpURLs.cs b/GUI/HelpURLs.cs new file mode 100644 index 0000000000..fff4b8f6ce --- /dev/null +++ b/GUI/HelpURLs.cs @@ -0,0 +1,21 @@ +namespace CKAN +{ + /// + /// Holds URLs that we launch for F1 help + /// + public static class HelpURLs + { + public const string UserGuide = "https://github.com/KSP-CKAN/CKAN/wiki/User-guide"; + public const string ManageInstances = "https://github.com/KSP-CKAN/CKAN/wiki/User-guide#adding-game-folders"; + public const string CompatibleGameVersions = "https://github.com/KSP-CKAN/CKAN/wiki/User-guide#choosing-compatible-game-versions"; + public const string ModPacks = "https://github.com/KSP-CKAN/CKAN/wiki/Sharing-a-modlist-%28metapackages%29"; + + public const string CloneFakeInstances = "https://github.com/KSP-CKAN/CKAN/pull/2627"; + public const string DeleteDirectories = "https://github.com/KSP-CKAN/CKAN/pull/2962"; + public const string Filters = "https://github.com/KSP-CKAN/CKAN/pull/3458"; + public const string Labels = "https://github.com/KSP-CKAN/CKAN/pull/2936"; + public const string PlayTime = "https://github.com/KSP-CKAN/CKAN/pull/3543"; + + public const string Discord = "https://discord.gg/Mb4nXQD"; + } +} diff --git a/GUI/Main/Main.cs b/GUI/Main/Main.cs index 6312f442b8..d5ae565ea9 100644 --- a/GUI/Main/Main.cs +++ b/GUI/Main/Main.cs @@ -336,6 +336,14 @@ protected override void OnShown(EventArgs e) base.OnShown(e); } + /// + /// Open the user guide when the user presses F1 + /// + protected override void OnHelpRequested(HelpEventArgs evt) + { + evt.Handled = Util.TryOpenWebPage(HelpURLs.UserGuide); + } + protected override void OnFormClosed(FormClosedEventArgs e) { // Stop all running play time timers @@ -711,12 +719,12 @@ private void MainTabControl_OnSelectedIndexChanged(object sender, EventArgs e) private void userGuideToolStripMenuItem_Click(object sender, EventArgs e) { - Utilities.ProcessStartURL("https://github.com/KSP-CKAN/CKAN/wiki/User-guide"); + Utilities.ProcessStartURL(HelpURLs.UserGuide); } private void discordToolStripMenuItem_Click(object sender, EventArgs e) { - Utilities.ProcessStartURL("https://discord.gg/Mb4nXQD"); + Utilities.ProcessStartURL(HelpURLs.Discord); } private void reportClientIssueToolStripMenuItem_Click(object sender, EventArgs e)