mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-10-26 14:24:07 +00:00
Show Handler Icon in Bookmarks (#747)
This commit is contained in:
1 parent
f7f0596fda
commit
2ea9ae1eb9
5 files changed
+77
-14
No files matched your search
@@ -185,22 +185,24 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
&& this.grid.existsRecipe(recipeId, BookmarkGrid.DEFAULT_GROUP_ID);
|
||||
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(itemStack);
|
||||
long factor = nbTag.getInteger("Count");
|
||||
long count = factor;
|
||||
|
||||
if (existsRecipe) {
|
||||
|
||||
for (int i = 0; i < this.grid.size(); i++) {
|
||||
if (this.grid.getBookmarkItem(i).equalsRecipe(recipeId, groupId)) {
|
||||
final long multiplier = this.grid.getBookmarkItem(i).getMultiplier();
|
||||
factor *= multiplier;
|
||||
count *= this.grid.getBookmarkItem(i).getMultiplier();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (factor == 0) {
|
||||
factor = nbTag.hasKey("gtFluidName") ? Math.min(144, nbTag.getInteger("Count")) : 1;
|
||||
}
|
||||
|
||||
this.grid.addItem(BookmarkItem.of(groupId, itemStack, factor, recipeId, false), true);
|
||||
this.grid.addItem(
|
||||
BookmarkItem.of(groupId, StackInfo.withAmount(itemStack, count), factor, recipeId, false),
|
||||
true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -209,6 +209,10 @@ public class NEIClientConfig {
|
||||
0,
|
||||
OptionIntegerField.UNSIGNED_INT_MAX));
|
||||
|
||||
tag.getTag("inventory.bookmarks.showRecipeHandlerIcon").setComment("Show Recipe Handler Icon")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.showRecipeHandlerIcon", true));
|
||||
|
||||
tag.getTag("inventory.bookmarks.recipeChainDir").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.bookmarks.recipeChainDir", 2, true));
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.awt.Color;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.BookmarkPanel.BookmarkViewMode;
|
||||
import codechicken.nei.ItemPanels;
|
||||
@@ -14,6 +16,9 @@ import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIClientUtils.Alignment;
|
||||
import codechicken.nei.bookmark.BookmarkGrid.BookmarkMouseContext;
|
||||
import codechicken.nei.bookmark.RecipeChainDetails.CalculatedType;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.HandlerInfo;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
@@ -51,6 +56,7 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
protected final CalculatedType calculatedType;
|
||||
protected final CalculatedType realType;
|
||||
protected final BookmarkItem bookmarkItem;
|
||||
protected HandlerInfo handlerInfo = null;
|
||||
|
||||
protected final boolean isOutputRecipe;
|
||||
protected final boolean isFirstOutput;
|
||||
@@ -175,6 +181,13 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
&& mouseContext.recipeId.equals(this.group.crafting.itemToRecipe.get(this.itemIndex));
|
||||
}
|
||||
|
||||
protected HandlerInfo getHandlerInfo() {
|
||||
if (this.bookmarkItem.recipeId != null && this.handlerInfo == null) {
|
||||
this.handlerInfo = GuiRecipeTab.getHandlerInfo(this.bookmarkItem.recipeId.getHandleName(), null);
|
||||
}
|
||||
return this.handlerInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawItem(Rectangle4i rect) {
|
||||
super.drawItem(this.emptyItemStack, rect);
|
||||
@@ -255,27 +268,67 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
drawMarker(
|
||||
rect,
|
||||
"x" + ReadableNumberConverter.INSTANCE.toWideReadableForm(this.realMultiplier),
|
||||
0xFFFFFF);
|
||||
0xFFFFFF,
|
||||
Alignment.TopLeft);
|
||||
} else if (shownItemType == ShownItemType.SHIFT) {
|
||||
drawMarker(rect, "x" + ReadableNumberConverter.INSTANCE.toWideReadableForm(getMultiplier()), 0xFFFFFF);
|
||||
drawMarker(
|
||||
rect,
|
||||
"x" + ReadableNumberConverter.INSTANCE.toWideReadableForm(getMultiplier()),
|
||||
0xFFFFFF,
|
||||
Alignment.TopLeft);
|
||||
} else if (this.isOutputRecipe || this.realMultiplier > 1) {
|
||||
drawMarker(
|
||||
rect,
|
||||
"x" + ReadableNumberConverter.INSTANCE.toWideReadableForm(this.realMultiplier),
|
||||
NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue());
|
||||
NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue(),
|
||||
Alignment.TopLeft);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.bookmarks.showRecipeHandlerIcon")
|
||||
&& getHandlerInfo() != null) {
|
||||
drawHandlerIcon(rect);
|
||||
} else if (NEIClientConfig.showRecipeMarkerMode() == 1) {
|
||||
drawMarker(
|
||||
rect,
|
||||
"R",
|
||||
NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue());
|
||||
NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue(),
|
||||
Alignment.TopRight);
|
||||
}
|
||||
|
||||
} else if (NEIClientConfig.showRecipeMarkerMode() == 1) {
|
||||
drawMarker(rect, "R", NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue());
|
||||
drawMarker(
|
||||
rect,
|
||||
"R",
|
||||
NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue(),
|
||||
Alignment.TopRight);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void drawMarker(Rectangle4i rect, String text, int color) {
|
||||
protected void drawHandlerIcon(Rectangle4i rect) {
|
||||
float panelFactor = 1;
|
||||
|
||||
if (rect.w != DEFAULT_SLOT_SIZE) {
|
||||
panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2);
|
||||
}
|
||||
|
||||
panelFactor *= 0.4f;
|
||||
float x = rect.x + 2 + 16 - 16 * panelFactor;
|
||||
|
||||
GL11.glTranslatef(x, rect.y, 0);
|
||||
GL11.glScaled(panelFactor, panelFactor, 1.5f);
|
||||
|
||||
if (this.handlerInfo.getImage() != null) {
|
||||
this.handlerInfo.getImage().draw(0, 0);
|
||||
} else {
|
||||
GuiContainerManager.drawItem(0, 0, this.handlerInfo.getItemStack(), true, "");
|
||||
}
|
||||
|
||||
GL11.glScaled(1f / panelFactor, 1f / panelFactor, 1f / 1.5f);
|
||||
GL11.glTranslatef(-1 * x, -1 * rect.y, 0);
|
||||
}
|
||||
|
||||
protected void drawMarker(Rectangle4i rect, String text, int color, Alignment alignment) {
|
||||
final float panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2);
|
||||
NEIClientUtils.drawNEIOverlayText(
|
||||
text,
|
||||
@@ -283,7 +336,7 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
panelFactor,
|
||||
color,
|
||||
true,
|
||||
Alignment.TopLeft);
|
||||
alignment);
|
||||
}
|
||||
|
||||
protected void drawStackSize(Rectangle4i rect, ShownItemType shownItemType) {
|
||||
|
||||
@@ -229,8 +229,12 @@ nei.options.inventory.bookmarks.recipeTooltipsMode.2=In Vertical View
|
||||
nei.options.inventory.bookmarks.recipeTooltipsMode.3=Always
|
||||
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.1=Text
|
||||
nei.options.inventory.bookmarks.showRecipeMarkerMode.2=Background
|
||||
nei.options.inventory.bookmarks.showRecipeHandlerIcon=Show Handler Icon
|
||||
nei.options.inventory.bookmarks.showRecipeHandlerIcon.true=Yes
|
||||
nei.options.inventory.bookmarks.showRecipeHandlerIcon.false=No
|
||||
|
||||
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
|
||||
|
||||
@@ -179,7 +179,7 @@ nei.options.inventory.bookmarks.recipeTooltipsMode.2=В вертикальном
|
||||
nei.options.inventory.bookmarks.recipeTooltipsMode.3=Всегда
|
||||
nei.options.inventory.bookmarks.showRecipeMarkerMode=Показывать маркер рецепта
|
||||
nei.options.inventory.bookmarks.showRecipeMarkerMode.0=Нет
|
||||
nei.options.inventory.bookmarks.showRecipeMarkerMode.1=Иконка
|
||||
nei.options.inventory.bookmarks.showRecipeMarkerMode.1=Текст
|
||||
nei.options.inventory.bookmarks.showRecipeMarkerMode.2=Фон
|
||||
nei.options.inventory.bookmarks.ignorePotionOverlap=Игнорировать перекрытие с HUD эффектов зелий
|
||||
nei.options.inventory.bookmarks.ignorePotionOverlap.true=Да
|
||||
|
||||
Reference in new issue
Block a user