Skip to content

Commit d394177

Browse files
committed
Improved tab page buttons
1 parent 2812b87 commit d394177

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

Diff for: client/gui/GuiCreativeInventory.java

+16-20
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public class GuiCreativeInventory extends GuiBasicInventory
6565
private static int tabPage = 0;
6666
private int maxPages = 0;
6767

68+
protected GuiButton buttonPrevPage;
69+
protected GuiButton buttonNextPage;
70+
6871
// PIAPI
6972

7073
public static int windowWidth = 195;
@@ -127,6 +130,9 @@ public void updateScreen()
127130
{
128131
this.mc.displayGuiScreen(new GuiSurvivalInventory(this.player, (ContainerInventory) this.player.inventoryContainer));
129132
}
133+
134+
this.buttonPrevPage.enabled = tabPage > 0;
135+
this.buttonNextPage.enabled = tabPage < this.maxPages;
130136
}
131137

132138
@Override
@@ -157,8 +163,8 @@ public void initGui()
157163
int tabCount = CreativeTabs.creativeTabArray.length;
158164
if (tabCount > 12)
159165
{
160-
this.buttonList.add(new GuiButton(101, this.guiLeft, this.guiTop - 50, 20, 20, "<"));
161-
this.buttonList.add(new GuiButton(102, this.guiLeft + this.xSize - 20, this.guiTop - 50, 20, 20, ">"));
166+
this.buttonList.add(this.buttonPrevPage = new GuiButton(0, this.guiLeft, this.guiTop - 50, 20, 20, "<"));
167+
this.buttonList.add(this.buttonNextPage = new GuiButton(1, this.guiLeft + this.xSize - 20, this.guiTop - 50, 20, 20, ">"));
162168
this.maxPages = (tabCount - 12) / 10 + 1;
163169
}
164170
}
@@ -397,7 +403,8 @@ public void drawScreen(int mouseX, int mouseY, float partialTickTime)
397403
{
398404
s = "Clear Inventory";
399405
}
400-
else {
406+
else
407+
{
401408
s = I18n.getString("inventory.binSlot");
402409
}
403410
this.drawCreativeTabHoveringText(s, mouseX, mouseY);
@@ -645,7 +652,7 @@ protected void renderToolTip(ItemStack stack, int x, int y)
645652
list.set(0, stack.getRarity().rarityColor + list.get(0));
646653
for (int k = 1; k < list.size(); ++k)
647654
{
648-
list.set(k, EnumChatFormatting.GRAY + list.get(k));
655+
list.set(k, EnumChatFormatting.GRAY + list.get(k));
649656
}
650657

651658
FontRenderer font = stack.getItem().getFontRenderer(stack);
@@ -1024,24 +1031,13 @@ public void actionPerformed(GuiButton button)
10241031

10251032
if (button.id == 0)
10261033
{
1027-
this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter()));
1034+
if (tabPage > 0)
1035+
tabPage--;
10281036
}
1029-
1030-
if (button.id == 1)
1037+
else if (button.id == 1)
10311038
{
1032-
this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter()));
1033-
}
1034-
1035-
if (button.id == 101)
1036-
{
1037-
tabPage = Math.max(tabPage - 1, 0);
1038-
}
1039-
else
1040-
{
1041-
if (button.id == 102)
1042-
{
1043-
tabPage = Math.min(tabPage + 1, this.maxPages);
1044-
}
1039+
if (tabPage < this.maxPages)
1040+
tabPage++;
10451041
}
10461042
}
10471043

0 commit comments

Comments
 (0)