fix(resource-pack-entry-widgets): respect scrollbar
This commit is contained in:
parent
b0a996c4f4
commit
0be3b7812e
@ -18,6 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class ResourcePackEntryMixin {
|
||||
@Shadow protected abstract boolean isSelectable();
|
||||
@Shadow @Final private ResourcePackOrganizer.Pack pack;
|
||||
@Shadow @Final private PackListWidget widget;
|
||||
@Unique int libjf$selected = -1;
|
||||
@Unique private Boolean fold;
|
||||
@Unique int libjf$foldTicks = 0;
|
||||
@ -26,11 +27,11 @@ public abstract class ResourcePackEntryMixin {
|
||||
@Inject(at = @At("TAIL"), method = "render(Lnet/minecraft/client/gui/DrawContext;IIIIIIIZF)V")
|
||||
private void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta, CallbackInfo info) {
|
||||
int prevMargin = 0;
|
||||
int deltaX = 2;
|
||||
int deltaX = 2 + (widget.getMaxScroll() > 0 ? 6 : 0);
|
||||
boolean selectable = isSelectable();
|
||||
libjf$selected = -1;
|
||||
if (libjf$foldTicks == maxFoldTicks) {
|
||||
context.drawGuiTexture(Identifier.ofVanilla("transferable_list/unselect"), x + entryWidth - 20, y + entryWidth / 20 - 16, 16, 32);
|
||||
context.drawGuiTexture(Identifier.ofVanilla("transferable_list/unselect"), x + entryWidth - 16 - deltaX, y + entryWidth / 20 - 16, 16, 32);
|
||||
} else {
|
||||
for (int i = 0; i < ResourcePackEntryWidget.WIDGETS.size(); i++) {
|
||||
ResourcePackEntryWidget widget = ResourcePackEntryWidget.WIDGETS.get(i);
|
||||
@ -47,7 +48,7 @@ public abstract class ResourcePackEntryMixin {
|
||||
prevMargin = widget.getXMargin(pack);
|
||||
}
|
||||
}
|
||||
if (fold == null) fold = deltaX > 42; // set only once to prevent flickering
|
||||
if (fold == null) fold = deltaX > 48; // set only once to prevent flickering
|
||||
if (!fold) return;
|
||||
int mouseRange = Math.max(10, deltaX) + 40;
|
||||
if (mouseX >= x + entryWidth - mouseRange && mouseX <= x + entryWidth && mouseY <= y + entryHeight && mouseY >= y) libjf$foldTicks = Math.max(libjf$foldTicks - 1, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user