diff --git a/resources/assets/nei/lang/en_US.lang b/resources/assets/nei/lang/en_US.lang index 1746cfb5..0f567c62 100644 --- a/resources/assets/nei/lang/en_US.lang +++ b/resources/assets/nei/lang/en_US.lang @@ -114,6 +114,9 @@ nei.options.inventory.bookmarksEnabled.false=Hidden nei.options.inventory.jei_style_tabs=JEI Style Tabs nei.options.inventory.jei_style_tabs.true=Yes nei.options.inventory.jei_style_tabs.false=No [Weirdo] +nei.options.inventory.creative_tab_style=Creative or JEI tab style +nei.options.inventory.creative_tab_style.true=Creative +nei.options.inventory.creative_tab_style.false=JEI nei.options.inventory.widgetsenabled.true=NEI Enabled nei.options.inventory.widgetsenabled.false=NEI Disabled nei.options.inventory.cheatmode.0=Recipe Mode diff --git a/src/codechicken/nei/NEIClientConfig.java b/src/codechicken/nei/NEIClientConfig.java index fc26781e..b174fc79 100644 --- a/src/codechicken/nei/NEIClientConfig.java +++ b/src/codechicken/nei/NEIClientConfig.java @@ -78,7 +78,7 @@ public class NEIClientConfig tag.getTag("inventory.widgetsenabled").getBooleanValue(true); API.addOption(new OptionToggleButton("inventory.widgetsenabled")); - + tag.getTag("inventory.hidden").getBooleanValue(false); tag.getTag("inventory.cheatmode").getIntValue(2); tag.getTag("inventory.lockmode").setComment("For those who can't help themselves.\nSet this to a mode and you will be unable to change it ingame").getIntValue(-1); @@ -130,6 +130,9 @@ public class NEIClientConfig tag.getTag("inventory.jei_style_tabs").setComment("Enable/disable JEI Style Tabs").getBooleanValue(true); API.addOption(new OptionToggleButtonBoubs("inventory.jei_style_tabs", true)); + tag.getTag("inventory.creative_tab_style").setComment("Creative or JEI style tabs").getBooleanValue(false); + API.addOption(new OptionToggleButton("inventory.creative_tab_style", true)); + setDefaultKeyBindings(); } @@ -294,6 +297,9 @@ public class NEIClientConfig public static boolean areJEIStyleTabsVisible() { return getBooleanSetting("inventory.jei_style_tabs"); } + public static boolean useCreativeTabStyle() { + return getBooleanSetting("inventory.creative_tab_style"); + } public static boolean isEnabled() { return enabledOverride && getBooleanSetting("inventory.widgetsenabled"); } diff --git a/src/codechicken/nei/recipe/GuiRecipeTab.java b/src/codechicken/nei/recipe/GuiRecipeTab.java index fcd2bf09..04fc01a5 100644 --- a/src/codechicken/nei/recipe/GuiRecipeTab.java +++ b/src/codechicken/nei/recipe/GuiRecipeTab.java @@ -18,14 +18,9 @@ import org.lwjgl.opengl.GL11; import java.util.HashMap; import java.util.List; -public class GuiRecipeTab extends Widget { +public abstract class GuiRecipeTab extends Widget { public static HashMap> imageMap = new HashMap<>(); public static HashMap> stackMap = new HashMap<>(); - - 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; @@ -33,13 +28,23 @@ public class GuiRecipeTab extends Widget { private final String handlerID; private boolean selected; + + public abstract int getWidth(); + public abstract int getHeight(); + + public abstract DrawableResource getSelectedTabImage(); + public abstract DrawableResource getUnselectedTabImage(); + + protected abstract int getForegroundIconX(); + protected abstract int getForegroundIconY(); + public GuiRecipeTab(GuiRecipe guiRecipe, IRecipeHandler handler, int x, int y) { super(); this.x = x; this.y = y; - this.w = TAB_WIDTH; - this.h = TAB_HEIGHT; + this.w = getWidth(); + this.h = getHeight(); this.handler = handler; this.handlerName = handler.toString().split("@")[0]; this.guiRecipe = guiRecipe; @@ -62,17 +67,17 @@ public class GuiRecipeTab extends Widget { GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor4f(1, 1, 1, 1); final DrawableResource image; - if (selected) image = selectedIcon; - else image = unselectedIcon; + if (selected) image = getSelectedTabImage(); + else image = getUnselectedTabImage(); final int iconX = x + (w - image.getWidth()) / 2; - final int iconY = y; + final int iconY = y + (h - image.getHeight()) / 2; image.draw(iconX, iconY); } public void drawForeground(int mouseX, int mouseY) { - final int iconX = x + (w - 16) / 2; - final int iconY = y + h - 22; + final int iconX = getForegroundIconX(); + final int iconY = getForegroundIconY(); final FontRenderer fontRenderer = GuiDraw.fontRenderer; final DrawableResource icon = getImage(handlerName); @@ -89,8 +94,8 @@ public class GuiRecipeTab extends Widget { } else { // Text fallback String text = handler.getRecipeName().substring(0, 2); - int textCenterX = x + (int) (TAB_WIDTH / 2f); - int textCenterY = y + (int) (TAB_HEIGHT / 2f) - 3; + int textCenterX = x + (int) (getWidth() / 2f); + int textCenterY = y + (int) (getHeight() / 2f) - 3; int color = selected ? 0xffffa0 : 0xe0e0e0; fontRenderer.drawStringWithShadow(text, textCenterX - (int) (fontRenderer.getStringWidth(text) / 2f), textCenterY, color); GL11.glColor4f(1, 1, 1, 1); diff --git a/src/codechicken/nei/recipe/GuiRecipeTabCreative.java b/src/codechicken/nei/recipe/GuiRecipeTabCreative.java new file mode 100644 index 00000000..0d121c38 --- /dev/null +++ b/src/codechicken/nei/recipe/GuiRecipeTabCreative.java @@ -0,0 +1,47 @@ +package codechicken.nei.recipe; + + +import codechicken.nei.drawable.DrawableBuilder; +import codechicken.nei.drawable.DrawableResource; + +public class GuiRecipeTabCreative extends GuiRecipeTab { + public static final int TAB_WIDTH = 28; + public static final int TAB_HEIGHT = 31; + private static final DrawableResource selectedTabImage = new DrawableBuilder("minecraft:textures/gui/container/creative_inventory/tabs.png", 28, 32, 28, 32).build(); + private static final DrawableResource unselectedTabImage = new DrawableBuilder("minecraft:textures/gui/container/creative_inventory/tabs.png", 28, 0, 28, 30).build(); + + public GuiRecipeTabCreative(GuiRecipe guiRecipe, IRecipeHandler handler, int x, int y) { + super(guiRecipe, handler, x, y); + } + + @Override + public int getWidth() { + return TAB_WIDTH; + } + + @Override + public int getHeight() { + return TAB_HEIGHT; + } + + @Override + protected int getForegroundIconX() { + return x + (w - 16) / 2; + } + + @Override + protected int getForegroundIconY() { + return y + h - 22; + } + + @Override + public DrawableResource getSelectedTabImage() { + return selectedTabImage; + } + + @Override + public DrawableResource getUnselectedTabImage() { + return unselectedTabImage; + } + +} diff --git a/src/codechicken/nei/recipe/GuiRecipeTabJEI.java b/src/codechicken/nei/recipe/GuiRecipeTabJEI.java new file mode 100644 index 00000000..e15e90c3 --- /dev/null +++ b/src/codechicken/nei/recipe/GuiRecipeTabJEI.java @@ -0,0 +1,47 @@ +package codechicken.nei.recipe; + + +import codechicken.nei.drawable.DrawableBuilder; +import codechicken.nei.drawable.DrawableResource; + +public class GuiRecipeTabJEI extends GuiRecipeTab { + public static final int TAB_WIDTH = 24; + public static final int TAB_HEIGHT = 24; + private static final DrawableResource selectedTabImage = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 16, 24, 24).build(); + private static final DrawableResource unselectedTabImage = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 24, 16, 24, 24).build(); + + public GuiRecipeTabJEI(GuiRecipe guiRecipe, IRecipeHandler handler, int x, int y) { + super(guiRecipe, handler, x, y); + } + + @Override + public int getWidth() { + return TAB_WIDTH; + } + + @Override + public int getHeight() { + return TAB_HEIGHT; + } + + @Override + protected int getForegroundIconX() { + return x + 4; + } + + @Override + protected int getForegroundIconY() { + return y + 4; + } + + @Override + public DrawableResource getSelectedTabImage() { + return selectedTabImage; + } + + @Override + public DrawableResource getUnselectedTabImage() { + return unselectedTabImage; + } + +} diff --git a/src/codechicken/nei/recipe/GuiRecipeTabs.java b/src/codechicken/nei/recipe/GuiRecipeTabs.java index d20659c5..aa43fe1d 100644 --- a/src/codechicken/nei/recipe/GuiRecipeTabs.java +++ b/src/codechicken/nei/recipe/GuiRecipeTabs.java @@ -14,23 +14,37 @@ public class GuiRecipeTabs { private final List