HUD system - #150
Open
EternalQ wants to merge 6 commits into
Open
Conversation
Author
brachy84
requested changes
Jul 17, 2026
| * @param panelCreator function which creates the main panel of this screen | ||
| * @param contextFactory factory that creates the context for this screen | ||
| */ | ||
| protected ModularScreen(@NotNull String owner, @NotNull Function<ModularGuiContext, ModularPanel> panelCreator, |
Collaborator
There was a problem hiding this comment.
Add the param to the existing private ctor and add overloads for the public ctors which just call this(...)
| } | ||
|
|
||
| boolean resized = scaledWidth != lastWidth || scaledHeight != lastHeight; | ||
| if (resized) { lastWidth = scaledWidth; lastHeight = scaledHeight; } |
| * Defaults to matching the field's own default horizontal padding (see BaseTextFieldWidget's | ||
| * constructor), since that's already the amount of breathing room the field visually reserves. | ||
| */ | ||
| private int scrollEdgeMargin = 4; |
Collaborator
There was a problem hiding this comment.
Why is this needed? Why is widget padding not enough?
Collaborator
|
Also either write SHORT code comments yourself or dont write them at all. NOBODY is reading those books. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUD system summary
com.cleanroommc.modularui.hudrenders ModularUI panels directly over the game world (or over/underan open
GuiScreen), reusing the normal widget-tree/theme/layout pipeline. A HUD element isdisplay-only: no mouse/keyboard input, no hover/focus/drag - only
draw()sees an updated mouseposition.
How it works
A
HudElementowns a privateModularScreenbuilt from aHudContext(no-oponFrameUpdate(), sono hover/focus/drag logic runs) and a throwaway
HudWrapperGuiScreenused only to satisfyModularScreen#constructOverlay's contract - neither is public API.HudManager(started once viaHudManager.init(), already wired inClientProxy) hooks:RenderGameOverlayEvent.Post- draws while noGuiScreenis open (visibleInWorld).GuiScreenEvent.DrawScreenEvent.Pre/.Post- draws under/over an openGuiScreen(
visibleInGui(visible, isOverGui)).ClientTickEvent- ticks registered elements.enabled(boolean)toggles an element entirely (skips ticking too);renderPriority(int)ordersoverlapping elements (higher draws on top).
Changes (including fixes for my chat mod)
HudElement,HudManager,HudContext,HudScreen,HudWrapper).typing past a field's visible width. Fixed by measuring scroll in the same coordinate space as the
cursor (plus a
scrollEdgeMargin) and widening the cursor quad so it still rasterizes at ascrolled/clipped edge.
Platform.setupDrawFont()now enablesGL_BLEND: previouslyFontRendererwrote fully opaquepixels regardless of a color's alpha channel, so fade-out/ghost-text effects had no visible effect.
InternalWidgetTree.drawTreeForegroundnow skips disabled widgets: brings it in line withdrawTree/IWidget#drawForeground's own documented contract - a disabled widget's foreground/tooltipshould not render, but it still did.
GuiScreen(the default)made the whole game - world and every GUI - render visibly darker, permanently, until restart. Cause:
RenderHelper.enableStandardItemLighting()bakesGL_LIGHT0/GL_LIGHT1positions relative towhatever matrix is active when it's called; called from a HUD overlay's own transform stack (as
ModularScreen.drawScreen()/drawForeground()always did, for every screen), those positions cameout wrong, corrupting lighting for everything drawn afterward. Fix: both methods now skip
RenderHelper.enableStandardItemLighting()/GlStateManager.enableLighting()entirely whenisOverlay()is true (HUD screens never render lit 3D items, so nothing is lost). Do not remove thisguard or call those methods from HUD-drawn code.
Checklist