impr(tab): user creative inventory tab asset and layout

This allow proprely textured GUI without the need to update a resourcepack.
This commit is contained in:
Léa Gris authored and Jason Mitchell committed 2021-03-22 19:02:42 -07:00
1 parent 07ec5f67c5
commit 400f38d919
3 files changed
+27 -23

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

+7 -7
View File
@@ -22,10 +22,10 @@ public class GuiRecipeTab extends Widget {
public static HashMap<String, ImmutablePair<String, DrawableResource>> imageMap = new HashMap<>();
public static HashMap<String, ImmutablePair<String, ItemStack>> stackMap = new HashMap<>();
public static final int TAB_WIDTH = 24;
public static final int TAB_HEIGHT = 24;
private static final DrawableResource selectedIcon = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 16, 24, 24).build();
private static final DrawableResource unselectedIcon = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 24, 16, 24, 24).build();
public static final int TAB_WIDTH = 28;
public static final int TAB_HEIGHT = 31;
private static final DrawableResource selectedIcon = new DrawableBuilder("minecraft:textures/gui/container/creative_inventory/tabs.png", 28, 32, 28, 32).build();
private static final DrawableResource unselectedIcon = new DrawableBuilder("minecraft:textures/gui/container/creative_inventory/tabs.png", 28, 0, 28, 30).build();
private final GuiRecipe guiRecipe;
private final IRecipeHandler handler;
@@ -66,13 +66,13 @@ public class GuiRecipeTab extends Widget {
else image = unselectedIcon;
final int iconX = x + (w - image.getWidth()) / 2;
final int iconY = y + (h - image.getHeight()) / 2;
final int iconY = y;
image.draw(iconX, iconY);
}
public void drawForeground(int mouseX, int mouseY) {
final int iconX = x + 4;
final int iconY = y + 4;
final int iconX = x + (w - 16) / 2;
final int iconY = y + h - 22;
final FontRenderer fontRenderer = GuiDraw.fontRenderer;
final DrawableResource icon = getImage(handlerName);
+20 -16
View File
@@ -2,8 +2,9 @@ package codechicken.nei.recipe;
import codechicken.nei.Button;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import java.awt.Rectangle;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
@@ -38,7 +39,7 @@ public class GuiRecipeTabs {
area.width = totalWidth;
area.height = GuiRecipeTab.TAB_HEIGHT;
area.x = guiRecipe.guiLeft + 2;
area.x = guiRecipe.guiLeft + 4;
area.y = guiRecipe.guiTop - GuiRecipeTab.TAB_HEIGHT + 3;
pageCount = (int) Math.ceil((float) numHandlers / categoriesPerPage);
@@ -56,51 +57,54 @@ public class GuiRecipeTabs {
tabs.clear();
buttons.clear();
int tabX = area.x;
final int startIndex = pageNumber * categoriesPerPage;
for (int i = 0 ; i < categoriesPerPage ; i++) {
final int index = i + startIndex;
if (index >= numHandlers) break;
IRecipeHandler handler = guiRecipe.currenthandlers.get(index);
int tabX = area.x + (i * GuiRecipeTab.TAB_WIDTH);
tabs.add(new GuiRecipeTab(guiRecipe, handler, tabX, area.y));
tabX += GuiRecipeTab.TAB_WIDTH;
}
// Maybe add buttons
if (numHandlers > categoriesPerPage) {
Button prevTab = new Button("prevTab") {
@Override
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) return previousPage();
else return false;
public boolean onButtonPress(boolean rightClick) {
if (!rightClick) {
NEIClientUtils.playClickSound();
return previousPage();
} else return false;
}
@Override
public String getRenderLabel() {
return "<";
}
};
prevTab.x = area.x - 7;
prevTab.y = area.y + 2;
prevTab.h = 20;
prevTab.w = 8;
prevTab.h = GuiRecipeTab.TAB_HEIGHT - 4;
prevTab.x = area.x - prevTab.w;
prevTab.y = area.y + 4;
buttons.add(prevTab);
Button nextTab = new Button("nextTab") {
@Override
public boolean onButtonPress(boolean rightclick) {
if(!rightclick) return nextPage();
else return false;
if (!rightclick) {
NEIClientUtils.playClickSound();
return nextPage();
} else return false;
}
@Override
public String getRenderLabel() {
return ">";
}
};
nextTab.w = prevTab.w;
nextTab.h = prevTab.h;
nextTab.x = area.x + area.width;
nextTab.y = area.y + 2;
nextTab.h = 20;
nextTab.w = 8;
nextTab.y = prevTab.y;
buttons.add(nextTab);
}
}