Skip to content

feat: add interactive HUD editor screen with drag-and-drop positioning#38

Open
dsnsgithub wants to merge 15 commits into
mainfrom
claude/hud-editor-drag-drop-82baxg
Open

feat: add interactive HUD editor screen with drag-and-drop positioning#38
dsnsgithub wants to merge 15 commits into
mainfrom
claude/hud-editor-drag-drop-82baxg

Conversation

@dsnsgithub

@dsnsgithub dsnsgithub commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

This PR introduces a new interactive HUD editor screen that allows users to visually arrange HUD elements instead of manually editing configuration values. The editor is opened with Right Shift (rebindable) or from Mod Menu, and provides real-time drag-and-drop positioning, scaling via scroll wheel, snapping to screen edges, center lines, and corner dock slots, and overlap prevention. The old placement settings (Orientation, the hidden Custom Position flag, and manual X/Y entry) are replaced by a single Position setting per element. Mod Menu is now an optional dependency.

Screenshots

Captured by the client gametest on Minecraft 26.2 (a real production client driven by simulated input).

The editor, opened with Right Shift or from Mod Menu — every enabled element outlined, the title and beveled Settings button in the center of the screen (where HUD elements are least likely to be placed), hints at the bottom:

HUD editor open

Dragging the FPS element out of the top-left stack (cyan outline while dragging, element info at the bottom; Ping takes over the vacated slot):

HUD editor after dragging the FPS element

Key Changes

  • New HudEditorScreen class: A full-featured GUI screen implementing Lunar Client-style HUD editing with:

    • Live preview of all enabled HUD elements
    • Drag-and-drop positioning with visual feedback (outline colors change based on state)
    • Dropping an element near a corner docks it into that corner's stack (margin and stacking included, previewed live); edge and center-line snapping for free placement
    • Overlap prevention: a drag onto another element is rejected and the element stays where it last fit, and scroll-resizing cannot grow an element into a neighbour
    • Scroll wheel scaling (0.1× to 10.0×)
    • A centered, enlarged title and a beveled vanilla-style Settings button (classic button proportions) that opens the Cloth Config screen for the remaining options
    • Automatic config save on close (Escape key)
  • Single Position setting replaces Orientation + Custom Position: each element has one Position value — top-left, top-right, bottom-left, bottom-right, or custom. It shows as a dropdown in the settings screen so an element can be reset to a corner; the raw Custom X/Y coordinates stay editor-managed and hidden. Old configs (both Orientation/Custom Position and the camelCase variants) migrate automatically, verified by a launch test with a planted legacy config.

  • Mod Menu is now optional (dependssuggests): the editor is reachable via its keybinding and hosts the Settings button itself. The Cloth screen builder lives in SettingsScreenBuilder, separate from the ModMenu entrypoint class, so ModMenuApi is never classloaded unless Mod Menu is installed. Verified by launch-testing with Mod Menu removed from the runtime mods.

  • Extracted HudLayout and HudRenderer utility classes: all positioning math and element drawing is shared between the in-game HUD and the editor, so the editor preview always matches the real HUD; BetterHUDGUI was refactored on top of them.

  • Updated ModSettings/CustomText: placement is expressed by the single position value; Custom X/Y became doubles (0-100%) so dragging is smooth, and old integer config values still parse.

  • Added keybinding: "Edit HUD Layout" (Right Shift) with proper category support across Minecraft versions.

  • Added localization: language strings for the editor UI (title, hints, scale display, Settings button).

  • Version-specific support: Added 1.21.9 variant to handle new MouseButtonEvent/KeyEvent input signatures while maintaining compatibility with earlier versions.

  • Enhanced game tests: exerciseHudEditor() drives the real editor with simulated input — drags an element to a custom position, then drags it back into a corner to dock it — and asserts the config after each step.

Implementation Details

  • The editor uses percentage-based positioning (0-100%) internally, which is resolution-independent and matches the config format
  • Dock snapping targets each corner's anchor slot (the spot a docked element occupies, margin included); releasing there stores the corner as the element's Position
  • The HUD skips rendering while the editor is open to avoid double-drawing elements
  • When opened without a world behind it (from Mod Menu on the title screen), the editor uses a solid backdrop and shows placeholder text for elements with nothing to display
  • All rendering code uses version-conditional compilation to support both GuiGraphics (pre-1.26) and GuiGraphicsExtractor (1.26+)

https://claude.ai/code/session_016M8Paub79s9he93GZUGemX

claude added 3 commits July 20, 2026 03:27
Press Right Shift (rebindable, Options > Controls > BetterHUD) to open a
Lunar Client style editor that shows every enabled HUD element live:
drag to place an element anywhere (with edge/center snapping), scroll to
resize it, right-click to snap it back to its corner stack, Escape to
save. No more typing coordinates or being limited to the four corners.

- HudEditorScreen: the editor; saves via Config.serialize() on close.
- HudLayout/HudRenderer: placement math and element drawing extracted
  from BetterHUDGUI so the editor preview and the real HUD share one
  code path. Also fixes the top-right stack ignoring element scale when
  computing its x offset.
- Custom X/Y settings are doubles now (0-100%), so dragging is smooth;
  old integer config values still parse.
- New 1.21.9 build variant (covers 1.21.9-1.21.11): 1.21.9 replaced the
  Screen mouse handler signatures with input event records, so the
  editor cannot be compiled once for 1.21.6-1.21.11. Follows the
  variant-split process from DEVELOPMENT.md; CI matrices pick it up
  from supported-versions.json automatically.
- Client gametests now open the editor with the keybinding, drag the
  FPS element with simulated mouse input, and assert the dragged
  position lands in betterhud.properties. Verified locally end-to-end
  on 1.21.4, 1.21.6, 1.21.11, and 26.2.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
Keeps the 1.21.6 variant's mc_dep cap at <1.21.9 (the new 1.21.9 variant
covers 1.21.9-1.21.11) and adopts main's comment cleanup from #36.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

The game launched and entered a survival singleplayer world with the HUD active, on every supported Minecraft version, for b939590. A ❌ means that version's launch test did not produce a screenshot — check its job. Title-screen screenshots and game logs are in the run artifacts.

1.21
BetterHUD on Minecraft 1.21
1.21.1
BetterHUD on Minecraft 1.21.1
1.21.2
BetterHUD on Minecraft 1.21.2
1.21.3
BetterHUD on Minecraft 1.21.3
1.21.4
BetterHUD on Minecraft 1.21.4
1.21.5
BetterHUD on Minecraft 1.21.5
1.21.6
BetterHUD on Minecraft 1.21.6
1.21.7
BetterHUD on Minecraft 1.21.7
1.21.8
BetterHUD on Minecraft 1.21.8
1.21.9
BetterHUD on Minecraft 1.21.9
1.21.10
BetterHUD on Minecraft 1.21.10
1.21.11
BetterHUD on Minecraft 1.21.11
26.1
BetterHUD on Minecraft 26.1
26.1.1
BetterHUD on Minecraft 26.1.1
26.1.2
BetterHUD on Minecraft 26.1.2
26.2
BetterHUD on Minecraft 26.2

@dsnsgithub dsnsgithub changed the title Add interactive HUD editor screen with drag-and-drop positioning feat: add interactive HUD editor screen with drag-and-drop positioning Jul 20, 2026
claude and others added 12 commits July 20, 2026 03:58
The Orientation / Custom Position / Custom X / Custom Y entries are gone
from the settings screen; placement is edited only by dragging (their
config keys remain as the persistence format). Mod Menu's configure
button now opens the HUD editor directly, which gains a Settings button
for the remaining Cloth Config options (toggles, colors, scale) and
returns to its parent screen on close. Right-clicking an element docks
it back into a corner, and right-clicking a docked element cycles it
through the corners, replacing the orientation dropdown. The gametests
now also cover right-click docking.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
Renames the title to BetterHUD Editor and moves it, with the Settings
button, to the center of the screen where HUD elements are least likely
to be placed. Drops the ellipsis from the button label.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
Opaque gray body with light/dark bevels and a border that turns white
on hover, so it no longer resembles the translucent HUD element boxes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
Uses vanilla's proportions scaled with the text: 20px-tall box with the
label centered at (height - 8) / 2 and ~10px side padding.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
Drops its text scale from 1.5x to 1.25x, keeping the classic button
proportions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
The HUD editor is reachable via its keybinding and hosts the Settings
button itself, so Mod Menu only contributes a configure button in its
mod list. The Cloth Config screen builder moves out of the ModMenu
entrypoint class into SettingsScreenBuilder so the editor never touches
ModMenuApi, which only classloads when Mod Menu is installed. modmenu
moves from depends to suggests in fabric.mod.json.

Verified with the 26.2 launch test both with Mod Menu loaded and with it
removed from the runtime mods.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
Removed feature list and updated HUD editor instructions for clarity.
Strip class-level Javadoc, method docs, and inline comments
that describe obvious behavior across the HUD editor, layout,
renderer, settings, and Mod Menu integration.
Removed comments explaining the HUD editor test process and adjusted the code accordingly.
Position (top-left / top-right / bottom-left / bottom-right / custom)
unites the old Orientation dropdown and hidden Custom Position flag. It
shows as a dropdown in the settings screen so an element can be reset to
a corner, and old configs migrate automatically.

In the editor, dragging near a corner now snaps into that corner's dock
slot (margin and stacking included, previewed live) in addition to the
flush edge and center snaps, replacing the right-click gesture. Elements
can no longer overlap: a drag onto another element is rejected and the
element stays where it last fit, and scroll-resizing cannot grow an
element into a neighbour.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
Takes the Position model over the pre-rework code the comment-cleanup
commits touched, keeps the revised README and 3.0.0 version bump, and
strips the rework's explanatory comments to match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M8Paub79s9he93GZUGemX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants