Skip to content

Commit

Permalink
Add draggable list to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
nea89o authored and NopoTheGamer committed Oct 20, 2024
1 parent 71c8ba6 commit df7ca08
Show file tree
Hide file tree
Showing 8 changed files with 478 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void render(RenderContext context, int x, int y, int width) {

context.drawDarkRect(x, y, width, height, true);
context.drawStringCenteredScaledMaxWidth(option.getName(),
fr, x + width / 6, y + 13, true, width / 3 - 10, 0xc0c0c0
fr, x + width / 6, y + 13, true, width / 3 - 10, 0xc0c0c0
);

float scale = 1;
Expand Down Expand Up @@ -115,7 +115,14 @@ public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY
return false;
}

// TODO: add RenderContext
public void renderOverlay(RenderContext renderContext, int x, int y, int width) {
this.renderOverlay(x, y, width);
}

/**
* Use {@link #renderOverlay(RenderContext, int, int, int)} instead.
*/
@Deprecated
public void renderOverlay(int x, int y, int width) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ public void render() {
int finalOptionWidth = optionWidth;
ContextAware.wrapErrorWithContext(editor, () -> {
editor.renderOverlay(
context,
finalX,
finalY,
finalOptionWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ public final boolean mouseInputOverlay(int x, int y, int width, int mouseX, int
}

@Override
public final void renderOverlay(int x, int y, int width) {
public final void renderOverlay(RenderContext context, int x, int y, int width) {
if (overlay == null) return;
overlay.foldRecursive((Void) null, (comp, _void) -> {
comp.setContext(getDelegate().getContext());
return _void;
});
val ctx = getImmContext(overlayX, overlayY, overlay.getWidth(), overlay.getHeight(), IMinecraft.instance.provideTopLevelRenderContext());
val ctx = getImmContext(overlayX, overlayY, overlay.getWidth(), overlay.getHeight(), context);
ctx.getRenderContext().translate(overlayX, overlayY, 0);
overlay.render(ctx);
}
Expand Down
Loading

0 comments on commit df7ca08

Please sign in to comment.