From 0121bd9039a1865c74dd7b9f739138c20e015826 Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+geometrically@users.noreply.github.com> Date: Fri, 12 Jun 2020 11:10:04 +0100 Subject: [PATCH] Move creative pagination buttons (#639) * Move creative pagination buttons * Bump module version + Update Texture * Remove Krita Autogenerated File * Add Hover and Update Texture * Fix button positions * Fix checkstyle --- fabric-item-groups-v0/build.gradle | 2 +- .../item/group/FabricCreativeGuiComponents.java | 10 +++++++--- .../client/MixinCreativePlayerInventoryGui.java | 6 +++--- .../fabric/textures/gui/creative_buttons.png | Bin 859 -> 552 bytes 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/fabric-item-groups-v0/build.gradle b/fabric-item-groups-v0/build.gradle index 9c2cef11a..f49388cce 100644 --- a/fabric-item-groups-v0/build.gradle +++ b/fabric-item-groups-v0/build.gradle @@ -1,5 +1,5 @@ archivesBaseName = "fabric-item-groups-v0" -version = getSubprojectVersion(project, "0.1.6") +version = getSubprojectVersion(project, "0.2.0") dependencies { compile project(path: ':fabric-api-base', configuration: 'dev') diff --git a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/impl/item/group/FabricCreativeGuiComponents.java b/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/impl/item/group/FabricCreativeGuiComponents.java index 3f257ab73..eaf125e96 100644 --- a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/impl/item/group/FabricCreativeGuiComponents.java +++ b/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/impl/item/group/FabricCreativeGuiComponents.java @@ -45,7 +45,7 @@ public class FabricCreativeGuiComponents { Type type; public ItemGroupButtonWidget(int x, int y, Type type, CreativeGuiExtensions extensions) { - super(x, y, 10, 11, type.text, (bw) -> type.clickConsumer.accept(extensions)); + super(x, y, 11, 10, type.text, (bw) -> type.clickConsumer.accept(extensions)); this.extensions = extensions; this.type = type; this.gui = (CreativeInventoryScreen) extensions; @@ -53,17 +53,21 @@ public class FabricCreativeGuiComponents { @Override public void render(int mouseX, int mouseY, float float_1) { + this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; this.visible = extensions.fabric_isButtonVisible(type); this.active = extensions.fabric_isButtonEnabled(type); if (this.visible) { + int u = active && this.isHovered() ? 22 : 0; + int v = active ? 0 : 10; + MinecraftClient minecraftClient = MinecraftClient.getInstance(); minecraftClient.getTextureManager().bindTexture(BUTTON_TEX); RenderSystem.disableLighting(); RenderSystem.color4f(1F, 1F, 1F, 1F); - this.blit(this.x, this.y, (type == Type.NEXT ? 12 : 0), (active ? 0 : 12), 12, 12); + this.blit(this.x, this.y, u + (type == Type.NEXT ? 11 : 0), v, 11, 10); - if (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height) { + if (this.isHovered) { gui.renderTooltip(I18n.translate("fabric.gui.creativeTabPage", extensions.fabric_currentPage() + 1, ((ItemGroup.GROUPS.length - 12) / 9) + 2), mouseX, mouseY); } } diff --git a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/mixin/item/group/client/MixinCreativePlayerInventoryGui.java b/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/mixin/item/group/client/MixinCreativePlayerInventoryGui.java index f6b48ee9f..50c48cb28 100644 --- a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/mixin/item/group/client/MixinCreativePlayerInventoryGui.java +++ b/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/mixin/item/group/client/MixinCreativePlayerInventoryGui.java @@ -119,10 +119,10 @@ public abstract class MixinCreativePlayerInventoryGui extends AbstractInventoryS private void init(CallbackInfo info) { fabric_updateSelection(); - int xpos = x + 170; - int ypos = y + 4; + int xpos = x + 116; + int ypos = y - 10; - addButton(new FabricCreativeGuiComponents.ItemGroupButtonWidget(xpos + 10, ypos, FabricCreativeGuiComponents.Type.NEXT, this)); + addButton(new FabricCreativeGuiComponents.ItemGroupButtonWidget(xpos + 11, ypos, FabricCreativeGuiComponents.Type.NEXT, this)); addButton(new FabricCreativeGuiComponents.ItemGroupButtonWidget(xpos, ypos, FabricCreativeGuiComponents.Type.PREVIOUS, this)); } diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/textures/gui/creative_buttons.png b/fabric-item-groups-v0/src/main/resources/assets/fabric/textures/gui/creative_buttons.png index 1c28eaccdfc99a4d4f17d9581809717b0e5da4ca..27b9a1499ec857ad5ccebcc442b7ad5ca995b99d 100644 GIT binary patch literal 552 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5FjO4;u=vBoS#-wo>-L1;Fyx1 zl&avFo0y&&l$w}QS$Hzl2B=6Pz$e62TU)!kyZitD|3HDJ?gOErp=pK7fb2+txPBnT zQ4-`A43q@{hI`F>BY`$e@^o;cw79Pj!0`G?6e>JP63-&HywBS`ZcJZ-KgGPgeph8*$!vjugTe~DWM4f1-NUU literal 859 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911L)MWvCLm?NMQuI!I^B)Bd0B$?ix0SZZ$xJHyX=jZ08=9Mrw7o{eaq^2m8XO?6rxO@5rgg5eu zGcYh+^>lFzskrs_*52Ia0Fj1^?jk3>H!%J-VCRi%YO|DRG0hOrRi2>c6j=Ac*=f`L z)0U!5-K&3}RM^cSesi0yL)JZKj>85rK37U*Etx&p1e_#}f4qMBvdP=yhQ<@7ZJ)n< z)-ua|&mS@@k#e|fQhQ(i{^jp`*-jWV%y@g9p^{Bt|6eJE!wl#2zT8ZBa8B>LwZSr&P0w3mW^K(QLTQ=$Nt39jioB1)EBZ&8b5R<}51|7Y7j1CM6 z3<3-s3@i*x42%s7ROZsgR3!HzF{$iyu*p;p5DfQ{7U~Vle>3QKcQkhy?YaWY1q`09 KelF{r5}E)`%gO%$