mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using Dalamud.Game.ClientState.Keys;
|
|
using Dalamud.Interface.Colors;
|
|
using ImGuiNET;
|
|
|
|
namespace Dalamud.Interface.Internal.Windows.Data;
|
|
|
|
/// <summary>
|
|
/// Widget for displaying keyboard state.
|
|
/// </summary>
|
|
internal class KeyStateWidget : IDataWindowWidget
|
|
{
|
|
/// <inheritdoc/>
|
|
public DataKind DataKind { get; init; } = DataKind.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);
|
|
}
|
|
}
|