Dalamud/Dalamud/Interface/Internal/Windows/Data/Widgets/KeyStateWidget.cs
goat 448b0d16ea
Add "loading dialog" for service init, unify blocking logic (#1779)
* wip

* hacky fix for overlapping event text in profiler

* move IsResumeGameAfterPluginLoad logic to PluginManager

* fix some warnings

* handle exceptions properly

* remove ability to cancel, rename button to "hide" instead

* undo Dalamud.Service refactor for now

* warnings

* add explainer, show which plugins are still loading

* add some text if loading takes more than 3 minutes

* undo wrong CS merge
2024-04-21 17:28:37 +02:00

54 lines
1.2 KiB
C#

using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface.Colors;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
/// <summary>
/// Widget for displaying keyboard state.
/// </summary>
internal class KeyStateWidget : IDataWindowWidget
{
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "keystate" };
/// <inheritdoc/>
public string DisplayName { get; init; } = "KeyState";
/// <inheritdoc/>
public bool Ready { get; set; }
/// <inheritdoc/>
public void Load()
{
this.Ready = true;
}
/// <inheritdoc/>
public void Draw()
{
var keyState = Service<KeyState>.Get();
ImGui.Columns(4);
var i = 0;
foreach (var vkCode in keyState.GetValidVirtualKeys())
{
var code = (int)vkCode;
var value = keyState[code];
ImGui.PushStyleColor(ImGuiCol.Text, value ? ImGuiColors.HealerGreen : ImGuiColors.DPSRed);
ImGui.Text($"{vkCode} ({code})");
ImGui.PopStyleColor();
i++;
if (i % 24 == 0)
ImGui.NextColumn();
}
ImGui.Columns(1);
}
}