2014-04-29 10:54:20 +10:00
|
|
|
package codechicken.nei;
|
|
|
|
|
|
2019-12-24 13:37:41 -08:00
|
|
|
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
|
|
|
|
import static codechicken.lib.gui.GuiDraw.drawRect;
|
|
|
|
|
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.canPerformAction;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.disabledActions;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.getOptionList;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.getSearchExpression;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.hasSMPCounterPart;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.invCreativeMode;
|
2021-03-14 12:22:27 -07:00
|
|
|
import static codechicken.nei.NEIClientConfig.isBookmarkPanelHidden;
|
2019-12-24 13:37:41 -08:00
|
|
|
import static codechicken.nei.NEIClientConfig.isEnabled;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.isHidden;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.showIDs;
|
|
|
|
|
import static codechicken.nei.NEIClientConfig.toggleBooleanSetting;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.cycleGamemode;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.decreaseSlotStack;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.deleteEverything;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.deleteHeldItem;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.deleteItemsOfType;
|
2021-03-20 16:43:24 -07:00
|
|
|
import static codechicken.nei.NEIClientUtils.getGamemode;
|
2019-12-24 13:37:41 -08:00
|
|
|
import static codechicken.nei.NEIClientUtils.getGuiContainer;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.getHeldItem;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.getNextGamemode;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.healPlayer;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.isValidGamemode;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.setHourForward;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.shiftKey;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.toggleMagnetMode;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.toggleRaining;
|
|
|
|
|
import static codechicken.nei.NEIClientUtils.translate;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2023-09-25 00:35:24 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.TreeSet;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
|
|
|
|
import net.minecraft.client.renderer.InventoryEffectRenderer;
|
|
|
|
|
import net.minecraft.inventory.Slot;
|
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
|
|
|
|
|
|
|
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
|
|
import codechicken.lib.gui.GuiDraw;
|
|
|
|
|
import codechicken.nei.KeyManager.IKeyStateTracker;
|
|
|
|
|
import codechicken.nei.api.API;
|
|
|
|
|
import codechicken.nei.api.GuiInfo;
|
2024-06-10 14:19:25 -06:00
|
|
|
import codechicken.nei.api.INEIAutoFocusSearchEnable;
|
2023-09-25 00:35:24 +02:00
|
|
|
import codechicken.nei.api.IRecipeOverlayRenderer;
|
|
|
|
|
import codechicken.nei.api.ItemInfo;
|
|
|
|
|
import codechicken.nei.api.LayoutStyle;
|
|
|
|
|
import codechicken.nei.drawable.DrawableBuilder;
|
|
|
|
|
import codechicken.nei.drawable.DrawableResource;
|
|
|
|
|
import codechicken.nei.guihook.GuiContainerManager;
|
|
|
|
|
import codechicken.nei.guihook.IContainerDrawHandler;
|
|
|
|
|
import codechicken.nei.guihook.IContainerInputHandler;
|
|
|
|
|
import codechicken.nei.guihook.IContainerObjectHandler;
|
|
|
|
|
import codechicken.nei.guihook.IContainerTooltipHandler;
|
|
|
|
|
import codechicken.nei.recipe.GuiRecipeTab;
|
|
|
|
|
import codechicken.nei.recipe.RecipeCatalysts;
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
public class LayoutManager implements IContainerInputHandler, IContainerTooltipHandler, IContainerDrawHandler,
|
|
|
|
|
IContainerObjectHandler, IKeyStateTracker {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
private static LayoutManager instance;
|
|
|
|
|
|
2021-09-24 07:50:34 -06:00
|
|
|
/** Note: this variable isn't actually used by this mod, but NEI add-ons might need it. */
|
2014-04-29 10:54:20 +10:00
|
|
|
private static Widget inputFocused;
|
2021-09-24 07:50:34 -06:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
/**
|
|
|
|
|
* Sorted bottom first
|
|
|
|
|
*/
|
2022-03-12 22:03:44 +08:00
|
|
|
private static TreeSet<Widget> drawWidgets = new TreeSet<>(new WidgetZOrder(false));
|
2014-04-29 10:54:20 +10:00
|
|
|
/**
|
|
|
|
|
* Sorted top first
|
|
|
|
|
*/
|
2022-03-12 22:03:44 +08:00
|
|
|
private static TreeSet<Widget> controlWidgets = new TreeSet<>(new WidgetZOrder(true));
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
public static ItemPanel itemPanel;
|
2019-12-24 13:37:41 -08:00
|
|
|
public static BookmarkPanel bookmarkPanel;
|
2014-06-29 20:31:37 +10:00
|
|
|
public static SubsetWidget dropDown;
|
2022-02-06 17:42:11 +02:00
|
|
|
public static PresetsWidget presetsPanel;
|
2022-08-19 15:03:42 +03:00
|
|
|
public static SearchField searchField;
|
2024-06-10 14:19:25 -06:00
|
|
|
public static boolean searchInitFocusedCancellable = false;
|
|
|
|
|
public static int mousePriorX, mousePriorY;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
public static ButtonCycled options;
|
2021-03-20 22:38:46 -07:00
|
|
|
public static ButtonCycled bookmarksButton;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-05-06 22:41:45 +03:00
|
|
|
@Deprecated
|
2014-04-29 10:54:20 +10:00
|
|
|
public static Button more;
|
2022-06-24 12:32:13 +01:00
|
|
|
|
2022-05-06 22:41:45 +03:00
|
|
|
@Deprecated
|
2014-04-29 10:54:20 +10:00
|
|
|
public static Button less;
|
2022-06-24 12:32:13 +01:00
|
|
|
|
2022-05-06 22:41:45 +03:00
|
|
|
@Deprecated
|
2014-04-29 10:54:20 +10:00
|
|
|
public static ItemQuantityField quantity;
|
|
|
|
|
|
|
|
|
|
public static Button delete;
|
|
|
|
|
public static ButtonCycled gamemode;
|
|
|
|
|
public static Button rain;
|
|
|
|
|
public static Button magnet;
|
|
|
|
|
public static Button[] timeButtons = new Button[4];
|
|
|
|
|
public static Button heal;
|
|
|
|
|
|
|
|
|
|
public static IRecipeOverlayRenderer overlayRenderer;
|
|
|
|
|
|
2019-12-30 20:19:16 -08:00
|
|
|
public static HashMap<Integer, LayoutStyle> layoutStyles = new HashMap<>();
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-08-31 17:43:22 +09:00
|
|
|
/**
|
|
|
|
|
* This is set to true immediately after item loading thread is started, to prevent duplicated loading thread from
|
|
|
|
|
* being executed. If you want to know if item list is actually finished loading, Use {@link ItemList#loadFinished}
|
|
|
|
|
* instead.
|
|
|
|
|
*/
|
2020-01-08 21:32:53 -08:00
|
|
|
public static boolean itemsLoaded = false;
|
2019-12-24 13:37:41 -08:00
|
|
|
|
2021-05-22 18:31:40 +01:00
|
|
|
/**
|
|
|
|
|
* Not present, Present
|
|
|
|
|
*/
|
|
|
|
|
public static Image[] itemPresenceOverlays = new Image[2];
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
public static void load() {
|
|
|
|
|
API.addLayoutStyle(0, new LayoutStyleMinecraft());
|
|
|
|
|
|
|
|
|
|
instance = new LayoutManager();
|
|
|
|
|
KeyManager.trackers.add(instance);
|
|
|
|
|
GuiContainerManager.addInputHandler(instance);
|
|
|
|
|
GuiContainerManager.addTooltipHandler(instance);
|
|
|
|
|
GuiContainerManager.addDrawHandler(instance);
|
|
|
|
|
GuiContainerManager.addObjectHandler(instance);
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPreDraw(GuiContainer gui) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!isHidden() && isEnabled() && gui instanceof InventoryEffectRenderer) // Reset the gui to the center of the
|
|
|
|
|
// screen, for potion effect offsets
|
|
|
|
|
// etc
|
2014-04-29 10:54:20 +10:00
|
|
|
{
|
|
|
|
|
gui.guiLeft = (gui.width - gui.xSize) / 2;
|
|
|
|
|
gui.guiTop = (gui.height - gui.ySize) / 2;
|
|
|
|
|
|
|
|
|
|
if (gui instanceof GuiContainerCreative && gui.buttonList.size() >= 2) {
|
|
|
|
|
GuiButton button1 = (GuiButton) gui.buttonList.get(0);
|
|
|
|
|
GuiButton button2 = (GuiButton) gui.buttonList.get(1);
|
|
|
|
|
button1.xPosition = gui.guiLeft;
|
|
|
|
|
button2.xPosition = gui.guiLeft + gui.xSize - 20;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-06 22:41:45 +03:00
|
|
|
@Deprecated
|
2019-12-24 13:37:41 -08:00
|
|
|
public static int getSideWidth(GuiContainer gui) {
|
|
|
|
|
return gui.width - 3;
|
|
|
|
|
}
|
2022-05-06 22:41:45 +03:00
|
|
|
|
|
|
|
|
@Deprecated
|
2019-12-24 13:37:41 -08:00
|
|
|
public static int getLeftSize(GuiContainer gui) {
|
2021-03-24 18:23:30 -07:00
|
|
|
return getSideWidth(gui);
|
2019-12-24 13:37:41 -08:00
|
|
|
}
|
|
|
|
|
|
2024-06-10 14:19:25 -06:00
|
|
|
public boolean isAllowedGuiAutoSearchFocus(GuiContainer gui) {
|
|
|
|
|
if (gui instanceof INEIAutoFocusSearchEnable) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
String guiClassName = gui.getClass().getName();
|
|
|
|
|
for (String prefix : NEIClientConfig.enableAutoFocusPrefixes) {
|
|
|
|
|
if (guiClassName.startsWith(prefix)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void searchFocusInitCancelCheck() {
|
|
|
|
|
if (searchInitFocusedCancellable) {
|
|
|
|
|
if (searchField.isVisible() && NEIClientConfig.isFocusSearchWidgetOnOpen()
|
|
|
|
|
&& getInputFocused() == searchField) {
|
|
|
|
|
searchField.setFocus(false);
|
|
|
|
|
setInputFocused(null);
|
|
|
|
|
}
|
|
|
|
|
searchInitFocusedCancellable = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (isHidden()) return;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2024-06-10 14:19:25 -06:00
|
|
|
searchFocusInitCancelCheck();
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : controlWidgets) widget.onGuiClick(mousex, mousey);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (isHidden()) return false;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!isEnabled()) return options.contains(mousex, mousey) && options.handleClick(mousex, mousey, button);
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2024-06-10 14:19:25 -06:00
|
|
|
searchFocusInitCancelCheck();
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
for (Widget widget : controlWidgets) {
|
|
|
|
|
widget.onGuiClick(mousex, mousey);
|
2022-06-24 12:32:13 +01:00
|
|
|
if (widget.contains(mousex, mousey) ? widget.handleClick(mousex, mousey, button)
|
|
|
|
|
: widget.handleClickExt(mousex, mousey, button))
|
|
|
|
|
return true;
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean objectUnderMouse(GuiContainer gui, int mousex, int mousey) {
|
2014-06-29 20:31:37 +10:00
|
|
|
if (!isHidden() && isEnabled())
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : drawWidgets) if (widget.contains(mousex, mousey)) return true;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean keyTyped(GuiContainer gui, char keyChar, int keyID) {
|
|
|
|
|
if (isEnabled() && !isHidden()) {
|
2024-06-10 14:19:25 -06:00
|
|
|
searchInitFocusedCancellable = false;
|
2022-06-24 12:32:13 +01:00
|
|
|
if (inputFocused != null) return inputFocused.handleKeyPress(keyID, keyChar);
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : controlWidgets) if (widget.handleKeyPress(keyID, keyChar)) return true;
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-06-24 12:32:13 +01:00
|
|
|
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {}
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
2022-08-19 15:03:42 +03:00
|
|
|
|
|
|
|
|
if (NEIClientConfig.isKeyHashDown("gui.hide")) {
|
2014-04-29 10:54:20 +10:00
|
|
|
toggleBooleanSetting("inventory.hidden");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-08-19 15:03:42 +03:00
|
|
|
|
|
|
|
|
if (NEIClientConfig.isKeyHashDown("gui.hide_bookmarks")) {
|
2021-03-20 22:38:46 -07:00
|
|
|
toggleBooleanSetting("inventory.bookmarksEnabled");
|
2021-03-14 12:22:27 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-03 23:35:03 +09:00
|
|
|
if (NEIClientConfig.isKeyHashDown("gui.next_tooltip")) {
|
|
|
|
|
GuiContainerManager.incrementTooltipPage();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
if (isEnabled() && !isHidden()) {
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : controlWidgets) if (inputFocused == null) widget.lastKeyTyped(keyID, keyChar);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2022-08-19 15:03:42 +03:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onMouseUp(GuiContainer gui, int mx, int my, int button) {
|
|
|
|
|
if (!isHidden() && isEnabled()) {
|
2024-06-10 14:19:25 -06:00
|
|
|
searchFocusInitCancelCheck();
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : controlWidgets) widget.mouseUp(mx, my, button);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onMouseDragged(GuiContainer gui, int mx, int my, int button, long heldTime) {
|
|
|
|
|
if (!isHidden() && isEnabled()) {
|
2024-06-10 14:19:25 -06:00
|
|
|
searchFocusInitCancelCheck();
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : controlWidgets) widget.mouseDragged(mx, my, button, heldTime);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) {
|
|
|
|
|
if (!isHidden() && isEnabled()) {
|
2022-02-06 17:42:11 +02:00
|
|
|
for (Widget widget : drawWidgets) {
|
2014-04-29 10:54:20 +10:00
|
|
|
ItemStack stack = widget.getStackMouseOver(mousex, mousey);
|
2022-06-24 12:32:13 +01:00
|
|
|
if (stack != null) return stack;
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void renderObjects(GuiContainer gui, int mousex, int mousey) {
|
|
|
|
|
if (!isHidden()) {
|
|
|
|
|
layout(gui);
|
2024-06-10 14:19:25 -06:00
|
|
|
if (mousePriorX == -1) {
|
|
|
|
|
mousePriorX = mousex;
|
|
|
|
|
mousePriorY = mousey;
|
|
|
|
|
}
|
|
|
|
|
if (mousePriorX != mousex || mousePriorY != mousey) {
|
|
|
|
|
searchFocusInitCancelCheck();
|
|
|
|
|
mousePriorX = mousex;
|
|
|
|
|
mousePriorY = mousey;
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
if (isEnabled()) {
|
|
|
|
|
getLayoutStyle().drawBackground(GuiContainerManager.getManager(gui));
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : drawWidgets) widget.draw(mousex, mousey);
|
2014-04-29 10:54:20 +10:00
|
|
|
} else {
|
|
|
|
|
options.draw(mousex, mousey);
|
2021-03-20 22:38:46 -07:00
|
|
|
bookmarksButton.draw(mousex, mousey);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
|
|
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public void postRenderObjects(GuiContainer gui, int mousex, int mousey) {
|
|
|
|
|
if (!isHidden() && isEnabled()) {
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : drawWidgets) widget.postDraw(mousex, mousey);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-10 17:38:07 +01:00
|
|
|
@Override
|
|
|
|
|
public void postRenderTooltips(GuiContainer gui, int mousex, int mousey, List<String> tooltip) {
|
2024-02-04 14:09:24 +02:00
|
|
|
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
2023-07-10 17:38:07 +01:00
|
|
|
for (Widget widget : drawWidgets) widget.postDrawTooltips(mousex, mousey, tooltip);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
|
|
|
|
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : drawWidgets) currenttip = widget.handleTooltip(mousex, mousey, currenttip);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
return currenttip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> handleItemDisplayName(GuiContainer gui, ItemStack stack, List<String> currenttip) {
|
|
|
|
|
String overridename = ItemInfo.getNameOverride(stack);
|
2022-06-24 12:32:13 +01:00
|
|
|
if (overridename != null) currenttip.set(0, overridename);
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
String mainname = currenttip.get(0);
|
|
|
|
|
if (showIDs()) {
|
|
|
|
|
mainname += " " + Item.getIdFromItem(stack.getItem());
|
2022-06-24 12:32:13 +01:00
|
|
|
if (stack.getItemDamage() != 0) mainname += ":" + stack.getItemDamage();
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
currenttip.set(0, mainname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return currenttip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-06-24 12:32:13 +01:00
|
|
|
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
|
|
|
|
List<String> currenttip) {
|
2014-04-29 10:54:20 +10:00
|
|
|
return currenttip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void layout(GuiContainer gui) {
|
|
|
|
|
VisiblityData visiblity = new VisiblityData();
|
2022-05-06 22:41:45 +03:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (isHidden()) visiblity.showNEI = false;
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (isBookmarkPanelHidden()) visiblity.showBookmarkPanel = false;
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2023-10-14 19:02:11 +08:00
|
|
|
if (gui.height - gui.ySize <= 40 && NEIClientConfig.isSearchWidgetCentered())
|
|
|
|
|
visiblity.showSearchSection = false;
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (visiblity.showBookmarkPanel || gui.guiTop <= 20) visiblity.showSubsetDropdown = false;
|
2022-02-17 09:28:48 +02:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!visiblity.showBookmarkPanel || gui.guiTop <= 20) visiblity.showPresetsDropdown = false;
|
2022-02-17 09:28:48 +02:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (gui.guiLeft - 4 < 76) visiblity.showWidgets = false;
|
2022-05-06 22:41:45 +03:00
|
|
|
|
2024-02-04 14:09:24 +02:00
|
|
|
if (!itemsLoaded) visiblity.showPresetsDropdown = false;
|
|
|
|
|
|
2021-06-05 10:47:58 -07:00
|
|
|
try {
|
|
|
|
|
GuiInfo.readLock.lock();
|
|
|
|
|
GuiInfo.guiHandlers.forEach(handler -> handler.modifyVisiblity(gui, visiblity));
|
|
|
|
|
} finally {
|
|
|
|
|
GuiInfo.readLock.unlock();
|
|
|
|
|
}
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
visiblity.translateDependancies();
|
|
|
|
|
|
|
|
|
|
getLayoutStyle().layout(gui, visiblity);
|
|
|
|
|
|
|
|
|
|
updateWidgetVisiblities(gui, visiblity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void init() {
|
2019-12-24 13:37:41 -08:00
|
|
|
itemPanel = ItemPanels.itemPanel;
|
|
|
|
|
itemPanel.init();
|
|
|
|
|
|
|
|
|
|
bookmarkPanel = ItemPanels.bookmarkPanel;
|
|
|
|
|
bookmarkPanel.init();
|
|
|
|
|
|
2014-06-29 20:31:37 +10:00
|
|
|
dropDown = new SubsetWidget();
|
2022-02-06 17:42:11 +02:00
|
|
|
presetsPanel = new PresetsWidget();
|
2014-04-29 10:54:20 +10:00
|
|
|
searchField = new SearchField("search");
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
options = new ButtonCycled(3) {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2021-03-23 23:34:05 -07:00
|
|
|
@Override
|
|
|
|
|
public void init() {
|
|
|
|
|
this.icons[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 32, 0, 16, 16).build();
|
|
|
|
|
this.icons[1] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 48, 0, 16, 16).build();
|
|
|
|
|
this.icons[2] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 64, 0, 16, 16).build();
|
|
|
|
|
}
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2023-02-28 16:53:59 +02:00
|
|
|
private boolean getIsAccessibleControlEventKey() {
|
|
|
|
|
if (Minecraft.isRunningOnMac) {
|
|
|
|
|
return Keyboard.getEventKey() == Keyboard.KEY_LMETA || Keyboard.getEventKey() == Keyboard.KEY_RMETA;
|
|
|
|
|
}
|
|
|
|
|
return Keyboard.getEventKey() == Keyboard.KEY_LCONTROL
|
|
|
|
|
|| Keyboard.getEventKey() == Keyboard.KEY_RCONTROL;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public boolean onButtonPress(boolean rightclick) {
|
|
|
|
|
if (!rightclick) {
|
2023-02-28 16:53:59 +02:00
|
|
|
if (Keyboard.getEventKeyState() && getIsAccessibleControlEventKey()) {
|
2021-03-15 22:31:36 -07:00
|
|
|
NEIClientConfig.cycleSetting("inventory.cheatmode", 3);
|
|
|
|
|
} else {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (Keyboard.getEventKeyState() && (Keyboard.getEventKey() == Keyboard.KEY_LSHIFT
|
|
|
|
|
|| Keyboard.getEventKey() == Keyboard.KEY_RSHIFT)) {
|
2021-03-28 00:12:17 -07:00
|
|
|
GuiRecipeTab.loadHandlerInfo();
|
2022-01-31 01:01:12 +09:00
|
|
|
RecipeCatalysts.loadCatalystInfo();
|
2021-03-28 00:12:17 -07:00
|
|
|
}
|
2021-03-15 22:31:36 -07:00
|
|
|
getOptionList().openGui(getGuiContainer(), false);
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
@Override
|
|
|
|
|
public void addTooltips(List<String> tooltip) {
|
|
|
|
|
tooltip.add(translate("inventory.options.tip"));
|
|
|
|
|
String modeColor = "";
|
|
|
|
|
final int cheatMode = NEIClientConfig.getCheatMode();
|
2022-06-24 12:32:13 +01:00
|
|
|
if (cheatMode == 1) modeColor = EnumChatFormatting.GOLD.toString();
|
|
|
|
|
else if (cheatMode == 2) modeColor = EnumChatFormatting.RED.toString();
|
2021-03-15 22:31:36 -07:00
|
|
|
String controlKeyLocalization = translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl");
|
|
|
|
|
tooltip.add(modeColor + translate("inventory.options.tip.cheatmode." + cheatMode));
|
|
|
|
|
tooltip.add(modeColor + translate("inventory.options.tip.cheatmode.disable", controlKeyLocalization));
|
|
|
|
|
}
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public String getRenderLabel() {
|
|
|
|
|
return translate("inventory.options");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
bookmarksButton = new ButtonCycled(2) {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2021-03-23 23:34:05 -07:00
|
|
|
@Override
|
|
|
|
|
public void init() {
|
|
|
|
|
this.icons[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 0, 16, 16).build();
|
|
|
|
|
this.icons[1] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 16, 0, 16, 16).build();
|
|
|
|
|
}
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2019-12-24 13:37:41 -08:00
|
|
|
@Override
|
2014-04-29 10:54:20 +10:00
|
|
|
public boolean onButtonPress(boolean rightclick) {
|
2021-03-21 09:32:03 -07:00
|
|
|
NEIClientConfig.toggleBooleanSetting("inventory.bookmarksEnabled");
|
2021-03-14 12:22:27 -07:00
|
|
|
return true;
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
public String getButtonTip() {
|
|
|
|
|
return translate("bookmark.toggle.tip");
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public String getRenderLabel() {
|
2019-12-24 13:37:41 -08:00
|
|
|
return translate("bookmark.toggle");
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-06 22:41:45 +03:00
|
|
|
more = ItemPanels.itemPanel.more;
|
|
|
|
|
less = ItemPanels.itemPanel.less;
|
|
|
|
|
quantity = ItemPanels.itemPanel.quantity;
|
2022-06-24 12:32:13 +01:00
|
|
|
delete = new Button() {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public boolean onButtonPress(boolean rightclick) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if ((state & 0x3) == 2) return false;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
ItemStack held = getHeldItem();
|
|
|
|
|
if (held != null) {
|
|
|
|
|
if (shiftKey()) {
|
|
|
|
|
deleteHeldItem();
|
|
|
|
|
deleteItemsOfType(held);
|
2022-06-24 12:32:13 +01:00
|
|
|
} else if (rightclick) decreaseSlotStack(-999);
|
|
|
|
|
else deleteHeldItem();
|
|
|
|
|
} else if (shiftKey()) deleteEverything();
|
|
|
|
|
else NEIController.toggleDeleteMode();
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getButtonTip() {
|
|
|
|
|
if ((state & 0x3) != 2) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (shiftKey()) return translate("inventory.delete.inv");
|
|
|
|
|
if (NEIController.canUseDeleteMode()) return getStateTip("delete", state);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void postDraw(int mousex, int mousey) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (contains(mousex, mousey) && getHeldItem() != null && (state & 0x3) != 2) GuiDraw.drawTip(
|
|
|
|
|
mousex + 9,
|
|
|
|
|
mousey,
|
|
|
|
|
translate(
|
|
|
|
|
"inventory.delete." + (shiftKey() ? "all" : "one"),
|
|
|
|
|
GuiContainerManager.itemDisplayNameShort(getHeldItem())));
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
};
|
2022-06-24 12:32:13 +01:00
|
|
|
gamemode = new ButtonCycled(3) {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public boolean onButtonPress(boolean rightclick) {
|
|
|
|
|
if (!rightclick) {
|
|
|
|
|
cycleGamemode();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
|
2021-03-20 22:38:46 -07:00
|
|
|
public void addTooltips(List<String> tooltip) {
|
|
|
|
|
tooltip.add(translate("inventory.current.gamemode." + getGamemode()));
|
|
|
|
|
tooltip.add(EnumChatFormatting.GRAY + translate("inventory.gamemode." + getNextGamemode()));
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
};
|
2022-06-24 12:32:13 +01:00
|
|
|
rain = new Button() {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public boolean onButtonPress(boolean rightclick) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (handleDisabledButtonPress("rain", rightclick)) return true;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
if (!rightclick) {
|
|
|
|
|
toggleRaining();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getButtonTip() {
|
|
|
|
|
return getStateTip("rain", state);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-06-24 12:32:13 +01:00
|
|
|
magnet = new Button() {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public boolean onButtonPress(boolean rightclick) {
|
|
|
|
|
if (!rightclick) {
|
|
|
|
|
toggleMagnetMode();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getButtonTip() {
|
|
|
|
|
return getStateTip("magnet", state);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
final int zone = i;
|
2022-06-24 12:32:13 +01:00
|
|
|
timeButtons[i] = new Button() {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public boolean onButtonPress(boolean rightclick) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (handleDisabledButtonPress(NEIActions.timeZones[zone], rightclick)) return true;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
if (!rightclick) {
|
|
|
|
|
setHourForward(zone * 6);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-06-15 23:19:57 +02:00
|
|
|
public void addTooltips(List<String> tooltip) {
|
|
|
|
|
addTimeTip(NEIActions.timeZones[zone], state, tooltip);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
heal = new Button() {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public boolean onButtonPress(boolean rightclick) {
|
|
|
|
|
if (!rightclick) {
|
|
|
|
|
healPlayer();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getButtonTip() {
|
|
|
|
|
return translate("inventory.heal");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
delete.state |= 0x4;
|
|
|
|
|
gamemode.state |= 0x4;
|
|
|
|
|
rain.state |= 0x4;
|
|
|
|
|
magnet.state |= 0x4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String getStateTip(String name, int state) {
|
2022-06-24 12:32:13 +01:00
|
|
|
String sfx = (state & 0x3) == 2 ? "enable" : (state & 0x3) == 1 ? "0" : "1";
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
return translate("inventory." + name + "." + sfx);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 23:19:57 +02:00
|
|
|
private static void addTimeTip(String name, int state, List<String> tooltip) {
|
|
|
|
|
if ((state & 0x3) == 2) {
|
|
|
|
|
tooltip.add(translate("inventory." + name + ".enable"));
|
|
|
|
|
} else {
|
|
|
|
|
tooltip.add(translate("inventory." + name + ".set"));
|
|
|
|
|
tooltip.add(EnumChatFormatting.GRAY + translate("inventory." + name + ".disable"));
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static boolean handleDisabledButtonPress(String ident, boolean rightclick) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!NEIActions.canDisable.contains(ident)) return false;
|
|
|
|
|
if (rightclick != disabledActions.contains(ident)) return setPropertyDisabled(ident, rightclick);
|
2014-04-29 10:54:20 +10:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static boolean setPropertyDisabled(String ident, boolean disable) {
|
|
|
|
|
if (disable && NEIActions.base(ident).equals("time")) {
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (disabledActions.contains(NEIActions.timeZones[i])) count++;
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
if (count == 3) return false;
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
if (hasSMPCounterPart()) NEICPH.sendSetPropertyDisabled(ident, disable);
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2020-05-30 09:17:12 -07:00
|
|
|
public static void markItemsDirty() {
|
|
|
|
|
// If anything has modified data this depends on, we'll need to reload the item list
|
|
|
|
|
itemsLoaded = false;
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void load(GuiContainer gui) {
|
|
|
|
|
if (isEnabled()) {
|
2021-09-24 07:50:34 -06:00
|
|
|
setInputFocused(null);
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!itemsLoaded) {
|
2020-01-08 21:32:53 -08:00
|
|
|
ItemList.loadItems.restart();
|
|
|
|
|
itemsLoaded = true;
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
overlayRenderer = null;
|
|
|
|
|
|
|
|
|
|
getLayoutStyle().init();
|
|
|
|
|
layout(gui);
|
2024-06-10 14:19:25 -06:00
|
|
|
mousePriorX = -1;
|
|
|
|
|
mousePriorY = -1;
|
|
|
|
|
|
|
|
|
|
if (searchField.isVisible() && NEIClientConfig.isFocusSearchWidgetOnOpen()
|
|
|
|
|
&& isAllowedGuiAutoSearchFocus(gui)) {
|
|
|
|
|
searchField.setFocus(true);
|
|
|
|
|
setInputFocused(searchField);
|
|
|
|
|
searchInitFocusedCancellable = true;
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NEIController.load(gui);
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (checkCreativeInv(gui) && gui.mc.currentScreen instanceof GuiContainerCreative) // override creative with
|
|
|
|
|
// creative+
|
|
|
|
|
gui.mc.displayGuiScreen(null); // close the screen and wait for the server to open it for us
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-06-24 12:32:13 +01:00
|
|
|
public void refresh(GuiContainer gui) {}
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
public boolean checkCreativeInv(GuiContainer gui) {
|
|
|
|
|
if (gui instanceof GuiContainerCreative && invCreativeMode()) {
|
|
|
|
|
NEICPH.sendCreativeInv(true);
|
|
|
|
|
return true;
|
|
|
|
|
} else if (gui instanceof GuiExtendedCreativeInv && !invCreativeMode()) {
|
|
|
|
|
NEICPH.sendCreativeInv(false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void updateWidgetVisiblities(GuiContainer gui, VisiblityData visiblity) {
|
2022-03-12 22:03:44 +08:00
|
|
|
drawWidgets = new TreeSet<>(new WidgetZOrder(false));
|
|
|
|
|
controlWidgets = new TreeSet<>(new WidgetZOrder(true));
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!visiblity.showNEI) return;
|
2019-12-24 13:37:41 -08:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
addWidget(options);
|
2021-03-20 22:38:46 -07:00
|
|
|
addWidget(bookmarksButton);
|
2014-04-29 10:54:20 +10:00
|
|
|
if (visiblity.showItemPanel) {
|
2022-02-06 17:42:11 +02:00
|
|
|
|
|
|
|
|
if (PresetsWidget.inEditMode()) {
|
|
|
|
|
drawWidgets.add(itemPanel);
|
|
|
|
|
} else {
|
|
|
|
|
addWidget(itemPanel);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-24 13:37:41 -08:00
|
|
|
itemPanel.setVisible();
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
2019-12-24 13:37:41 -08:00
|
|
|
if (visiblity.showBookmarkPanel) {
|
|
|
|
|
addWidget(bookmarkPanel);
|
|
|
|
|
bookmarkPanel.setVisible();
|
2022-02-17 09:28:48 +02:00
|
|
|
}
|
2022-02-06 17:42:11 +02:00
|
|
|
|
2022-02-17 09:28:48 +02:00
|
|
|
if (visiblity.showPresetsDropdown) {
|
2022-02-06 17:42:11 +02:00
|
|
|
addWidget(presetsPanel);
|
2021-11-22 05:31:02 +02:00
|
|
|
}
|
2019-12-24 13:37:41 -08:00
|
|
|
|
2022-08-19 15:03:42 +03:00
|
|
|
searchField.setVisible(visiblity.showSearchSection);
|
2014-04-29 10:54:20 +10:00
|
|
|
if (visiblity.showSearchSection) {
|
|
|
|
|
addWidget(searchField);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (visiblity.showUtilityButtons) {
|
|
|
|
|
if (canPerformAction("time")) {
|
2022-06-24 12:32:13 +01:00
|
|
|
for (int i = 0; i < 4; i++) addWidget(timeButtons[i]);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
if (canPerformAction("rain")) addWidget(rain);
|
|
|
|
|
if (canPerformAction("heal")) addWidget(heal);
|
|
|
|
|
if (canPerformAction("magnet")) addWidget(magnet);
|
|
|
|
|
if (isValidGamemode("creative") || isValidGamemode("creative+") || isValidGamemode("adventure"))
|
2014-04-29 10:54:20 +10:00
|
|
|
addWidget(gamemode);
|
2022-06-24 12:32:13 +01:00
|
|
|
if (canPerformAction("delete")) addWidget(delete);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2022-02-17 09:28:48 +02:00
|
|
|
if (visiblity.showSubsetDropdown) {
|
2021-04-03 22:56:15 -07:00
|
|
|
// Bookmarks or Subset/dropdown
|
|
|
|
|
addWidget(dropDown);
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static LayoutStyle getLayoutStyle(int id) {
|
|
|
|
|
LayoutStyle style = layoutStyles.get(id);
|
2022-06-24 12:32:13 +01:00
|
|
|
if (style == null) style = layoutStyles.get(0);
|
2014-04-29 10:54:20 +10:00
|
|
|
return style;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static LayoutStyle getLayoutStyle() {
|
2019-12-24 13:37:41 -08:00
|
|
|
return getLayoutStyle(0);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
2019-12-24 13:37:41 -08:00
|
|
|
public static void addWidget(Widget widget) {
|
2014-04-29 10:54:20 +10:00
|
|
|
drawWidgets.add(widget);
|
|
|
|
|
controlWidgets.add(widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void guiTick(GuiContainer gui) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (checkCreativeInv(gui)) return;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!isEnabled()) return;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : drawWidgets) widget.update();
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (isHidden() || !isEnabled()) return false;
|
2024-06-10 14:19:25 -06:00
|
|
|
searchFocusInitCancelCheck();
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
for (Widget widget : drawWidgets) if (widget.onMouseWheel(scrolled, mousex, mousey)) return true;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-06-24 12:32:13 +01:00
|
|
|
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {}
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean shouldShowTooltip(GuiContainer gui) {
|
2024-02-04 14:09:24 +02:00
|
|
|
return itemPanel.draggedStack == null && !bookmarkPanel.inEditingState();
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
2021-09-24 07:50:34 -06:00
|
|
|
/** Note: this method isn't actually used by this mod, but NEI add-ons might need it. */
|
|
|
|
|
public static Widget getInputFocused() {
|
|
|
|
|
return inputFocused;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Note: this method isn't actually used by this mod, but NEI add-ons might need it. */
|
|
|
|
|
public static void setInputFocused(Widget widget) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (inputFocused != null) inputFocused.loseFocus();
|
2021-09-24 07:50:34 -06:00
|
|
|
|
|
|
|
|
inputFocused = widget;
|
2022-06-24 12:32:13 +01:00
|
|
|
if (inputFocused != null) inputFocused.gainFocus();
|
2021-09-24 07:50:34 -06:00
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
|
|
|
|
public void renderSlotUnderlay(GuiContainer gui, Slot slot) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (overlayRenderer != null) overlayRenderer.renderOverlay(GuiContainerManager.getManager(gui), slot);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void renderSlotOverlay(GuiContainer window, Slot slot) {
|
2024-02-04 14:09:24 +02:00
|
|
|
|
|
|
|
|
if (SearchField.searchInventories()) {
|
|
|
|
|
ItemStack item = slot.getStack();
|
|
|
|
|
|
|
|
|
|
if (item == null ? !getSearchExpression().equals("") : !searchField.getFilter().matches(item)) {
|
|
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
|
|
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
|
|
|
|
GL11.glTranslatef(0, 0, 150);
|
|
|
|
|
drawRect(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, 0x80000000);
|
|
|
|
|
GL11.glTranslatef(0, 0, -150);
|
|
|
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
|
|
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2024-02-04 14:09:24 +02:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void drawIcon(int x, int y, Image image) {
|
2021-03-23 23:34:05 -07:00
|
|
|
final boolean isDrawableResource = image instanceof DrawableResource;
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!isDrawableResource) changeTexture("nei:textures/nei_sprites.png");
|
2021-11-22 05:31:02 +02:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
GL11.glColor4f(1, 1, 1, 1);
|
|
|
|
|
GL11.glEnable(GL11.GL_BLEND);
|
|
|
|
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!isDrawableResource) drawTexturedModalRect(x, y, image.x, image.y, image.width, image.height);
|
|
|
|
|
else((DrawableResource) image).draw(x, y);
|
2014-04-29 10:54:20 +10:00
|
|
|
GL11.glDisable(GL11.GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void drawButtonBackground(int x, int y, int w, int h, boolean edges, int type) {
|
2021-03-15 22:31:36 -07:00
|
|
|
int wTiles = 0;
|
2022-06-24 12:32:13 +01:00
|
|
|
int ew = w; // end width
|
2014-04-29 10:54:20 +10:00
|
|
|
if (w / 2 > 100) {
|
2021-03-15 22:31:36 -07:00
|
|
|
wTiles = (w - 200) / 50 + 1;
|
2014-04-29 10:54:20 +10:00
|
|
|
ew = 200;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
final int w1 = ew / 2;
|
|
|
|
|
final int h1 = h / 2;
|
|
|
|
|
final int w2 = (ew + 1) / 2;
|
|
|
|
|
final int h2 = (h + 1) / 2;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
final int x2 = x + w - w2;
|
|
|
|
|
final int y2 = y + h - h2;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
final int ty = 46 + type * 20;
|
2022-06-24 12:32:13 +01:00
|
|
|
final int te = (edges ? 0 : 1); // tex edges
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
final int ty1 = ty + te;
|
|
|
|
|
final int tx1 = te;
|
|
|
|
|
final int tx3 = 75;
|
2022-06-24 12:32:13 +01:00
|
|
|
// halfway the 1 is for odd number adjustment
|
2021-03-15 22:31:36 -07:00
|
|
|
final int ty2 = ty + 20 - h2 - te;
|
|
|
|
|
final int tx2 = 200 - w2 - te;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
changeTexture("textures/gui/widgets.png");
|
2022-06-24 12:32:13 +01:00
|
|
|
drawTexturedModalRect(x, y, tx1, ty1, w1, h1); // top left
|
|
|
|
|
drawTexturedModalRect(x, y2, tx1, ty2, w1, h2); // bottom left
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2021-03-15 22:31:36 -07:00
|
|
|
for (int tile = 0; tile < wTiles; tile++) {
|
|
|
|
|
final int tileX = x + w1 + 50 * tile;
|
2022-06-24 12:32:13 +01:00
|
|
|
drawTexturedModalRect(tileX, y, tx3, ty1, 50, h1); // top
|
|
|
|
|
drawTexturedModalRect(tileX, y2, tx3, ty2, 50, h2); // bottom
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
drawTexturedModalRect(x2, y, tx2, ty1, w2, h1); // top right
|
|
|
|
|
drawTexturedModalRect(x2, y2, tx2, ty2, w2, h2); // bottom right
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
2024-02-19 06:12:01 -06:00
|
|
|
public static void drawItemPresenceOverlay(int slotX, int slotY, boolean isPresent, boolean slotHighlight) {
|
|
|
|
|
|
|
|
|
|
if (slotHighlight) {
|
|
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
|
|
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
|
|
|
|
GL11.glTranslatef(0, 0, -150);
|
2024-02-22 01:26:41 +02:00
|
|
|
drawRect(slotX, slotY, 16, 16, isPresent ? 0x8000AA00 : 0x80AA0000);
|
2024-02-19 06:12:01 -06:00
|
|
|
GL11.glTranslatef(0, 0, 150);
|
|
|
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
|
|
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
|
|
|
} else {
|
|
|
|
|
Image icon = itemPresenceOverlays[isPresent ? 1 : 0];
|
|
|
|
|
drawIcon(slotX + 16 - icon.width, slotY + 16 - icon.height, icon);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-22 18:31:40 +01:00
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
public static LayoutManager instance() {
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void tickKeyStates() {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (Minecraft.getMinecraft().currentScreen != null) return;
|
2019-12-24 13:37:41 -08:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
if (KeyManager.keyStates.get("world.dawn").down) timeButtons[0].onButtonPress(false);
|
|
|
|
|
if (KeyManager.keyStates.get("world.noon").down) timeButtons[1].onButtonPress(false);
|
|
|
|
|
if (KeyManager.keyStates.get("world.dusk").down) timeButtons[2].onButtonPress(false);
|
|
|
|
|
if (KeyManager.keyStates.get("world.midnight").down) timeButtons[3].onButtonPress(false);
|
|
|
|
|
if (KeyManager.keyStates.get("world.rain").down) rain.onButtonPress(false);
|
|
|
|
|
if (KeyManager.keyStates.get("world.heal").down) heal.onButtonPress(false);
|
|
|
|
|
if (KeyManager.keyStates.get("world.creative").down) gamemode.onButtonPress(false);
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|