mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Allow setting a DisplayOrder on commands (#2162)
* Allow setting a DisplayOrder on commands * Linq on demand * Sort commands in /help alphabetically * note default in xmldoc --------- Co-authored-by: goat <16760685+goaaats@users.noreply.github.com>
This commit is contained in:
parent
0b9a2fd9c8
commit
f2c132c7d8
3 changed files with 14 additions and 5 deletions
|
|
@ -26,6 +26,11 @@ public interface IReadOnlyCommandInfo
|
||||||
/// Gets a value indicating whether if this command should be shown in the help output.
|
/// Gets a value indicating whether if this command should be shown in the help output.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool ShowInHelp { get; }
|
bool ShowInHelp { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the display order of this command. Defaults to alphabetical ordering.
|
||||||
|
/// </summary>
|
||||||
|
int DisplayOrder { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -51,4 +56,7 @@ public sealed class CommandInfo : IReadOnlyCommandInfo
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool ShowInHelp { get; set; } = true;
|
public bool ShowInHelp { get; set; } = true;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public int DisplayOrder { get; set; } = -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ internal class DalamudCommands : IServiceType
|
||||||
if (arguments.IsNullOrWhitespace())
|
if (arguments.IsNullOrWhitespace())
|
||||||
{
|
{
|
||||||
chatGui.Print(Loc.Localize("DalamudCmdHelpAvailable", "Available commands:"));
|
chatGui.Print(Loc.Localize("DalamudCmdHelpAvailable", "Available commands:"));
|
||||||
foreach (var cmd in commandManager.Commands)
|
foreach (var cmd in commandManager.Commands.OrderBy(cInfo => cInfo.Key))
|
||||||
{
|
{
|
||||||
if (!cmd.Value.ShowInHelp)
|
if (!cmd.Value.ShowInHelp)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -2762,13 +2762,14 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
var commands = commandManager.Commands
|
var commands = commandManager.Commands
|
||||||
.Where(cInfo =>
|
.Where(cInfo =>
|
||||||
cInfo.Value is { ShowInHelp: true } &&
|
cInfo.Value is { ShowInHelp: true } &&
|
||||||
commandManager.GetHandlerAssemblyName(cInfo.Key, cInfo.Value) == plugin.Manifest.InternalName)
|
commandManager.GetHandlerAssemblyName(cInfo.Key, cInfo.Value) == plugin.Manifest.InternalName);
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
if (commands.Any())
|
if (commands.Any())
|
||||||
{
|
{
|
||||||
ImGui.Dummy(ImGuiHelpers.ScaledVector2(10f, 10f));
|
ImGui.Dummy(ImGuiHelpers.ScaledVector2(10f, 10f));
|
||||||
foreach (var command in commands)
|
foreach (var command in commands
|
||||||
|
.OrderBy(cInfo => cInfo.Value.DisplayOrder)
|
||||||
|
.ThenBy(cInfo => cInfo.Key))
|
||||||
{
|
{
|
||||||
ImGuiHelpers.SafeTextWrapped($"{command.Key} → {command.Value.HelpMessage}");
|
ImGuiHelpers.SafeTextWrapped($"{command.Key} → {command.Value.HelpMessage}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue