mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 19:15:13 +00:00
fix tooltips
This commit is contained in:
1 parent
e3be08c970
commit
83696ca9ae
9 files changed
+133
-74
No files matched your search
@@ -31,8 +31,8 @@ public class AutoFocusWidget implements IContainerInputHandler {
|
||||
protected boolean autofocus = false;
|
||||
protected Point mouse;
|
||||
|
||||
static {
|
||||
GuiContainerManager.addInputHandler(instance);
|
||||
public AutoFocusWidget() {
|
||||
GuiContainerManager.addInputHandler(this);
|
||||
}
|
||||
|
||||
public void load(GuiContainer gui) {
|
||||
|
||||
@@ -1408,6 +1408,8 @@ public class BookmarkPanel extends PanelWidget {
|
||||
|
||||
public BookmarkPanel() {
|
||||
grid = new BookmarkGrid();
|
||||
namespaces.add(new BookmarkGrid());
|
||||
setNamespace(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1464,8 +1466,6 @@ public class BookmarkPanel extends PanelWidget {
|
||||
}
|
||||
};
|
||||
|
||||
namespaces.add(new BookmarkGrid());
|
||||
setNamespace(activeNamespaceIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1749,7 +1749,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
}
|
||||
|
||||
protected void setNamespace(int namespaceIndex) {
|
||||
activeNamespaceIndex = namespaceIndex;
|
||||
activeNamespaceIndex = Math.min(namespaceIndex, namespaces.size() - 1);
|
||||
grid = namespaces.get(activeNamespaceIndex);
|
||||
|
||||
if (grid.size() == 0 && activeNamespaceIndex > 0) {
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
|
||||
public class HeldItemHandler implements IContainerInputHandler, IContainerTooltipHandler {
|
||||
|
||||
protected HeldItemHandler() {
|
||||
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
HeldItemHandler instance = new HeldItemHandler();
|
||||
GuiContainerManager.addInputHandler(instance);
|
||||
GuiContainerManager.addTooltipHandler(instance);
|
||||
}
|
||||
|
||||
protected boolean contains(int mousex, int mousey) {
|
||||
return NEIClientUtils.getHeldItem() != null
|
||||
&& (ItemPanels.bookmarkPanel.contains(mousex, mousey) || ItemPanels.itemPanel.contains(mousex, mousey)
|
||||
|| ItemPanels.itemPanel.historyPanel.contains(mousex, mousey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
|
||||
if (contains(mousex, mousey)) {
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
if (button == 1) {
|
||||
NEIClientUtils.decreaseSlotStack(-999);
|
||||
} else {
|
||||
NEIClientUtils.deleteHeldItem();
|
||||
}
|
||||
} else {
|
||||
NEIClientUtils.dropHeldItem();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
|
||||
if (contains(mousex, mousey)) {
|
||||
currenttip.clear();
|
||||
currenttip.add(EnumChatFormatting.RED + translate("itempanel.deleteItem"));
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawRect;
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -124,22 +120,6 @@ public class ItemHistoryPanel extends Widget {
|
||||
|
||||
@Override
|
||||
public boolean handleClick(int mousex, int mousey, int button) {
|
||||
|
||||
if (grid.contains(mousex, mousey) && NEIClientUtils.getHeldItem() != null) {
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
if (button == 1) {
|
||||
NEIClientUtils.decreaseSlotStack(-999);
|
||||
} else {
|
||||
NEIClientUtils.deleteHeldItem();
|
||||
}
|
||||
} else {
|
||||
NEIClientUtils.dropHeldItem();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (handleClickExt(mousex, mousey, button)) return true;
|
||||
|
||||
ItemPanelSlot hoverSlot = getSlotMouseOver(mousex, mousey);
|
||||
@@ -203,17 +183,4 @@ public class ItemHistoryPanel extends Widget {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(int mousex, int mousey, List<String> currenttip) {
|
||||
|
||||
if (grid.contains(mousex, mousey) && NEIClientUtils.getHeldItem() != null) {
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
currenttip.clear();
|
||||
currenttip.add(EnumChatFormatting.RED + translate("itempanel.deleteItem") + EnumChatFormatting.RESET);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,7 +91,8 @@ public class ItemList {
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
return pattern.matcher(EnumChatFormatting.getTextWithoutFormattingCodes(item.getDisplayName())).find();
|
||||
String displayName = EnumChatFormatting.getTextWithoutFormattingCodes(item.getDisplayName());
|
||||
return !displayName.isEmpty() && pattern.matcher(displayName).find();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,8 +42,10 @@ public class ItemZoom extends Widget implements IContainerInputHandler {
|
||||
@Override
|
||||
public void draw(int mx, int my) {
|
||||
|
||||
if (this.stack != null && (NEIClientConfig.getBooleanSetting("inventory.itemzoom.enabled")
|
||||
|| NEIClientConfig.isKeyHashDown("gui.itemzoom_hold"))) {
|
||||
if (this.stack != null
|
||||
&& (NEIClientConfig.getBooleanSetting("inventory.itemzoom.enabled")
|
||||
|| NEIClientConfig.isKeyHashDown("gui.itemzoom_hold"))
|
||||
&& GuiContainerManager.shouldShowTooltip(NEIClientUtils.getGuiContainer())) {
|
||||
final float inverseScaleFactor = 1.0f / this.scale;
|
||||
final float screenScale = getScreenScale();
|
||||
final float size = SLOT_SIZE * this.scale;
|
||||
|
||||
@@ -661,6 +661,7 @@ public class NEIClientConfig {
|
||||
ItemInfo.load(world);
|
||||
GuiInfo.load();
|
||||
RecipeInfo.load();
|
||||
HeldItemHandler.load();
|
||||
LayoutManager.load();
|
||||
NEIController.load();
|
||||
BookmarkContainerInfo.load();
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
@@ -219,22 +216,6 @@ public abstract class PanelWidget extends Widget implements IContainerTooltipHan
|
||||
|
||||
@Override
|
||||
public boolean handleClick(int mousex, int mousey, int button) {
|
||||
|
||||
if (grid.contains(mousex, mousey) && NEIClientUtils.getHeldItem() != null) {
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
if (button == 1) {
|
||||
NEIClientUtils.decreaseSlotStack(-999);
|
||||
} else {
|
||||
NEIClientUtils.deleteHeldItem();
|
||||
}
|
||||
} else {
|
||||
NEIClientUtils.dropHeldItem();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (handleClickExt(mousex, mousey, button)) return true;
|
||||
|
||||
ItemPanelSlot hoverSlot = getSlotMouseOver(mousex, mousey);
|
||||
@@ -399,14 +380,6 @@ public abstract class PanelWidget extends Widget implements IContainerTooltipHan
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
|
||||
if (grid.contains(mousex, mousey) && NEIClientUtils.getHeldItem() != null) {
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
currenttip.clear();
|
||||
currenttip.add(EnumChatFormatting.RED + translate("itempanel.deleteItem") + EnumChatFormatting.RESET);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
@@ -545,11 +545,6 @@ public class GuiContainerManager {
|
||||
}
|
||||
|
||||
public void renderToolTips(int mousex, int mousey) {
|
||||
|
||||
if (!shouldShowTooltip(window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> tooltip = new LinkedList<>();
|
||||
Map<String, String> hotkeys = new HashMap<>();
|
||||
FontRenderer font = GuiDraw.fontRenderer;
|
||||
@@ -559,7 +554,7 @@ public class GuiContainerManager {
|
||||
tooltip = handler.handleTooltip(window, mousex, mousey, tooltip);
|
||||
}
|
||||
|
||||
if (tooltip.isEmpty()) { // mouseover tip, not holding an item
|
||||
if (tooltip.isEmpty() && shouldShowTooltip(window)) { // mouseover tip, not holding an item
|
||||
ItemStack stack = getStackMouseOver(window);
|
||||
font = getFontRenderer(stack);
|
||||
if (stack != null) {
|
||||
@@ -659,6 +654,7 @@ public class GuiContainerManager {
|
||||
}
|
||||
|
||||
public static boolean shouldShowTooltip(GuiContainer window) {
|
||||
if (window == null) return false;
|
||||
for (IContainerObjectHandler handler : objectHandlers) if (!handler.shouldShowTooltip(window)) return false;
|
||||
|
||||
return window.mc.thePlayer.inventory.getItemStack() == null;
|
||||
|
||||
Reference in new issue
Block a user