Skip to content

Commit

Permalink
Context sensitive help
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Aug 3, 2022
1 parent f1bcd19 commit bab8c7c
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 4 deletions.
3 changes: 2 additions & 1 deletion GUI/CKAN-GUI.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AssemblyName>CKAN-GUI</AssemblyName>
Expand Down Expand Up @@ -346,6 +346,7 @@
<Compile Include="SingleAssemblyResourceManager.cs" />
<Compile Include="TabController.cs" />
<Compile Include="URLHandlers.cs" />
<Compile Include="HelpURLs.cs" />
<Compile Include="Util.cs" />
<Compile Include="X11.cs" />
</ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions GUI/Controls/DeleteDirectories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ public bool Wait(out HashSet<string> toDelete)
}
}

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
protected override void OnHelpRequested(HelpEventArgs evt)
{
evt.Handled = Util.TryOpenWebPage(HelpURLs.DeleteDirectories);
}

private void DirectoriesListView_ItemSelectionChanged(Object sender, ListViewItemSelectionChangedEventArgs e)
{
ContentsListView.Items.Clear();
Expand Down
8 changes: 8 additions & 0 deletions GUI/Controls/EditModpack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ private void LoadRelationships(IRegistryQuerier registry)
RelationshipsListView_ItemSelectionChanged(null, null);
}

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
protected override void OnHelpRequested(HelpEventArgs evt)
{
evt.Handled = Util.TryOpenWebPage(HelpURLs.ModPacks);
}

private void AddGroup(List<RelationshipDescriptor> relationships, ListViewGroup group, IRegistryQuerier registry)
{
if (relationships != null)
Expand Down
8 changes: 8 additions & 0 deletions GUI/Controls/PlayTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public void loadAllPlayTime(GameInstanceManager manager)
/// </summary>
public event Action Done;

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
protected override void OnHelpRequested(HelpEventArgs evt)
{
evt.Handled = Util.TryOpenWebPage(HelpURLs.PlayTime);
}

private void ShowTotal()
{
if (rows != null)
Expand Down
1 change: 1 addition & 0 deletions GUI/Dialogs/CloneFakeGameDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions GUI/Dialogs/CloneFakeGameDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -332,5 +333,22 @@ private void buttonPathBrowser_Click(object sender, EventArgs e)
}

}

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
protected override void OnHelpRequested(HelpEventArgs evt)
{
evt.Handled = Util.TryOpenWebPage(HelpURLs.CloneFakeInstances);
}

/// <summary>
/// Open the user guide when the user clicks the help button
/// </summary>
protected override void OnHelpButtonClicked(CancelEventArgs evt)
{
evt.Cancel = Util.TryOpenWebPage(HelpURLs.CloneFakeInstances);
}

}
}
1 change: 1 addition & 0 deletions GUI/Dialogs/CompatibleGameVersionsDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion GUI/Dialogs/CompatibleGameVersionsDialog.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -42,6 +43,22 @@ public CompatibleGameVersionsDialog(GameInstance inst, bool centerScreen)
SortAndAddVersionsToList(knownVersions, compatibleVersions);
}

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
protected override void OnHelpRequested(HelpEventArgs evt)
{
evt.Handled = Util.TryOpenWebPage(HelpURLs.CompatibleGameVersions);
}

/// <summary>
/// Open the user guide when the user clicks the help button
/// </summary>
protected override void OnHelpButtonClicked(CancelEventArgs evt)
{
evt.Cancel = Util.TryOpenWebPage(HelpURLs.CompatibleGameVersions);
}

private void CompatibleGameVersionsDialog_Shown(object sender, EventArgs e)
{
if (_inst.CompatibleVersionsAreFromDifferentGameVersion)
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions GUI/Dialogs/EditLabelsDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions GUI/Dialogs/EditLabelsDialog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using log4net;

Expand Down Expand Up @@ -72,6 +73,22 @@ private void LoadTree()
LabelSelectionTree.EndUpdate();
}

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
protected override void OnHelpRequested(HelpEventArgs evt)
{
evt.Handled = Util.TryOpenWebPage(HelpURLs.Labels);
}

/// <summary>
/// Open the user guide when the user clicks the help button
/// </summary>
protected override void OnHelpButtonClicked(CancelEventArgs evt)
{
evt.Cancel = Util.TryOpenWebPage(HelpURLs.Labels);
}

private void LabelSelectionTree_BeforeSelect(Object sender, TreeViewCancelEventArgs e)
{
if (e.Node == null)
Expand Down
3 changes: 3 additions & 0 deletions GUI/Dialogs/InstallFiltersDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions GUI/Dialogs/InstallFiltersDialog.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.ComponentModel;
using System.Windows.Forms;

using CKAN.Configuration;
Expand All @@ -15,6 +16,22 @@ public InstallFiltersDialog(IConfiguration globalConfig, GameInstance instance)
this.instance = instance;
}

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
protected override void OnHelpRequested(HelpEventArgs evt)
{
evt.Handled = Util.TryOpenWebPage(HelpURLs.Filters);
}

/// <summary>
/// Open the user guide when the user clicks the help button
/// </summary>
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);
Expand Down
3 changes: 3 additions & 0 deletions GUI/Dialogs/ManageGameInstancesDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions GUI/Dialogs/ManageGameInstancesDialog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;

Expand Down Expand Up @@ -128,6 +129,22 @@ private string[] rowItems(GameInstance instance, bool includeGame, bool includeP
return list.ToArray();
}

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
protected override void OnHelpRequested(HelpEventArgs evt)
{
evt.Handled = Util.TryOpenWebPage(HelpURLs.ManageInstances);
}

/// <summary>
/// Open the user guide when the user clicks the help button
/// </summary>
protected override void OnHelpButtonClicked(CancelEventArgs evt)
{
evt.Cancel = Util.TryOpenWebPage(HelpURLs.ManageInstances);
}

private static string FormatVersion(GameVersion v)
{
return v == null
Expand Down
21 changes: 21 additions & 0 deletions GUI/HelpURLs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace CKAN
{
/// <summary>
/// Holds URLs that we launch for F1 help
/// </summary>
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";
}
}
12 changes: 10 additions & 2 deletions GUI/Main/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ protected override void OnShown(EventArgs e)
base.OnShown(e);
}

/// <summary>
/// Open the user guide when the user presses F1
/// </summary>
protected override void OnHelpRequested(HelpEventArgs evt)
{
evt.Handled = Util.TryOpenWebPage(HelpURLs.UserGuide);
}

protected override void OnFormClosed(FormClosedEventArgs e)
{
// Stop all running play time timers
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bab8c7c

Please sign in to comment.