aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/gui
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2018-12-30 20:10:36 +0800
committerUnknown <shekwancheung0528@gmail.com>2018-12-30 20:10:36 +0800
commit3e1f4333a51513b440b32adfe9b698590fbf76f5 (patch)
treecf337b4e12df85cd30d25721bab6c1ba1f4591f8 /src/main/java/me/shedaniel/gui
parent814e2e94ad643f04576ab0569c4b94f96b275f51 (diff)
downloadRoughlyEnoughItems-3e1f4333a51513b440b32adfe9b698590fbf76f5.tar.gz
RoughlyEnoughItems-3e1f4333a51513b440b32adfe9b698590fbf76f5.tar.bz2
RoughlyEnoughItems-3e1f4333a51513b440b32adfe9b698590fbf76f5.zip
Better stuff
Diffstat (limited to 'src/main/java/me/shedaniel/gui')
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/Drawable.java4
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/GuiItemList.java136
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/REIRenderHelper.java (renamed from src/main/java/me/shedaniel/gui/AEIRenderHelper.java)84
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/RecipeGui.java106
-rw-r--r--src/main/java/me/shedaniel/gui/SearchArgument.java35
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/widget/Button.java4
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/widget/Control.java19
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/widget/REISlot.java (renamed from src/main/java/me/shedaniel/gui/widget/AEISlot.java)39
-rw-r--r--src/main/java/me/shedaniel/gui/widget/Tab.java101
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/widget/TextBox.java10
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/widget/WidgetArrow.java4
11 files changed, 404 insertions, 138 deletions
diff --git a/src/main/java/me/shedaniel/gui/Drawable.java b/src/main/java/me/shedaniel/gui/Drawable.java
index 8fffc17af..76d49e049 100755
--- a/src/main/java/me/shedaniel/gui/Drawable.java
+++ b/src/main/java/me/shedaniel/gui/Drawable.java
@@ -22,10 +22,10 @@ public abstract class Drawable implements IDrawable {
public abstract void draw();
public boolean isHighlighted() {
- Point mousePoint = AEIRenderHelper.getMouseLoc();
+ Point mousePoint = REIRenderHelper.getMouseLoc();
if (rect.contains(mousePoint.x, mousePoint.y)) {
if (this instanceof Control)
- AEIRenderHelper.aeiGui.setLastHovered((Control) this);
+ REIRenderHelper.reiGui.setLastHovered((Control) this);
return true;
}
return false;
diff --git a/src/main/java/me/shedaniel/gui/GuiItemList.java b/src/main/java/me/shedaniel/gui/GuiItemList.java
index 80666f2cb..f23ab9f85 100755
--- a/src/main/java/me/shedaniel/gui/GuiItemList.java
+++ b/src/main/java/me/shedaniel/gui/GuiItemList.java
@@ -1,9 +1,9 @@
package me.shedaniel.gui;
import me.shedaniel.ClientListener;
-import me.shedaniel.gui.widget.AEISlot;
import me.shedaniel.gui.widget.Button;
import me.shedaniel.gui.widget.Control;
+import me.shedaniel.gui.widget.REISlot;
import me.shedaniel.gui.widget.TextBox;
import me.shedaniel.listenerdefinitions.IMixinGuiContainer;
import net.minecraft.client.MainWindow;
@@ -19,13 +19,17 @@ import net.minecraft.util.text.TextComponentTranslation;
import java.awt.*;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class GuiItemList extends Drawable {
public static final int FOOTERSIZE = 44;
private GuiContainer overlayedGui;
private static int page = 0;
- private ArrayList<AEISlot> displaySlots;
+ private ArrayList<REISlot> displaySlots;
protected ArrayList<Control> controls;
private boolean needsResize = false;
Button buttonLeft;
@@ -60,14 +64,14 @@ public class GuiItemList extends Drawable {
}
private static Rectangle calculateRect(GuiContainer overlayedGui) {
- MainWindow res = AEIRenderHelper.getResolution();
+ MainWindow res = REIRenderHelper.getResolution();
int startX = (((IMixinGuiContainer) overlayedGui).getGuiLeft() + ((IMixinGuiContainer) overlayedGui).getXSize()) + 10;
int width = res.getScaledWidth() - startX;
return new Rectangle(startX, 0, width, res.getScaledHeight());
}
protected void resize() {
- MainWindow res = AEIRenderHelper.getResolution();
+ MainWindow res = REIRenderHelper.getResolution();
if (overlayedGui != Minecraft.getInstance().currentScreen) {
if (Minecraft.getInstance().currentScreen instanceof GuiContainer) {
@@ -117,25 +121,42 @@ public class GuiItemList extends Drawable {
}
private void calculateSlots() {
- int x = rect.x;
- int y = rect.y + 20;
- MainWindow res = AEIRenderHelper.getResolution();
+ int x = rect.x, y = rect.y + 20;
+ MainWindow res = REIRenderHelper.getResolution();
displaySlots.clear();
- int xOffset = 4;
- int yOffset = 4;
+ int xOffset = 0, yOffset = 0, row = 0, perRow = 0, currentX = 0, currentY = 0;
while (true) {
- AEISlot slot = new AEISlot(x + xOffset, y + yOffset);
- slot.setCheatable(true);
xOffset += 18;
- displaySlots.add(slot);
- if (x + xOffset + 18 > res.getScaledWidth()) {
- xOffset = 4;
+ if (row == 0)
+ perRow++;
+ if (x + xOffset + 22 > res.getScaledWidth()) {
+ xOffset = 0;
yOffset += 18;
+ row++;
}
if (y + yOffset + 9 + FOOTERSIZE > rect.height) {
+ xOffset = 0;
+ yOffset = 0;
break;
}
}
+ x += (rect.width - perRow * 18) / 2;
+ y += (rect.height - FOOTERSIZE - 2 - row * 18) / 2;
+ while (true) {
+ REISlot slot = new REISlot(x + xOffset, y + yOffset);
+ slot.setCheatable(true);
+ xOffset += 18;
+ currentX++;
+ displaySlots.add(slot);
+ if (currentX >= perRow) {
+ xOffset = 0;
+ yOffset += 18;
+ currentX = 0;
+ currentY++;
+ }
+ if (currentY >= row)
+ break;
+ }
}
@Override
@@ -196,52 +217,70 @@ public class GuiItemList extends Drawable {
private String getCheatModeText() {
if (cheatMode) {
- TextComponentTranslation cheat = new TextComponentTranslation("text.aei.cheat", new Object[]{null});
+ TextComponentTranslation cheat = new TextComponentTranslation("text.rei.cheat", new Object[]{null});
return cheat.getFormattedText();
}
- TextComponentTranslation noCheat = new TextComponentTranslation("text.aei.nocheat", new Object[]{null});
+ TextComponentTranslation noCheat = new TextComponentTranslation("text.rei.nocheat", new Object[]{null});
return noCheat.getFormattedText();
}
protected void updateView() {
String searchText = searchBox.getText();
- String modText = null;
- if (searchText.contains("@")) {
- int nextBreak = searchText.indexOf(' ', searchText.indexOf('@'));
- if (nextBreak == 0 || nextBreak == -1)
- nextBreak = searchText.length();
- modText = searchText.substring(searchText.indexOf('@'), nextBreak);
- searchText = searchText.replace(modText, "").trim();
- modText = modText.replace("@", "").toLowerCase();
- }
-
view.clear();
- if (searchText.equals("") || searchText == null) {
- for(ItemStack stack : ClientListener.stackList) {
- if (modText != null) {
- if (getMod(stack).contains(modText)) {
- view.add(stack);
- }
- } else {
- view.add(stack);
- }
- }
- } else {
- for(ItemStack stack : ClientListener.stackList) {
- if (stack.getItem().getName().getString().toLowerCase().contains(searchText))
- if (modText != null) {
- if (getMod(stack).contains(modText)) {
- view.add(stack);
- }
- } else {
- view.add(stack);
- }
- }
- }
+ List<ItemStack> stacks = new ArrayList<>();
+ Arrays.stream(searchText.split("\\|")).forEachOrdered(s -> {
+ List<SearchArgument> arguments = new ArrayList<>();
+ while (s.startsWith(" ")) s = s.substring(1);
+ while (s.endsWith(" ")) s = s.substring(0, s.length());
+ if (s.startsWith("@-") || s.startsWith("-@"))
+ arguments.add(new SearchArgument(SearchArgument.ArgumentType.MOD, s.substring(2), false));
+ else if (s.startsWith("@"))
+ arguments.add(new SearchArgument(SearchArgument.ArgumentType.MOD, s.substring(1), true));
+ else if (s.startsWith("#-") || s.startsWith("-#"))
+ arguments.add(new SearchArgument(SearchArgument.ArgumentType.TOOLTIP, s.substring(2), false));
+ else if (s.startsWith("#"))
+ arguments.add(new SearchArgument(SearchArgument.ArgumentType.TOOLTIP, s.substring(1), true));
+ else if (s.startsWith("-"))
+ arguments.add(new SearchArgument(SearchArgument.ArgumentType.TEXT, s.substring(1), false));
+ else
+ arguments.add(new SearchArgument(SearchArgument.ArgumentType.TEXT, s, true));
+ ClientListener.stackList.stream().filter(itemStack -> filterItem(itemStack, arguments)).forEachOrdered(stacks::add);
+ });
+ view.addAll(stacks.stream().distinct().collect(Collectors.toList()));
page = 0;
fillSlots();
}
+ private boolean filterItem(ItemStack itemStack, List<SearchArgument> arguments) {
+ String mod = getMod(itemStack);
+ List<String> toolTipsList = REIRenderHelper.getOverlayedGui().getItemToolTip(itemStack);
+ String toolTipsMixed = toolTipsList.stream().skip(1).collect(Collectors.joining()).toLowerCase();
+ String allMixed = Stream.of(itemStack.getDisplayName().getString(), toolTipsMixed).collect(Collectors.joining()).toLowerCase();
+ for(SearchArgument searchArgument : arguments.stream().filter(searchArgument -> !searchArgument.isInclude()).collect(Collectors.toList())) {
+ if (searchArgument.getArgumentType().equals(SearchArgument.ArgumentType.MOD))
+ if (mod.toLowerCase().contains(searchArgument.getText().toLowerCase()))
+ return false;
+ if (searchArgument.getArgumentType().equals(SearchArgument.ArgumentType.TOOLTIP))
+ if (toolTipsMixed.contains(searchArgument.getText().toLowerCase()))
+ return false;
+ if (searchArgument.getArgumentType().equals(SearchArgument.ArgumentType.TEXT))
+ if (allMixed.contains(searchArgument.getText().toLowerCase()))
+ return false;
+ }
+ for(SearchArgument searchArgument : arguments.stream().filter(SearchArgument::isInclude).collect(Collectors.toList())) {
+ if (searchArgument.getArgumentType().equals(SearchArgument.ArgumentType.MOD))
+ if (!mod.toLowerCase().contains(searchArgument.getText().toLowerCase()))
+ return false;
+ if (searchArgument.getArgumentType().equals(SearchArgument.ArgumentType.TOOLTIP))
+ if (!toolTipsMixed.contains(searchArgument.getText().toLowerCase()))
+ return false;
+ if (searchArgument.getArgumentType().equals(SearchArgument.ArgumentType.TEXT))
+ if (!allMixed.contains(searchArgument.getText().toLowerCase()))
+ return false;
+ }
+ return true;
+ }
+
public void tick() {
controls.forEach(f -> f.tick());
}
@@ -261,4 +300,5 @@ public class GuiItemList extends Drawable {
}
return "";
}
+
}
diff --git a/src/main/java/me/shedaniel/gui/AEIRenderHelper.java b/src/main/java/me/shedaniel/gui/REIRenderHelper.java
index 3ffbc7d82..74f8c1b02 100755
--- a/src/main/java/me/shedaniel/gui/AEIRenderHelper.java
+++ b/src/main/java/me/shedaniel/gui/REIRenderHelper.java
@@ -1,9 +1,9 @@
package me.shedaniel.gui;
-import me.shedaniel.gui.widget.AEISlot;
import me.shedaniel.gui.widget.Control;
import me.shedaniel.gui.widget.IFocusable;
-import me.shedaniel.impl.AEIRecipeManager;
+import me.shedaniel.gui.widget.REISlot;
+import me.shedaniel.impl.REIRecipeManager;
import me.shedaniel.library.KeyBindManager;
import me.shedaniel.listenerdefinitions.IMixinGuiContainer;
import net.minecraft.client.MainWindow;
@@ -13,6 +13,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.item.ItemStack;
+import org.dimdev.riftloader.RiftLoader;
import java.awt.*;
import java.util.ArrayList;
@@ -23,9 +24,9 @@ import java.util.Optional;
/**
* Created by James on 7/28/2018.
*/
-public class AEIRenderHelper {
+public class REIRenderHelper {
static Point mouseLoc;
- static public GuiItemList aeiGui;
+ static public GuiItemList reiGui;
static GuiContainer overlayedGui;
static List<TooltipData> tooltipsToRender = new ArrayList<>();
@@ -40,25 +41,36 @@ public class AEIRenderHelper {
}
public static MainWindow getResolution() {
-
return Minecraft.getInstance().mainWindow;
}
- public static void drawAEI(GuiContainer overlayedGui) {
- AEIRenderHelper.overlayedGui = overlayedGui;
- if (aeiGui == null) {
- aeiGui = new GuiItemList(overlayedGui);
+ public static String tryGettingModName(String modid) {
+ if (modid.equalsIgnoreCase("minecraft"))
+ return "Minecraft";
+ return RiftLoader.instance.getMods().stream()
+ .filter(modInfo -> modInfo.id.equals(modid) || (modInfo.name != null && modInfo.name.equals(modid)))
+ .findFirst().map(modInfo -> {
+ if (modInfo.name != null)
+ return modInfo.name;
+ return modid;
+ }).orElse(modid);
+ }
+
+ public static void drawREI(GuiContainer overlayedGui) {
+ REIRenderHelper.overlayedGui = overlayedGui;
+ if (reiGui == null) {
+ reiGui = new GuiItemList(overlayedGui);
}
- aeiGui.draw();
+ reiGui.draw();
renderTooltips();
}
- public static void resize() {
- if (aeiGui != null) {
- aeiGui.resize();
+ public static void resize(int scaledWidth, int scaledHeight) {
+ if (reiGui != null) {
+ reiGui.resize();
}
if (overlayedGui instanceof RecipeGui) {
- overlayedGui.onResize(Minecraft.getInstance(), 0, 0);
+ overlayedGui.onResize(Minecraft.getInstance(), scaledWidth, scaledHeight);
}
}
@@ -94,8 +106,8 @@ public class AEIRenderHelper {
}
public static boolean mouseClick(int x, int y, int button) {
- if (aeiGui.visible) {
- for(Control control : aeiGui.controls) {
+ if (reiGui.visible) {
+ for(Control control : reiGui.controls) {
if (control.isHighlighted() && control.isEnabled() && control.onClick != null) {
if (focusedControl != null)
focusedControl.setFocused(false);
@@ -164,12 +176,12 @@ public class AEIRenderHelper {
}
public static boolean mouseScrolled(double direction) {
- if (!aeiGui.visible)
+ if (!reiGui.visible)
return false;
- if (direction > 0 && aeiGui.buttonLeft.isEnabled())
- aeiGui.buttonLeft.onClick.apply(0);
- else if (direction < 0 && aeiGui.buttonRight.isEnabled())
- aeiGui.buttonRight.onClick.apply(0);
+ if (direction > 0 && reiGui.buttonLeft.isEnabled())
+ reiGui.buttonLeft.onClick.apply(0);
+ else if (direction < 0 && reiGui.buttonRight.isEnabled())
+ reiGui.buttonRight.onClick.apply(0);
return true;
}
@@ -187,26 +199,26 @@ public class AEIRenderHelper {
}
public static void updateSearch() {
- aeiGui.updateView();
+ reiGui.updateView();
}
public static void tick() {
- if (aeiGui != null && Minecraft.getInstance().currentScreen == overlayedGui)
- aeiGui.tick();
+ if (reiGui != null && Minecraft.getInstance().currentScreen == overlayedGui)
+ reiGui.tick();
}
public static void recipeKeybind() {
if (!(Minecraft.getInstance().currentScreen instanceof GuiContainer))
return;
- Control control = aeiGui.getLastHovered();
- if (control != null && control.isHighlighted() && control instanceof AEISlot) {
- AEISlot slot = (AEISlot) control;
- AEIRecipeManager.instance().displayRecipesFor(slot.getStack());
+ Control control = reiGui.getLastHovered();
+ if (control != null && control.isHighlighted() && control instanceof REISlot) {
+ REISlot slot = (REISlot) control;
+ REIRecipeManager.instance().displayRecipesFor(slot.getStack());
return;
}
if (((IMixinGuiContainer) overlayedGui).getHoveredSlot() != null) {
ItemStack stack = ((IMixinGuiContainer) overlayedGui).getHoveredSlot().getStack();
- AEIRecipeManager.instance().displayRecipesFor(stack);
+ REIRecipeManager.instance().displayRecipesFor(stack);
}
}
@@ -214,22 +226,22 @@ public class AEIRenderHelper {
public static void useKeybind() {
if (!(Minecraft.getInstance().currentScreen instanceof GuiContainer))
return;
- Control control = aeiGui.getLastHovered();
- if (control != null && control.isHighlighted() && control instanceof AEISlot) {
- AEISlot slot = (AEISlot) control;
- AEIRecipeManager.instance().displayUsesFor(slot.getStack());
+ Control control = reiGui.getLastHovered();
+ if (control != null && control.isHighlighted() && control instanceof REISlot) {
+ REISlot slot = (REISlot) control;
+ REIRecipeManager.instance().displayUsesFor(slot.getStack());
return;
}
if (((IMixinGuiContainer) overlayedGui).getHoveredSlot() != null) {
ItemStack stack = ((IMixinGuiContainer) overlayedGui).getHoveredSlot().getStack();
- AEIRecipeManager.instance().displayUsesFor(stack);
+ REIRecipeManager.instance().displayUsesFor(stack);
}
}
public static void hideKeybind() {
- if (Minecraft.getInstance().currentScreen == overlayedGui && aeiGui != null) {
- aeiGui.visible = !aeiGui.visible;
+ if (Minecraft.getInstance().currentScreen == overlayedGui && reiGui != null) {
+ reiGui.visible = !reiGui.visible;
}
}
}
diff --git a/src/main/java/me/shedaniel/gui/RecipeGui.java b/src/main/java/me/shedaniel/gui/RecipeGui.java
index 6cdd9542a..43cb8333d 100755
--- a/src/main/java/me/shedaniel/gui/RecipeGui.java
+++ b/src/main/java/me/shedaniel/gui/RecipeGui.java
@@ -2,14 +2,17 @@ package me.shedaniel.gui;
import me.shedaniel.api.IDisplayCategory;
import me.shedaniel.api.IRecipe;
-import me.shedaniel.gui.widget.AEISlot;
import me.shedaniel.gui.widget.Button;
import me.shedaniel.gui.widget.Control;
+import me.shedaniel.gui.widget.REISlot;
+import me.shedaniel.gui.widget.Tab;
+import me.shedaniel.impl.REIRecipeManager;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
@@ -20,6 +23,8 @@ import java.util.List;
import java.util.Map;
public class RecipeGui extends GuiContainer {
+
+ private static final ResourceLocation CREATIVE_INVENTORY_TABS = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("almostenoughitems", "textures/gui/recipecontainer.png");
private final MainWindow mainWindow;
private final Container container;
@@ -28,12 +33,15 @@ public class RecipeGui extends GuiContainer {
private int guiWidth = 176;
private int guiHeight = 222;
ArrayList<IDisplayCategory> categories = new ArrayList<>();
- private int categoryPointer = 0;
+ private int categoryTabPage = 0;
+ private IDisplayCategory selectedCategory;
private int recipePointer = 0;
- private List<AEISlot> slots;
+ private List<REISlot> slots;
private int cycleCounter = 0;
private int[] itemPointer;
List<Control> controls = new LinkedList<>();
+ private List<Tab> tabs;
+ private boolean tabsEnabled = false;
public RecipeGui(Container p_i1072_1_, GuiScreen prevScreen, Map<IDisplayCategory, List<IRecipe>> recipes) {
super(new RecipeContainer());
@@ -49,7 +57,17 @@ public class RecipeGui extends GuiContainer {
}
private void setupCategories() {
- categories.addAll(recipes.keySet());
+ for(IDisplayCategory adapter : REIRecipeManager.instance().getDisplayAdapters())
+ if (recipes.containsKey(adapter))
+ categories.add(adapter);
+ selectedCategory = categories.get(0);
+ categoryTabPage = 0;
+ tabs = new ArrayList<>();
+ for(int i = 0; i < 6; i++)
+ tabs.add(new Tab(i, 0, 0, 0, 28, 32));
+ tabs.forEach(tab -> tab.setOnClick(i -> {
+ return onClickTab(tab.getId());
+ }));
updateRecipe();
}
@@ -58,7 +76,7 @@ public class RecipeGui extends GuiContainer {
public void render(int mouseX, int mouseY, float partialTicks) {
super.render(mouseX, mouseY, partialTicks);
int y = (int) ((mainWindow.getScaledHeight() / 2 - this.guiHeight / 2));
- drawCenteredString(this.fontRenderer, categories.get(categoryPointer).getDisplayName(), guiLeft + guiWidth / 2, y + 11, -1);
+ drawCenteredString(this.fontRenderer, selectedCategory.getDisplayName(), guiLeft + guiWidth / 2, y + 11, -1);
drawCenteredString(this.fontRenderer, String.format("%d/%d", 1 + getCurrentPage(), getTotalPages()), guiLeft + guiWidth / 2, y + 34, -1);
controls.forEach(Control::draw);
}
@@ -70,7 +88,7 @@ public class RecipeGui extends GuiContainer {
@Override
public void tick() {
super.tick();
- slots.forEach(AEISlot::tick);
+ slots.forEach(REISlot::tick);
controls.forEach(Control::tick);
}
@@ -82,6 +100,7 @@ public class RecipeGui extends GuiContainer {
}
private void updateRecipe() {
+ int categoryPointer = categories.indexOf(selectedCategory);
IRecipe recipe = recipes.get(categories.get(categoryPointer)).get(recipePointer);
categories.get(categoryPointer).resetRecipes();
categories.get(categoryPointer).addRecipe(recipe);
@@ -95,9 +114,7 @@ public class RecipeGui extends GuiContainer {
guiLeft = (int) ((mainWindow.getScaledWidth() / 2 - this.guiWidth / 2));
guiTop = (int) ((mainWindow.getScaledHeight() / 2 - this.guiHeight / 2));
- for(AEISlot slot : slots) {
- slot.move(guiLeft, guiTop);
- }
+ slots.forEach(reiSlot -> reiSlot.move(guiLeft, guiTop));
Button btnCategoryLeft = new Button(guiLeft + 10, guiTop + 5, 15, 20, "<");
Button btnCategoryRight = new Button(guiLeft + guiWidth - 25, guiTop + 5, 15, 20, ">");
@@ -114,7 +131,7 @@ public class RecipeGui extends GuiContainer {
controls.clear();
controls.add(btnCategoryLeft);
controls.add(btnCategoryRight);
- if (categories.size() <= 2) {
+ if (categories.size() <= 1) {
btnCategoryLeft.setEnabled(false);
btnCategoryRight.setEnabled(false);
}
@@ -129,15 +146,46 @@ public class RecipeGui extends GuiContainer {
List<Control> newControls = new LinkedList<>();
categories.get(categoryPointer).addWidget(newControls, 0);
- if (recipes.get(categories.get(categoryPointer)).size() >= categoryPointer + 2) {
+ if (recipes.get(categories.get(categoryPointer)).size() >= categoryPointer + 2)
categories.get(categoryPointer).addWidget(newControls, 1);
- }
newControls.forEach(f -> f.move(guiLeft, guiTop));
controls.addAll(newControls);
+
+ updateTabs();
+ }
+
+ private void updateTabs() {
+ tabsEnabled = guiTop - 28 > 4;
+ if (tabsEnabled) {
+ tabs.forEach(tab -> tab.moveTo(guiLeft + 4, guiLeft + 2 + tabs.indexOf(tab) * 28, guiTop - 28));
+ for(int i = 0; i < tabs.size(); i++) {
+ int ref = i + categoryTabPage * 6;
+ if (categories.size() > ref) {
+ tabs.get(i).setItem(categories.get(ref).getCategoryIcon(), categories.get(ref).getDisplayName(), categories.get(ref).equals(selectedCategory));
+ } else tabs.get(i).setItem(null, null, false);
+ }
+ controls.addAll(tabs);
+ }
+ }
+
+ private boolean onClickTab(int index) {
+ System.out.println(index);
+ if (index + categoryTabPage * 6 == categories.indexOf(selectedCategory))
+ return false;
+ selectedCategory = categories.get(index + categoryTabPage * 6);
+ return false;
}
@Override
protected void drawGuiContainerBackgroundLayer(float v, int i, int i1) {
+ //Tabs
+ if (tabsEnabled) {
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ RenderHelper.enableGUIStandardItemLighting();
+ this.mc.getTextureManager().bindTexture(CREATIVE_INVENTORY_TABS);
+ tabs.stream().filter(tab -> tab.getId() + categoryTabPage * 6 == categories.indexOf(selectedCategory)).forEach(Tab::drawTab);
+ }
+
drawDefaultBackground();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
@@ -146,18 +194,20 @@ public class RecipeGui extends GuiContainer {
int lvt_5_1_ = (int) ((mainWindow.getScaledHeight() / 2 - this.guiHeight / 2));
this.drawTexturedModalRect(lvt_4_1_, lvt_5_1_, 0, 0, this.guiWidth, this.guiHeight);
- slots.forEach(AEISlot::draw);
- }
-
-
- @Override
- protected void initGui() {
- super.initGui();
+ slots.forEach(REISlot::draw);
+
+ if (tabsEnabled)
+ tabs.stream().filter(tab -> tab.getId() + categoryTabPage * 6 != categories.indexOf(selectedCategory)).forEach(tab -> {
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ RenderHelper.enableGUIStandardItemLighting();
+ this.mc.getTextureManager().bindTexture(CREATIVE_INVENTORY_TABS);
+ tab.drawTab();
+ });
}
@Override
public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) {
- if (p_keyPressed_1_ == 259 && prevScreen != null && AEIRenderHelper.focusedControl == null) {
+ if (p_keyPressed_1_ == 259 && prevScreen != null && REIRenderHelper.focusedControl == null) {
Minecraft.getInstance().displayGuiScreen(prevScreen);
return true;
}
@@ -172,20 +222,24 @@ public class RecipeGui extends GuiContainer {
private boolean btnCategoryLeft(int button) {
recipePointer = 0;
+ int categoryPointer = categories.indexOf(selectedCategory);
categoryPointer--;
- if (categoryPointer < 0) {
+ if (categoryPointer < 0)
categoryPointer = categories.size() - 1;
- }
+ selectedCategory = categories.get(categoryPointer);
+ categoryTabPage = categoryPointer / 6;
updateRecipe();
return true;
}
private boolean btnCategoryRight(int button) {
recipePointer = 0;
+ int categoryPointer = categories.indexOf(selectedCategory);
categoryPointer++;
- if (categoryPointer >= categories.size()) {
+ if (categoryPointer >= categories.size())
categoryPointer = 0;
- }
+ selectedCategory = categories.get(categoryPointer);
+ categoryTabPage = categoryPointer / 6;
updateRecipe();
return true;
}
@@ -201,7 +255,7 @@ public class RecipeGui extends GuiContainer {
private boolean btnRecipeRight(int button) {
recipePointer += 2;
- if (recipePointer >= recipes.get(categories.get(categoryPointer)).size()) {
+ if (recipePointer >= recipes.get(selectedCategory).size()) {
recipePointer = 0;
}
updateRecipe();
@@ -213,6 +267,6 @@ public class RecipeGui extends GuiContainer {
}
private int getTotalPages() {
- return MathHelper.clamp(riseDoublesToInt(recipes.get(categories.get(categoryPointer)).size() / 2), 1, Integer.MAX_VALUE);
+ return MathHelper.clamp(riseDoublesToInt(recipes.get(selectedCategory).size() / 2), 1, Integer.MAX_VALUE);
}
}
diff --git a/src/main/java/me/shedaniel/gui/SearchArgument.java b/src/main/java/me/shedaniel/gui/SearchArgument.java
new file mode 100644
index 000000000..253f87814
--- /dev/null
+++ b/src/main/java/me/shedaniel/gui/SearchArgument.java
@@ -0,0 +1,35 @@
+package me.shedaniel.gui;
+
+public class SearchArgument {
+
+ public enum ArgumentType {
+ TEXT, MOD, TOOLTIP
+ }
+
+ private ArgumentType argumentType;
+ private String text;
+ private boolean include;
+
+ public SearchArgument(ArgumentType argumentType, String text, boolean include) {
+ this.argumentType = argumentType;
+ this.text = text;
+ this.include = include;
+ }
+
+ public ArgumentType getArgumentType() {
+ return argumentType;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public boolean isInclude() {
+ return include;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("Argument[%s]: name = %s, include = %b", argumentType.name(), text, include);
+ }
+}
diff --git a/src/main/java/me/shedaniel/gui/widget/Button.java b/src/main/java/me/shedaniel/gui/widget/Button.java
index 3cb68a2ba..df43893ff 100755
--- a/src/main/java/me/shedaniel/gui/widget/Button.java
+++ b/src/main/java/me/shedaniel/gui/widget/Button.java
@@ -1,6 +1,6 @@
package me.shedaniel.gui.widget;
-import me.shedaniel.gui.AEIRenderHelper;
+import me.shedaniel.gui.REIRenderHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -36,7 +36,7 @@ public class Button extends Control {
public void draw() {
GlStateManager.pushMatrix();
GlStateManager.disableLighting();
- GuiContainer gui = AEIRenderHelper.getOverlayedGui();
+ GuiContainer gui = REIRenderHelper.getOverlayedGui();
Minecraft lvt_4_1_ = Minecraft.getInstance();
FontRenderer lvt_5_1_ = lvt_4_1_.fontRenderer;
lvt_4_1_.getTextureManager().bindTexture(BUTTON_TEXTURES);
diff --git a/src/main/java/me/shedaniel/gui/widget/Control.java b/src/main/java/me/shedaniel/gui/widget/Control.java
index 32763caa6..dd674e605 100755
--- a/src/main/java/me/shedaniel/gui/widget/Control.java
+++ b/src/main/java/me/shedaniel/gui/widget/Control.java
@@ -91,6 +91,25 @@ public abstract class Control extends Drawable {
lvt_9_1_.draw();
}
+ protected void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel) {
+ float lvt_7_1_ = 0.00390625F;
+ float lvt_8_1_ = 0.00390625F;
+ Tessellator lvt_9_1_ = Tessellator.getInstance();
+ BufferBuilder lvt_10_1_ = lvt_9_1_.getBuffer();
+ lvt_10_1_.begin(7, DefaultVertexFormats.POSITION_TEX);
+ lvt_10_1_.pos((double) (x + 0), (double) (y + height), zLevel).tex((double) ((float) (u + 0) * 0.00390625F), (double) ((float) (v + height) * 0.00390625F)).endVertex();
+ lvt_10_1_.pos((double) (x + width), (double) (y + height), zLevel).tex((double) ((float) (u + width) * 0.00390625F), (double) ((float) (v + height) * 0.00390625F)).endVertex();
+ lvt_10_1_.pos((double) (x + width), (double) (y + 0), zLevel).tex((double) ((float) (u + width) * 0.00390625F), (double) ((float) (v + 0) * 0.00390625F)).endVertex();
+ lvt_10_1_.pos((double) (x + 0), (double) (y + 0), zLevel).tex((double) ((float) (u + 0) * 0.00390625F), (double) ((float) (v + 0) * 0.00390625F)).endVertex();
+ lvt_9_1_.draw();
+ }
+
+
public void tick() {
}
+
+ public void setOnClick(IntFunction<Boolean> onClick) {
+ this.onClick = onClick;
+ }
+
}
diff --git a/src/main/java/me/shedaniel/gui/widget/AEISlot.java b/src/main/java/me/shedaniel/gui/widget/REISlot.java
index bc3569699..2a2c65569 100755
--- a/src/main/java/me/shedaniel/gui/widget/AEISlot.java
+++ b/