Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Display input state in an ImGui window
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver-makes-code committed Jan 19, 2024
1 parent d2cfe16 commit 06b6442
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion Client/Rendering/GameRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using ImGuiNET;
using Veldrid;
using Voxel.Client.Gui;
using Voxel.Client.Keybinding;
using Voxel.Client.Rendering.Debug;
using Voxel.Client.Rendering.Gui;
using Voxel.Client.Rendering.World;
Expand Down Expand Up @@ -81,10 +82,44 @@ public override void Render(double delta) {

BlitRenderer.Blit(Framebuffer.ResolvedMainColor, RenderSystem.GraphicsDevice.MainSwapchain.Framebuffer, true);


ImGui.Begin("General Debug");
ImGui.Text($"Player Position: {(Client.PlayerEntity?.blockPosition ?? ivec3.Zero)}");
ImGui.Text($"Player Velocity: {(Client.PlayerEntity?.velocity.WorldToBlockPosition() ?? ivec3.Zero)}");
ImGui.Text($"Player Grounded: {Client.PlayerEntity?.isOnFloor ?? false}");
ImGui.End();

ImGui.Begin("Keybinding State");
ImGui.BeginTable("bindings", 6);
ImGui.TableNextRow();
ImGui.TableSetColumnIndex(0);
ImGui.Text("Name");
ImGui.TableSetColumnIndex(1);
ImGui.Text($"Is Pressed");
ImGui.TableSetColumnIndex(2);
ImGui.Text($"Just Pressed");
ImGui.TableSetColumnIndex(3);
ImGui.Text($"Just Released");
ImGui.TableSetColumnIndex(4);
ImGui.Text($"Strength");
ImGui.TableSetColumnIndex(5);
ImGui.Text($"Axis");
foreach (var (name, bind) in Keybinds.Keybindings) {
ImGui.TableNextRow();
ImGui.TableSetColumnIndex(0);
ImGui.Text(name);
ImGui.TableSetColumnIndex(1);
ImGui.Text($"{bind.isPressed}");
ImGui.TableSetColumnIndex(2);
ImGui.Text($"{bind.justPressed}");
ImGui.TableSetColumnIndex(3);
ImGui.Text($"{bind.justReleased}");
ImGui.TableSetColumnIndex(4);
ImGui.Text($"{bind.strength}");
ImGui.TableSetColumnIndex(5);
ImGui.Text($"{bind.axis}");
}
ImGui.EndTable();
ImGui.End();
}


Expand Down

0 comments on commit 06b6442

Please sign in to comment.