diff --git a/src/main/java/codechicken/nei/ItemsGrid.java b/src/main/java/codechicken/nei/ItemsGrid.java index 3ab55b27..9b440af6 100644 --- a/src/main/java/codechicken/nei/ItemsGrid.java +++ b/src/main/java/codechicken/nei/ItemsGrid.java @@ -178,14 +178,14 @@ public abstract class ItemsGrid { - double offsetX = Math.ceil(x); - double offsetY = Math.ceil(y); - - if (alignRight) { - offsetX = Math.ceil(x + 16 * scale - GuiDraw.fontRenderer.getStringWidth(text) * smallTextScale); - } - - if (alignBottom) { - offsetY = Math - .ceil(y + 16 * scale - GuiDraw.fontRenderer.FONT_HEIGHT * smallTextScale + smallTextScale); - } + final int width = GuiDraw.fontRenderer.getStringWidth(text); + final float partW = rect.w / 2f; + final float partH = rect.h / 2f; + final double offsetX = Math + .ceil(rect.x + partW + partW * alignment.x - (width / 2f * (alignment.x + 1)) * smallTextScale); + final double offsetY = Math.ceil( + rect.y + partH + + partH * alignment.y + - (GuiDraw.fontRenderer.FONT_HEIGHT / 2f * (alignment.y + 1)) * smallTextScale); GL11.glTranslated(offsetX, offsetY, 0); - GL11.glScalef(smallTextScale, smallTextScale, 1f); - - GuiDraw.fontRenderer.drawStringWithShadow(text, 0, 0, color); - - GL11.glScalef(1f / smallTextScale, 1f / smallTextScale, 1f); + GL11.glScaled(smallTextScale, smallTextScale, 1); + GuiDraw.fontRenderer.drawString(text, 0, 0, color, shadow); + GL11.glScaled(1 / smallTextScale, 1 / smallTextScale, 1); GL11.glTranslated(-1 * offsetX, -1 * offsetY, 0); }); } + public static void drawNEIOverlayText(String text, int x, int y) { + drawNEIOverlayText(text, new Rectangle4i(x, y, 16, 16), 0.5f, 0xFDD835, false, Alignment.TopLeft); + } + public static void gl2DRenderContext(Runnable callback) { boolean isLighting = GL11.glGetBoolean(GL11.GL_LIGHTING); boolean isDepthTest = GL11.glGetBoolean(GL11.GL_DEPTH_TEST); diff --git a/src/main/java/codechicken/nei/bookmark/BookmarkGridGenerator.java b/src/main/java/codechicken/nei/bookmark/BookmarkGridGenerator.java index 20906b4f..f57ca36b 100644 --- a/src/main/java/codechicken/nei/bookmark/BookmarkGridGenerator.java +++ b/src/main/java/codechicken/nei/bookmark/BookmarkGridGenerator.java @@ -236,11 +236,10 @@ public class BookmarkGridGenerator { index++; } else if (viewMode == BookmarkViewMode.DEFAULT) { return index; - } else if (isFirstColumn && (meta.recipeId == null || !meta.isIngredient - || previousMeta == null + } else if (isFirstColumn && (meta.recipeId == null || previousMeta == null || previousMeta.groupId != meta.groupId - || index + 1 < maxIndex && this.grid.isInvalidSlot((index + 1) % maxIndex) - || meta.isIngredient && !meta.recipeId.equals(previousMeta.recipeId))) { + || !meta.recipeId.equals(previousMeta.recipeId) + || index + 1 < maxIndex && this.grid.isInvalidSlot((index + 1) % maxIndex))) { // In first column must be an item without recipe, a recipe result, or an ingredient // if the second column is occupied return index; diff --git a/src/main/java/codechicken/nei/bookmark/BookmarksGridSlot.java b/src/main/java/codechicken/nei/bookmark/BookmarksGridSlot.java index 5438ecfd..c9ef5b6f 100644 --- a/src/main/java/codechicken/nei/bookmark/BookmarksGridSlot.java +++ b/src/main/java/codechicken/nei/bookmark/BookmarksGridSlot.java @@ -11,6 +11,7 @@ import codechicken.nei.ItemsGrid.ItemsGridSlot; import codechicken.nei.ItemsGrid.MouseContext; import codechicken.nei.NEIClientConfig; import codechicken.nei.NEIClientUtils; +import codechicken.nei.NEIClientUtils.Alignment; import codechicken.nei.bookmark.BookmarkGrid.BookmarkMouseContext; import codechicken.nei.bookmark.RecipeChainDetails.CalculatedType; import codechicken.nei.recipe.Recipe.RecipeId; @@ -90,7 +91,8 @@ public class BookmarksGridSlot extends ItemsGridSlot { final BookmarkGrid grid = ItemPanels.bookmarkPanel.getGrid(); final BookmarkItem prevItem = grid.getCalculatedItem( grid.gridGenerator.slotToItem.getOrDefault(grid.gridGenerator.itemToSlot.get(this.itemIndex) - 1, -1)); - this.isFirstOutput = this.itemIndex >= 0 + this.isFirstOutput = this.itemIndex >= 0 && !this.bookmarkItem.isIngredient + && ((this.slotIndex % grid.getColumns()) == 0 || group.viewMode == BookmarkViewMode.DEFAULT) && (prevItem == null || prevItem.isIngredient || !this.bookmarkItem.equalsRecipe(prevItem)); this.rowIndex = this.slotIndex / grid.getColumns(); } @@ -252,26 +254,35 @@ public class BookmarksGridSlot extends ItemsGridSlot { drawMarker( rect, "x" + ReadableNumberConverter.INSTANCE.toWideReadableForm(this.realMultiplier), - 0xAAAAAA); + 0xFFFFFF); } else if (shownItemType == ShownItemType.SHIFT) { drawMarker(rect, "x" + ReadableNumberConverter.INSTANCE.toWideReadableForm(getMultiplier()), 0xFFFFFF); - } else if (this.isOutputRecipe) { + } else if (this.isOutputRecipe || this.realMultiplier > 1) { drawMarker( rect, "x" + ReadableNumberConverter.INSTANCE.toWideReadableForm(this.realMultiplier), - 0xAAAAAA); + NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue()); } else if (NEIClientConfig.showRecipeMarkerMode() == 1) { - drawMarker(rect, "R", 0xA0A0A0); + drawMarker( + rect, + "R", + NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue()); } } else if (NEIClientConfig.showRecipeMarkerMode() == 1) { - drawMarker(rect, "R", 0xA0A0A0); + drawMarker(rect, "R", NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue()); } } protected void drawMarker(Rectangle4i rect, String text, int color) { - final float panelFactor = rect.w / DEFAULT_SLOT_SIZE; - NEIClientUtils.drawMarker(rect.x + panelFactor, rect.y + panelFactor, panelFactor, text, color, false, false); + final float panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2); + NEIClientUtils.drawNEIOverlayText( + text, + new Rectangle4i(rect.x + 1, rect.y + 1, rect.w - 2, rect.h - 2), + panelFactor, + color, + true, + Alignment.TopLeft); } protected void drawStackSize(Rectangle4i rect, ShownItemType shownItemType) { @@ -284,7 +295,7 @@ public class BookmarksGridSlot extends ItemsGridSlot { } if (amount > 0 || shownItemType == ShownItemType.REAL && this.bookmarkItem.factor > 0) { - final float panelFactor = rect.w / DEFAULT_SLOT_SIZE; + final float panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2); final long stackSize = this.bookmarkItem.getStackSize(amount); String amountString = ""; @@ -298,14 +309,13 @@ public class BookmarksGridSlot extends ItemsGridSlot { amountString += "L"; } - NEIClientUtils.drawMarker( - rect.x + panelFactor, - rect.y + panelFactor, - panelFactor, + NEIClientUtils.drawNEIOverlayText( amountString, + new Rectangle4i(rect.x + 1, rect.y + 1, rect.w - 2, rect.h - 2), + panelFactor, 0xFFFFFF, - !this.isFluidDisplay, - true); + true, + this.isFluidDisplay ? Alignment.BottomLeft : Alignment.BottomRight); } } diff --git a/src/main/java/codechicken/nei/recipe/AcceptsFollowingTooltipLineHandler.java b/src/main/java/codechicken/nei/recipe/AcceptsFollowingTooltipLineHandler.java index 1b522265..24232d36 100644 --- a/src/main/java/codechicken/nei/recipe/AcceptsFollowingTooltipLineHandler.java +++ b/src/main/java/codechicken/nei/recipe/AcceptsFollowingTooltipLineHandler.java @@ -43,7 +43,7 @@ public class AcceptsFollowingTooltipLineHandler extends ItemsTooltipLineHandler super.drawItem(x, y, drawStack, stackSize); if (FavoriteRecipes.contains(drawStack)) { - NEIClientUtils.drawMarker(x, y, 1f, "F", 0xA0A0A0, false, false); + NEIClientUtils.drawNEIOverlayText("F", x, y); } } diff --git a/src/main/java/codechicken/nei/recipe/GuiRecipe.java b/src/main/java/codechicken/nei/recipe/GuiRecipe.java index 0fa2a21f..77de03b8 100644 --- a/src/main/java/codechicken/nei/recipe/GuiRecipe.java +++ b/src/main/java/codechicken/nei/recipe/GuiRecipe.java @@ -627,7 +627,7 @@ public abstract class GuiRecipe extends GuiContainer i } public Recipe getFocusedRecipe() { - List indices = getRecipeIndices(); + final List indices = getRecipeIndices(); for (int refIndex = 0; refIndex < indices.size(); refIndex++) { final int recipeIndex = indices.get(refIndex); @@ -641,7 +641,6 @@ public abstract class GuiRecipe extends GuiContainer i protected boolean recipeInFocus(int refIndex, int recipeIndex) { final PositionedStack result = handler.original.getResultStack(recipeIndex); - if (result != null && isMouseOver(result, refIndex)) { return true; } @@ -656,6 +655,15 @@ public abstract class GuiRecipe extends GuiContainer i return false; } + private boolean isMouseOver(PositionedStack stack, int refIndex) { + Point p = getRefIndexPosition(refIndex); + Point mousepos = GuiDraw.getMousePosition(); + Slot stackSlot = slotcontainer.getSlotWithStack(stack, p.x, p.y); + Slot mouseoverSlot = getSlotAtPosition(mousepos.x, mousepos.y); + + return stackSlot == mouseoverSlot; + } + public String getHandlerName() { return handlerInfo.getHandlerName(); } @@ -1204,15 +1212,6 @@ public abstract class GuiRecipe extends GuiContainer i return firstGuiGeneral; } - public boolean isMouseOver(PositionedStack stack, int refIndex) { - Point p = getRefIndexPosition(refIndex); - Point mousepos = GuiDraw.getMousePosition(); - Slot stackSlot = slotcontainer.getSlotWithStack(stack, p.x, p.y); - Slot mouseoverSlot = getSlotAtPosition(mousepos.x, mousepos.y); - - return stackSlot == mouseoverSlot; - } - private int getRecipesPerPage() { return limitToOneRecipe ? 1 : getRecipesPerPage(handlerInfo); } diff --git a/src/main/java/codechicken/nei/recipe/RecipeItemInputHandler.java b/src/main/java/codechicken/nei/recipe/RecipeItemInputHandler.java index c44ab80c..5072537c 100644 --- a/src/main/java/codechicken/nei/recipe/RecipeItemInputHandler.java +++ b/src/main/java/codechicken/nei/recipe/RecipeItemInputHandler.java @@ -7,6 +7,7 @@ import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; import codechicken.lib.gui.GuiDraw; +import codechicken.lib.vec.Rectangle4i; import codechicken.nei.BookmarkPanel.BookmarkViewMode; import codechicken.nei.FavoriteRecipes; import codechicken.nei.ItemPanels; @@ -101,7 +102,14 @@ public class RecipeItemInputHandler implements IContainerInputHandler, IContaine if (ItemPanels.itemPanel.contains(mousex, mousey) || ItemPanels.itemPanel.historyPanel.contains(mousex, mousey)) { - return NEIClientConfig.getFavoriteRecipeTooltips() ? FavoriteRecipes.getFavorite(itemstack) : null; + return NEIClientConfig.showRecipeTooltipInPanel() ? FavoriteRecipes.getFavorite(itemstack) : null; + } + + if (gui instanceof GuiRecipeguiRecipe + && new Rectangle4i(gui.guiLeft, gui.guiTop, gui.xSize, gui.ySize).contains(mousex, mousey) + && NEIClientConfig.showRecipeTooltipInGui() + && guiRecipe.getFocusedRecipe() == null) { + return FavoriteRecipes.getFavorite(itemstack); } return null; diff --git a/src/main/resources/assets/nei/lang/en_US.lang b/src/main/resources/assets/nei/lang/en_US.lang index 19ece8b3..ec2a880e 100644 --- a/src/main/resources/assets/nei/lang/en_US.lang +++ b/src/main/resources/assets/nei/lang/en_US.lang @@ -211,6 +211,7 @@ nei.options.inventory.bookmarks.showRecipeMarkerMode=Show Recipe Marker nei.options.inventory.bookmarks.showRecipeMarkerMode.0=None nei.options.inventory.bookmarks.showRecipeMarkerMode.1=Icon nei.options.inventory.bookmarks.showRecipeMarkerMode.2=Background +nei.options.inventory.bookmarks.recipeMarkerColor=Recipe Marker Color nei.options.inventory.bookmarks.ignorePotionOverlap=Ignore overlap with potion effect HUD nei.options.inventory.bookmarks.ignorePotionOverlap.true=Yes nei.options.inventory.bookmarks.ignorePotionOverlap.false=No @@ -224,9 +225,12 @@ nei.options.inventory.favorites.enabled.false=Hidden nei.options.inventory.favorites.worldSpecific=World Specific nei.options.inventory.favorites.worldSpecific.true=Yes nei.options.inventory.favorites.worldSpecific.false=No -nei.options.inventory.favorites.showRecipeTooltip=Show Recipe Tooltips in Right Panel -nei.options.inventory.favorites.showRecipeTooltip.true=Yes -nei.options.inventory.favorites.showRecipeTooltip.false=No +nei.options.inventory.favorites.showRecipeTooltipInPanel=Show Recipe Tooltips in Right Panel +nei.options.inventory.favorites.showRecipeTooltipInPanel.true=Yes +nei.options.inventory.favorites.showRecipeTooltipInPanel.false=No +nei.options.inventory.favorites.showRecipeTooltipInGui=Show Recipe Tooltips in Recipe Gui +nei.options.inventory.favorites.showRecipeTooltipInGui.true=Yes +nei.options.inventory.favorites.showRecipeTooltipInGui.false=No nei.options.inventory.favorites.depth=Depth nei.options.inventory.hotkeysHelpText=Show Hotkeys Help Text nei.options.inventory.hotkeysHelpText.true=Yes