mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 18:54:45 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a02d293d44 | ||
|
|
1265113390 | ||
|
|
4ffd614017 | ||
|
|
41554f4c5b | ||
|
|
2104184077 | ||
|
|
d5f25a4be8 | ||
|
|
ccbf94790a |
No files matched your search
@@ -45,6 +45,7 @@ import codechicken.core.ClassDiscoverer;
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
@@ -374,6 +375,7 @@ public class ClientHandler {
|
||||
} else if (event.gui == null) {
|
||||
/* prevent WorldClient reference being held in the Gui */
|
||||
NEIController.manager = null;
|
||||
GuiInfo.clearGuiHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -251,7 +251,6 @@ public class ItemList {
|
||||
|
||||
private void updateOrdering(List<ItemStack> items) {
|
||||
final Map<ItemStack, Integer> newOrdering = new HashMap<>();
|
||||
ItemSorter.sort(items);
|
||||
|
||||
if (!CollapsibleItems.isEmpty()) {
|
||||
final HashMap<Integer, Integer> groups = new HashMap<>();
|
||||
@@ -424,6 +423,9 @@ public class ItemList {
|
||||
}
|
||||
}
|
||||
|
||||
if (interrupted()) return;
|
||||
ItemSorter.sort(items);
|
||||
|
||||
if (interrupted()) return;
|
||||
ItemList.items = items;
|
||||
ItemList.itemMap = itemMap;
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
@@ -27,7 +28,7 @@ public abstract class ItemsGrid<T extends ItemsGrid.ItemsGridSlot, M extends Ite
|
||||
protected static class ScreenCapture {
|
||||
|
||||
private long nextCacheRefresh = 0;
|
||||
private Framebuffer framebuffer;
|
||||
private final Framebuffer framebuffer;
|
||||
|
||||
public ScreenCapture() {
|
||||
this.framebuffer = new Framebuffer(1, 1, true);
|
||||
@@ -51,7 +52,7 @@ public abstract class ItemsGrid<T extends ItemsGrid.ItemsGridSlot, M extends Ite
|
||||
}
|
||||
|
||||
public void captureScreen(Runnable callback, int mode) {
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
|
||||
resetFramebuffer();
|
||||
this.framebuffer.bindFramebuffer(false);
|
||||
@@ -84,6 +85,21 @@ public abstract class ItemsGrid<T extends ItemsGrid.ItemsGridSlot, M extends Ite
|
||||
} else {
|
||||
this.framebuffer.framebufferClear();
|
||||
}
|
||||
|
||||
// Copy stencil values (required by mui2)
|
||||
OpenGlHelper.func_153171_g(GL30.GL_READ_FRAMEBUFFER, minecraft.getFramebuffer().framebufferObject);
|
||||
OpenGlHelper.func_153171_g(GL30.GL_DRAW_FRAMEBUFFER, this.framebuffer.framebufferObject);
|
||||
GL30.glBlitFramebuffer(
|
||||
0,
|
||||
0,
|
||||
minecraft.displayWidth,
|
||||
minecraft.displayHeight,
|
||||
0,
|
||||
0,
|
||||
minecraft.displayWidth,
|
||||
minecraft.displayHeight,
|
||||
GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT,
|
||||
GL11.GL_NEAREST);
|
||||
}
|
||||
|
||||
public void renderCapturedScreen() {
|
||||
|
||||
@@ -263,6 +263,10 @@ public class NEIClientConfig {
|
||||
.setComment("Require holding shift to move items when overlaying recipe").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.shiftOverlayRecipe", true));
|
||||
|
||||
tag.getTag("inventory.guirecipe.scrollPages").setComment("Disable page scroll when overlaying recipe")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.scrollPages", true));
|
||||
|
||||
tag.getTag("inventory.guirecipe.profile").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.profile", true));
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.LinkedList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.config.GuiOptionList;
|
||||
import codechicken.nei.config.OptionCycled;
|
||||
|
||||
public class NEIInfo {
|
||||
@@ -13,7 +14,8 @@ public class NEIInfo {
|
||||
|
||||
public static void load(World world) {
|
||||
OptionCycled modeOption = (OptionCycled) NEIClientConfig.getOptionList().getOption("inventory.cheatmode");
|
||||
modeOption.parent.synthesizeEnvironment(false);
|
||||
// kept alive so the WeakReference in Option.slotRef isn't GC'd before copyGlobals/cycle use it
|
||||
GuiOptionList env = modeOption.parent.synthesizeEnvironment(false);
|
||||
if (!modeOption.optionValid(modeOption.value())) {
|
||||
modeOption.copyGlobals();
|
||||
modeOption.cycle();
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class DataDumper extends Option {
|
||||
|
||||
public Rectangle4i dumpButtonSize() {
|
||||
int width = 80;
|
||||
return new Rectangle4i(slot.slotWidth() - width, 0, width, 20);
|
||||
return new Rectangle4i(getSlot().slotWidth() - width, 0, width, 20);
|
||||
}
|
||||
|
||||
public Rectangle4i modeButtonSize() {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class GuiHighlightTips extends GuiScreenWidget {
|
||||
@Override
|
||||
public void keyTyped(char c, int keycode) {
|
||||
if (keycode == Keyboard.KEY_ESCAPE || keycode == Keyboard.KEY_BACK) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(opt.slot.getGui());
|
||||
Minecraft.getMinecraft().displayGuiScreen(opt.getSlot().getGui());
|
||||
return;
|
||||
}
|
||||
super.keyTyped(c, keycode);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class GuiItemIconDumper extends GuiScreen {
|
||||
}
|
||||
|
||||
private void returnScreen(IChatComponent msg) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(opt.slot.getGui());
|
||||
Minecraft.getMinecraft().displayGuiScreen(opt.getSlot().getGui());
|
||||
NEIClientUtils.printChatMessage(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class GuiItemSorter extends GuiOptionPane {
|
||||
|
||||
@Override
|
||||
public GuiScreen getParentScreen() {
|
||||
return opt.slot.getGui();
|
||||
return opt.getSlot().getGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -247,7 +247,7 @@ public class GuiPanelSettings extends GuiScreenWidget {
|
||||
public void keyTyped(char c, int keycode) {
|
||||
|
||||
if (keycode == Keyboard.KEY_ESCAPE || keycode == Keyboard.KEY_BACK) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(opt.slot.getGui());
|
||||
Minecraft.getMinecraft().displayGuiScreen(opt.getSlot().getGui());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,8 +99,9 @@ public class IMCHandler {
|
||||
NEIClientConfig.logger.info("Error setting handler dimensions for {}", handler);
|
||||
}
|
||||
|
||||
// true if not set to false
|
||||
info.setUseCustomScroll(tag.hasKey("useCustomScroll") && tag.getBoolean("useCustomScroll"));
|
||||
final boolean allowOverflow = tag.hasKey("useCustomScroll") && tag.getBoolean("useCustomScroll");
|
||||
info.setAllowOverflowX(tag.hasKey("allowOverflowX") ? tag.getBoolean("allowOverflowX") : true);
|
||||
info.setAllowOverflowY(tag.hasKey("allowOverflowY") ? tag.getBoolean("allowOverflowY") : allowOverflow);
|
||||
info.setShowFavoritesButton(!tag.hasKey("showFavoritesButton") || tag.getBoolean("showFavoritesButton"));
|
||||
info.setShowOverlayButton(!tag.hasKey("showOverlayButton") || tag.getBoolean("showOverlayButton"));
|
||||
info.setShowBadge(tag.hasKey("showBadge") && tag.getBoolean("showBadge"));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package codechicken.nei.config;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -17,7 +18,11 @@ public abstract class Option {
|
||||
.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
|
||||
public OptionScrollSlot slot;
|
||||
private WeakReference<OptionScrollSlot> slotRef;
|
||||
|
||||
public OptionScrollSlot getSlot() {
|
||||
return slotRef != null ? slotRef.get() : null;
|
||||
}
|
||||
|
||||
public String namespace = null;
|
||||
public final String name;
|
||||
@@ -134,7 +139,7 @@ public abstract class Option {
|
||||
* @return true if the gui is in world config mode
|
||||
*/
|
||||
public boolean worldConfig() {
|
||||
return slot.getGui().worldConfig();
|
||||
return getSlot().getGui().worldConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +194,7 @@ public abstract class Option {
|
||||
}
|
||||
|
||||
public void onAdded(OptionScrollSlot slot) {
|
||||
this.slot = slot;
|
||||
this.slotRef = new WeakReference<>(slot);
|
||||
}
|
||||
|
||||
public void onAdded(OptionList list) {
|
||||
|
||||
@@ -57,10 +57,10 @@ public abstract class OptionButton extends Option {
|
||||
}
|
||||
|
||||
public Rectangle buttonSize() {
|
||||
if (getPrefix() == null) return new Rectangle(0, 0, slot.slotWidth(), 20);
|
||||
if (getPrefix() == null) return new Rectangle(0, 0, getSlot().slotWidth(), 20);
|
||||
|
||||
int width = Math.max(60, getStringWidth(getButtonText()) + 8);
|
||||
return new Rectangle(slot.slotWidth() - width, 0, width, 20);
|
||||
return new Rectangle(getSlot().slotWidth() - width, 0, width, 20);
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
|
||||
@@ -85,7 +85,7 @@ public class OptionKeyBind extends OptionButton {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Option o : slot.options) {
|
||||
for (Option o : getSlot().options) {
|
||||
if (o instanceof OptionKeyBind && o != this && ((OptionKeyBind) o).getValue() == keyboard) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -131,13 +131,15 @@ public class OptionList extends OptionButton {
|
||||
/**
|
||||
* Adds this option to a temporary slot and gui for internal setting manipulation.
|
||||
*/
|
||||
public void synthesizeEnvironment(boolean world) {
|
||||
getGui(null, this, world).addWidgets();
|
||||
public GuiOptionList synthesizeEnvironment(boolean world) {
|
||||
GuiOptionList gui = getGui(null, this, world);
|
||||
gui.addWidgets();
|
||||
return gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
openGui(slot.getGui(), slot.getGui().worldConfig());
|
||||
openGui(getSlot().getGui(), getSlot().getGui().worldConfig());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,6 @@ public abstract class OptionStringSet extends Option {
|
||||
}
|
||||
|
||||
public int buttonX() {
|
||||
return slot.slotWidth() - (24 * options.size() - 4);
|
||||
return getSlot().slotWidth() - (24 * options.size() - 4);
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class OptionTextField extends Option {
|
||||
}
|
||||
|
||||
protected int getMaxInputWidth() {
|
||||
return slot.slotWidth();
|
||||
return getSlot().slotWidth();
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
@@ -64,9 +64,10 @@ public class OptionTextField extends Option {
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
GuiDraw.drawString(getPrefix(), 10, 6, -1);
|
||||
|
||||
textField.w = Math
|
||||
.max(60, Math.min(getMaxInputWidth(), slot.slotWidth() - GuiDraw.getStringWidth(getPrefix())) - 16);
|
||||
textField.x = slot.slotWidth() - textField.w;
|
||||
textField.w = Math.max(
|
||||
60,
|
||||
Math.min(getMaxInputWidth(), getSlot().slotWidth() - GuiDraw.getStringWidth(getPrefix())) - 16);
|
||||
textField.x = getSlot().slotWidth() - textField.w;
|
||||
textField.draw(mousex, mousey);
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ public class GuiPresetList extends GuiOptionPane {
|
||||
|
||||
@Override
|
||||
public GuiScreen getParentScreen() {
|
||||
return opt.slot.getGui();
|
||||
return opt.getSlot().getGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -92,6 +92,9 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
private GuiButton prevtype;
|
||||
private GuiButton nexttype;
|
||||
|
||||
private Rectangle typeArea = new Rectangle();
|
||||
private Rectangle pageArea = new Rectangle();
|
||||
|
||||
private int lastPage = -1;
|
||||
private final GuiRecipeTabs recipeTabs;
|
||||
private final GuiRecipeCatalyst recipeCatalyst;
|
||||
@@ -308,7 +311,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
@Override
|
||||
public Widget getWidgetUnderMouse(int mousex, int mousey) {
|
||||
|
||||
if (handlerInfo.getUseCustomScroll() && !this.widgets.isEmpty()) {
|
||||
if (handlerInfo.isAllowOverflowY() && !this.widgets.isEmpty()) {
|
||||
return this.widgets.get(0);
|
||||
}
|
||||
|
||||
@@ -346,7 +349,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
this.container.x = this.guiLeft + 3;
|
||||
this.container.y = this.guiTop + 32;
|
||||
this.container.h = this.ySize - 32 - 5;
|
||||
this.container.h = this.ySize - 32 - 4;
|
||||
|
||||
GuiRecipe.toggleSearch.icon = new DrawableBuilder("nei:textures/nei_sprites.png", 0, 76, 10, 10).build();
|
||||
GuiRecipe.toggleSearch.w = GuiRecipe.toggleSearch.h = 12;
|
||||
@@ -358,8 +361,18 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
GuiRecipe.searchField.w = this.xSize - (BORDER_PADDING + BUTTON_WIDTH) * 2 + 1 - GuiRecipe.toggleSearch.w - 45;
|
||||
GuiRecipe.searchField.h = 14;
|
||||
|
||||
this.buttonList.addAll(Arrays.asList(this.prevtype, this.nexttype, this.prevpage, this.nextpage));
|
||||
this.typeArea.setBounds(
|
||||
this.prevtype.xPosition + BUTTON_WIDTH,
|
||||
this.prevtype.yPosition,
|
||||
this.nexttype.xPosition - this.prevtype.xPosition - BUTTON_WIDTH - 1,
|
||||
BUTTON_HEIGHT);
|
||||
this.pageArea.setBounds(
|
||||
this.prevpage.xPosition + BUTTON_WIDTH,
|
||||
this.prevpage.yPosition,
|
||||
this.nextpage.xPosition - this.prevpage.xPosition - BUTTON_WIDTH - 1,
|
||||
BUTTON_HEIGHT);
|
||||
|
||||
this.buttonList.addAll(Arrays.asList(this.prevtype, this.nexttype, this.prevpage, this.nextpage));
|
||||
if (this.currenthandlers.size() == 1) {
|
||||
this.prevtype.visible = false;
|
||||
this.nexttype.visible = false;
|
||||
@@ -372,9 +385,19 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
if (this.handlerPages.rebuildPages() || this.lastPage != this.handlerPages.getCurrentPageIndex()) {
|
||||
this.lastPage = this.handlerPages.getCurrentPageIndex();
|
||||
updateContainerSize();
|
||||
|
||||
this.container.setWidgets(this.handlerPages.getCurrentPageWidgets());
|
||||
|
||||
if (this.handlerInfo.getUseCustomScroll()) {
|
||||
if (!this.handlerInfo.isAllowOverflowX() && this.handlerInfo.getWidth() > this.xSize - 6) {
|
||||
this.container.setPaddingInline(0, 2);
|
||||
this.container.setHorizontalScroll(ScrollBar.defaultHorizontalBar().setTrackPadding(1, 0, 1, 0));
|
||||
} else {
|
||||
this.container.setPaddingInline(0, 0);
|
||||
this.container.setHorizontalScroll(null);
|
||||
}
|
||||
|
||||
if (this.handlerInfo.isAllowOverflowY()) {
|
||||
this.container.setVerticalScroll(null);
|
||||
} else if (this.container.w == this.xSize - 6) {
|
||||
this.container.setVerticalScroll(VERTICAL_SCROLLBAR);
|
||||
@@ -416,7 +439,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
this.recipetype = (this.currenthandlers.size() + idx) % this.currenthandlers.size();
|
||||
this.handler = new SearchRecipeHandler<>(this.currenthandlers.get(this.recipetype));
|
||||
this.handlerInfo = GuiRecipeTab.getHandlerInfo(this.handler.original);
|
||||
this.container.w = Math.max(this.xSize - 6, this.handlerInfo.getWidth());
|
||||
updateContainerSize();
|
||||
this.handlerPages = new RecipePageManager(this.handler, this.handlerInfo, this.container);
|
||||
this.prevpage.enabled = this.nextpage.enabled = this.handlerPages.getNumPages() > 1;
|
||||
this.lastPage = -1;
|
||||
@@ -426,9 +449,21 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
GuiRecipe.toggleSearch.state = 0;
|
||||
|
||||
this.container.setVerticalScrollOffset(0);
|
||||
this.container.setHorizontalScrollOffset(0);
|
||||
this.recipeTabs.update(this);
|
||||
}
|
||||
|
||||
private void updateContainerSize() {
|
||||
final int width = this.xSize - 6;
|
||||
this.container.w = Math.max(width, this.handlerInfo.getWidth());
|
||||
this.container.h = this.ySize - 32 - 4;
|
||||
|
||||
if (!this.handlerInfo.isAllowOverflowX() && this.handlerInfo.getWidth() > width) {
|
||||
this.container.w = width;
|
||||
this.container.h -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
public int openTargetRecipe(RecipeId recipeId) {
|
||||
int refIndex = -1;
|
||||
int recipetype = 0;
|
||||
@@ -671,7 +706,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
// If shift is held, try switching to the next recipe handler. Replicates the
|
||||
// GuiRecipeTabs.mouseScrolled()
|
||||
// without the checking for the cursor being inside the tabbar.
|
||||
if (NEIClientUtils.shiftKey()) {
|
||||
if (NEIClientUtils.shiftKey() || this.typeArea.contains(mouse)) {
|
||||
if (scroll < 0) {
|
||||
nextType();
|
||||
} else {
|
||||
@@ -683,7 +718,12 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
// Finally, if nothing else has handled scrolling, try changing to the next
|
||||
// recipe page.
|
||||
if (new Rectangle(this.guiLeft, this.guiTop, this.xSize, this.ySize).contains(mouse)) {
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.guirecipe.scrollPages")
|
||||
&& this.container.boundsInside().contains(mouse.x, mouse.y)
|
||||
|| this.pageArea.contains(mouse)
|
||||
&& (!this.handler.searchingAvailable() || !GuiRecipe.toggleSearch.contains(mouse.x, mouse.y))
|
||||
&& (!GuiRecipe.searchField.isVisible() || !GuiRecipe.searchField.contains(mouse.x, mouse.y))) {
|
||||
|
||||
if (scroll > 0) {
|
||||
prevPage();
|
||||
} else {
|
||||
@@ -825,16 +865,16 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
final int textMiddle = (BUTTON_WIDTH - this.fontRendererObj.FONT_HEIGHT) / 2;
|
||||
|
||||
drawRect(
|
||||
this.prevtype.xPosition + BUTTON_WIDTH - 1,
|
||||
this.prevtype.yPosition,
|
||||
this.nexttype.xPosition,
|
||||
this.prevtype.yPosition + BUTTON_HEIGHT,
|
||||
this.typeArea.x,
|
||||
this.typeArea.y,
|
||||
this.typeArea.x + this.typeArea.width,
|
||||
this.typeArea.y + this.typeArea.height,
|
||||
0x30000000);
|
||||
drawRect(
|
||||
this.prevpage.xPosition + BUTTON_WIDTH - 1,
|
||||
this.prevpage.yPosition,
|
||||
this.nextpage.xPosition,
|
||||
this.prevpage.yPosition + BUTTON_HEIGHT,
|
||||
this.pageArea.x,
|
||||
this.pageArea.y,
|
||||
this.pageArea.x + this.pageArea.width,
|
||||
this.pageArea.y + this.pageArea.height,
|
||||
0x30000000);
|
||||
|
||||
final String handlerTitle = this.handler.original.getRecipeName().trim();
|
||||
@@ -843,7 +883,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
this.fontRendererObj,
|
||||
titleColorCode + handlerTitle + EnumChatFormatting.RESET,
|
||||
this.guiLeft + this.xSize / 2,
|
||||
this.prevtype.yPosition + textMiddle,
|
||||
this.typeArea.y + textMiddle,
|
||||
0xffffff);
|
||||
|
||||
if (this.handler.searchingAvailable()) {
|
||||
@@ -866,7 +906,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
this.fontRendererObj,
|
||||
recipePage,
|
||||
GuiRecipe.searchField.x + GuiRecipe.searchField.w + 22,
|
||||
this.prevpage.yPosition + textMiddle,
|
||||
this.pageArea.y + textMiddle,
|
||||
0xffffff);
|
||||
} else {
|
||||
final String recipePage = NEIClientUtils.translate(
|
||||
@@ -877,7 +917,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
this.fontRendererObj,
|
||||
recipePage,
|
||||
this.guiLeft + this.xSize / 2,
|
||||
this.prevpage.yPosition + textMiddle,
|
||||
this.pageArea.y + textMiddle,
|
||||
0xffffff);
|
||||
}
|
||||
|
||||
|
||||
@@ -263,8 +263,13 @@ public abstract class GuiRecipeTab extends Widget {
|
||||
NEIClientConfig.logger.info("Error setting handler dimensions for " + handler);
|
||||
}
|
||||
|
||||
info.setUseCustomScroll(
|
||||
record.isSet("useCustomScroll") ? Boolean.parseBoolean(record.get("useCustomScroll")) : false);
|
||||
final boolean allowOverflow = record.isSet("useCustomScroll")
|
||||
&& Boolean.parseBoolean(record.get("useCustomScroll"));
|
||||
info.setAllowOverflowX(
|
||||
record.isSet("allowOverflowX") ? Boolean.parseBoolean(record.get("allowOverflowX")) : true);
|
||||
info.setAllowOverflowY(
|
||||
record.isSet("allowOverflowY") ? Boolean.parseBoolean(record.get("allowOverflowY"))
|
||||
: allowOverflow);
|
||||
handlerMap.put(handler, info);
|
||||
NEIClientConfig.logger.info("Loaded " + handler);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@ public class HandlerInfo {
|
||||
private boolean showFavoritesButton = true;
|
||||
private boolean showOverlayButton = true;
|
||||
private boolean showBadge = false;
|
||||
private boolean useCustomScroll = false;
|
||||
|
||||
private boolean allowOverflowX = true;
|
||||
private boolean allowOverflowY = false;
|
||||
|
||||
private ItemStack itemStack = null;
|
||||
private DrawableResource image = null;
|
||||
@@ -151,12 +153,26 @@ public class HandlerInfo {
|
||||
this.showBadge = showBadge;
|
||||
}
|
||||
|
||||
public boolean getUseCustomScroll() {
|
||||
return this.useCustomScroll;
|
||||
@Deprecated
|
||||
public void setUseCustomScroll(boolean useCustomScroll) {
|
||||
this.allowOverflowX = useCustomScroll;
|
||||
this.allowOverflowY = useCustomScroll;
|
||||
}
|
||||
|
||||
public void setUseCustomScroll(boolean useCustomScroll) {
|
||||
this.useCustomScroll = useCustomScroll;
|
||||
public boolean isAllowOverflowX() {
|
||||
return this.allowOverflowX;
|
||||
}
|
||||
|
||||
public void setAllowOverflowX(boolean allowOverflowX) {
|
||||
this.allowOverflowX = allowOverflowX;
|
||||
}
|
||||
|
||||
public boolean isAllowOverflowY() {
|
||||
return this.allowOverflowY;
|
||||
}
|
||||
|
||||
public void setAllowOverflowY(boolean allowOverflowY) {
|
||||
this.allowOverflowY = allowOverflowY;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@@ -195,6 +211,7 @@ public class HandlerInfo {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Builder setUseCustomScroll(boolean useCustomScroll) {
|
||||
this.info.setUseCustomScroll(useCustomScroll);
|
||||
return this;
|
||||
@@ -241,6 +258,16 @@ public class HandlerInfo {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAllowOverflowX(boolean allowOverflowX) {
|
||||
this.info.allowOverflowX = allowOverflowX;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAllowOverflowY(boolean allowOverflowY) {
|
||||
this.info.allowOverflowY = allowOverflowY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HandlerInfo build() {
|
||||
return this.info;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class NEIRecipeWidget extends Widget {
|
||||
|
||||
public void update() {
|
||||
|
||||
if (this.showAsWidget || !this.handlerInfo.getUseCustomScroll()) {
|
||||
if (this.showAsWidget || !this.handlerInfo.isAllowOverflowY()) {
|
||||
final int recipeHeight = this.handlerRef.handler.getRecipeHeight(this.handlerRef.recipeIndex);
|
||||
this.w = Math.max(166, this.handlerInfo.getWidth());
|
||||
this.h = recipeHeight > 0 ? recipeHeight : this.handlerInfo.getHeight();
|
||||
@@ -145,7 +145,7 @@ public class NEIRecipeWidget extends Widget {
|
||||
final List<GuiRecipeButton> buttons = new ArrayList<>();
|
||||
final boolean showFavorites = NEIClientConfig.favoritesEnabled() && handlerInfo.getShowFavoritesButton();
|
||||
final boolean showOverlay = handlerInfo.getShowOverlayButton();
|
||||
final int x = Math.min(168, this.w) - GuiRecipeButton.BUTTON_WIDTH;
|
||||
final int x = Math.min(166, this.w) - GuiRecipeButton.BUTTON_WIDTH;
|
||||
int y = this.h - GuiRecipeButton.BUTTON_HEIGHT - 6;
|
||||
|
||||
if (guiContainer instanceof IGuiContainerOverlay overlay) {
|
||||
|
||||
@@ -42,10 +42,10 @@ public class RecipePageManager {
|
||||
this.cacheKey = cacheKey;
|
||||
this.pageWidgets.clear();
|
||||
|
||||
final boolean useCustomScroll = this.handlerInfo.getUseCustomScroll();
|
||||
final boolean allowOverflowY = this.handlerInfo.isAllowOverflowY();
|
||||
final int handlerHeight = this.handlerInfo.getHeight() + this.handlerInfo.getYShift();
|
||||
final boolean multipleWidgetsAllowed = !useCustomScroll && handlerInfo.isMultipleWidgetsAllowed();
|
||||
final boolean infiniteScroll = !useCustomScroll
|
||||
final boolean multipleWidgetsAllowed = !allowOverflowY && handlerInfo.isMultipleWidgetsAllowed();
|
||||
final boolean infiniteScroll = !allowOverflowY
|
||||
&& NEIClientConfig.getBooleanSetting("inventory.guirecipe.infiniteScroll");
|
||||
|
||||
final int heightAvailable = this.container.getVisibleHeight();
|
||||
@@ -59,7 +59,7 @@ public class RecipePageManager {
|
||||
final NEIRecipeWidget widget = RecipeHandlerRef.of(this.handler.original, recipeIndex).getRecipeWidget();
|
||||
widget.w = width;
|
||||
|
||||
if (useCustomScroll) {
|
||||
if (allowOverflowY) {
|
||||
widget.h = Math.min(handlerHeight, heightAvailable);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class RecipePageManager {
|
||||
}
|
||||
|
||||
public boolean isMultipleWidgetsAllowed() {
|
||||
return !this.handlerInfo.getUseCustomScroll() && this.handlerInfo.isMultipleWidgetsAllowed();
|
||||
return !this.handlerInfo.isAllowOverflowY() && this.handlerInfo.isMultipleWidgetsAllowed();
|
||||
}
|
||||
|
||||
public int getNumRecipes() {
|
||||
|
||||
@@ -84,12 +84,13 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
|
||||
efuels.add(Item.getItemFromBlock(Blocks.wooden_door));
|
||||
efuels.add(Item.getItemFromBlock(Blocks.trapped_chest));
|
||||
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
final Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
final List<ItemStack> itemsSnapshot = new ArrayList<>(ItemList.items);
|
||||
if (parallel) {
|
||||
try {
|
||||
FurnaceRecipeHandler.afuels = ItemList.forkJoinPool
|
||||
.submit(
|
||||
() -> ItemList.items.parallelStream().map(TemplateRecipeHandler::identifyFuel)
|
||||
() -> itemsSnapshot.parallelStream().map(TemplateRecipeHandler::identifyFuel)
|
||||
.filter(Objects::nonNull).collect(Collectors.toCollection(ArrayList::new)))
|
||||
.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
@@ -97,7 +98,7 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
FurnaceRecipeHandler.afuels = ItemList.items.stream().map(TemplateRecipeHandler::identifyFuel)
|
||||
FurnaceRecipeHandler.afuels = itemsSnapshot.stream().map(TemplateRecipeHandler::identifyFuel)
|
||||
.filter(Objects::nonNull).collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntPredicate;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -53,7 +53,8 @@ public class DebugHandlerWidget extends Widget {
|
||||
public int height;
|
||||
public boolean multiWidgets;
|
||||
public int order;
|
||||
public boolean useCustomScroll;
|
||||
public boolean allowOverflowX;
|
||||
public boolean allowOverflowY;
|
||||
public boolean showFavorites;
|
||||
public boolean showOverlay;
|
||||
public boolean showBadge;
|
||||
@@ -68,7 +69,8 @@ public class DebugHandlerWidget extends Widget {
|
||||
this.height = info.getHeight();
|
||||
this.multiWidgets = info.isMultipleWidgetsAllowed();
|
||||
this.order = NEIClientConfig.handlerOrdering.getOrDefault(handlerKey, 0);
|
||||
this.useCustomScroll = info.getUseCustomScroll();
|
||||
this.allowOverflowX = info.isAllowOverflowX();
|
||||
this.allowOverflowY = info.isAllowOverflowY();
|
||||
this.showFavorites = info.getShowFavoritesButton();
|
||||
this.showOverlay = info.getShowOverlayButton();
|
||||
this.showBadge = info.getShowBadge();
|
||||
@@ -79,7 +81,8 @@ public class DebugHandlerWidget extends Widget {
|
||||
this.info.setYShift(this.yShift);
|
||||
this.info.setHandlerDimensions(this.width, this.height);
|
||||
this.info.setMultipleWidgetsAllowed(this.multiWidgets);
|
||||
this.info.setUseCustomScroll(this.useCustomScroll);
|
||||
this.info.setAllowOverflowX(this.allowOverflowX);
|
||||
this.info.setAllowOverflowY(this.allowOverflowY);
|
||||
this.info.setShowFavoritesButton(this.showFavorites);
|
||||
this.info.setShowOverlayButton(this.showOverlay);
|
||||
this.info.setShowBadge(this.showBadge);
|
||||
@@ -94,10 +97,11 @@ public class DebugHandlerWidget extends Widget {
|
||||
this.width = intOrDefault(parts[3], this.width);
|
||||
this.multiWidgets = intOrDefault(parts[4], this.multiWidgets ? 1 : 0) == 1;
|
||||
this.order = intOrDefault(parts[5], this.order);
|
||||
this.useCustomScroll = intOrDefault(parts[6], this.useCustomScroll ? 1 : 0) == 1;
|
||||
this.showFavorites = intOrDefault(parts[7], this.showFavorites ? 1 : 0) == 1;
|
||||
this.showOverlay = intOrDefault(parts[8], this.showOverlay ? 1 : 0) == 1;
|
||||
this.showBadge = intOrDefault(parts[9], this.showBadge ? 1 : 0) == 1;
|
||||
this.allowOverflowX = intOrDefault(parts[6], this.allowOverflowX ? 1 : 0) == 1;
|
||||
this.allowOverflowY = intOrDefault(parts[7], this.allowOverflowY ? 1 : 0) == 1;
|
||||
this.showFavorites = intOrDefault(parts[8], this.showFavorites ? 1 : 0) == 1;
|
||||
this.showOverlay = intOrDefault(parts[9], this.showOverlay ? 1 : 0) == 1;
|
||||
this.showBadge = intOrDefault(parts[10], this.showBadge ? 1 : 0) == 1;
|
||||
|
||||
apply();
|
||||
}
|
||||
@@ -111,7 +115,8 @@ public class DebugHandlerWidget extends Widget {
|
||||
String.valueOf(this.width),
|
||||
String.valueOf(this.multiWidgets ? 1 : 0),
|
||||
String.valueOf(this.order),
|
||||
String.valueOf(this.useCustomScroll ? 1 : 0),
|
||||
String.valueOf(this.allowOverflowX ? 1 : 0),
|
||||
String.valueOf(this.allowOverflowY ? 1 : 0),
|
||||
String.valueOf(this.showFavorites ? 1 : 0),
|
||||
String.valueOf(this.showOverlay ? 1 : 0),
|
||||
String.valueOf(this.showBadge ? 1 : 0));
|
||||
@@ -137,7 +142,7 @@ public class DebugHandlerWidget extends Widget {
|
||||
private static final int LABEL_WIDTH = 50;
|
||||
|
||||
private static final String TOOLTIP_PREFIX = "debug.RecipeHandler.";
|
||||
private static final String HEADER = "HandlerId,YShift,Height,Width,MultiWidgets,Order,UseCustomScroll,ShowFavorites,ShowOverlay,ShowBadge";
|
||||
private static final String HEADER = "HandlerId,YShift,Height,Width,MultiWidgets,Order,AllowOverflowX,AllowOverflowY,ShowFavorites,ShowOverlay,ShowBadge";
|
||||
private final int[] COLORS = new int[] { 0x2200FF00, 0x22FF0000, 0x220000FF, 0x2200FFFF, 0x22FF00FF, 0x22FFFF00 };
|
||||
|
||||
public static DebugHandlerWidget instance = new DebugHandlerWidget();
|
||||
@@ -183,12 +188,12 @@ public class DebugHandlerWidget extends Widget {
|
||||
y = addTextFieldWidget("Order", 0, (field, oldText) -> {
|
||||
record.order = field.getInteger();
|
||||
saveHandlerInfoPatch();
|
||||
}, y);
|
||||
}, null, y);
|
||||
|
||||
y = addTextFieldWidget("yShift", 0, (field, oldText) -> {
|
||||
record.yShift = field.getInteger();
|
||||
saveHandlerInfoPatch();
|
||||
}, y);
|
||||
}, null, y);
|
||||
|
||||
y = addCheckboxWidget("MultiWidgets", button -> {
|
||||
record.multiWidgets = button.value;
|
||||
@@ -205,15 +210,20 @@ public class DebugHandlerWidget extends Widget {
|
||||
y = addTextFieldWidget("Height", HandlerInfo.DEFAULT_HEIGHT, (field, oldText) -> {
|
||||
record.height = field.getInteger();
|
||||
saveHandlerInfoPatch();
|
||||
}, y);
|
||||
}, newValue -> newValue > 0, y);
|
||||
|
||||
y = addTextFieldWidget("Width", HandlerInfo.DEFAULT_WIDTH, (field, oldText) -> {
|
||||
record.width = field.getInteger();
|
||||
saveHandlerInfoPatch();
|
||||
}, newValue -> newValue >= HandlerInfo.DEFAULT_WIDTH, y);
|
||||
|
||||
y = addCheckboxWidget("AllowOverflowX", button -> {
|
||||
record.allowOverflowX = button.value;
|
||||
saveHandlerInfoPatch();
|
||||
}, y);
|
||||
|
||||
y = addCheckboxWidget("UseCustomScroll", button -> {
|
||||
record.useCustomScroll = button.value;
|
||||
y = addCheckboxWidget("AllowOverflowY", button -> {
|
||||
record.allowOverflowY = button.value;
|
||||
saveHandlerInfoPatch();
|
||||
}, y);
|
||||
|
||||
@@ -254,9 +264,10 @@ public class DebugHandlerWidget extends Widget {
|
||||
return y + value.h + 1;
|
||||
}
|
||||
|
||||
private int addTextFieldWidget(String key, int defaultValue, BiConsumer<IntegerField, String> onChange, int y) {
|
||||
private int addTextFieldWidget(String key, int defaultValue, BiConsumer<IntegerField, String> onChange,
|
||||
IntPredicate validator, int y) {
|
||||
final LabelWidget label = new LabelWidget(0x888888, false);
|
||||
final IntegerField value = new IntegerField(key, onChange, defaultValue);
|
||||
final IntegerField value = new IntegerField(key, onChange, validator, defaultValue);
|
||||
|
||||
label.y = value.y = y;
|
||||
value.w = 60;
|
||||
@@ -397,7 +408,8 @@ public class DebugHandlerWidget extends Widget {
|
||||
this.values.get("width").updateValue(String.valueOf(this.record.width));
|
||||
|
||||
this.values.get("multiwidgets").updateValue(String.valueOf(this.record.multiWidgets));
|
||||
this.values.get("usecustomscroll").updateValue(String.valueOf(this.record.useCustomScroll));
|
||||
this.values.get("allowoverflowx").updateValue(String.valueOf(this.record.allowOverflowX));
|
||||
this.values.get("allowoverflowy").updateValue(String.valueOf(this.record.allowOverflowY));
|
||||
|
||||
this.values.get("showfavorites").updateValue(String.valueOf(this.record.showFavorites));
|
||||
this.values.get("showoverlay").updateValue(String.valueOf(this.record.showOverlay));
|
||||
@@ -589,17 +601,23 @@ public class DebugHandlerWidget extends Widget {
|
||||
public void loadHandlerInfoPatch() {
|
||||
|
||||
ClientHandler.loadSettingsFile("handlers.patch", lines -> {
|
||||
final List<String> linesList = lines.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
for (String line : lines.collect(Collectors.toCollection(HashSet::new))) {
|
||||
if (HEADER.equals(line)) continue;
|
||||
final String[] parts = (line).split(",");
|
||||
if (linesList.isEmpty() || !HEADER.equals(linesList.get(0))) {
|
||||
return;
|
||||
}
|
||||
|
||||
linesList.remove(0);
|
||||
|
||||
for (String line : linesList) {
|
||||
final String[] parts = line.split(",");
|
||||
final String handlerKey = parts[0];
|
||||
|
||||
if (GuiRecipeTab.handlerMap.containsKey(handlerKey)) {
|
||||
final HandlerInfoRecord record = patches.computeIfAbsent(
|
||||
handlerKey,
|
||||
key -> new HandlerInfoRecord(key, GuiRecipeTab.handlerMap.get(key)));
|
||||
record.apply((line + ",null,null,null,null,null,null,null,null,null"));
|
||||
record.apply((line + ",null,null,null,null,null,null,null,null,null,null"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei.recipe.debug;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.IntPredicate;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -13,10 +14,13 @@ public class IntegerField extends TextField implements IUpdatableWidget {
|
||||
|
||||
protected int defaultValue = 0;
|
||||
protected BiConsumer<IntegerField, String> onChange;
|
||||
protected IntPredicate validator;
|
||||
|
||||
public IntegerField(String ident, BiConsumer<IntegerField, String> onChange, int defaultValue) {
|
||||
public IntegerField(String ident, BiConsumer<IntegerField, String> onChange, IntPredicate validator,
|
||||
int defaultValue) {
|
||||
super(ident);
|
||||
this.onChange = onChange;
|
||||
this.validator = validator;
|
||||
this.defaultValue = defaultValue;
|
||||
this.h = 16;
|
||||
this.z = 2;
|
||||
@@ -68,8 +72,12 @@ public class IntegerField extends TextField implements IUpdatableWidget {
|
||||
}
|
||||
|
||||
protected int getInteger() {
|
||||
return getInteger(text());
|
||||
}
|
||||
|
||||
protected int getInteger(String text) {
|
||||
try {
|
||||
return Integer.parseInt(text());
|
||||
return Integer.parseInt(text);
|
||||
} catch (NumberFormatException nfe) {
|
||||
return this.defaultValue;
|
||||
}
|
||||
@@ -78,10 +86,17 @@ public class IntegerField extends TextField implements IUpdatableWidget {
|
||||
@Override
|
||||
public boolean onMouseWheel(int i, int mx, int my) {
|
||||
if (!contains(mx, my)) return false;
|
||||
setText(Integer.toString(getInteger() + i));
|
||||
setText(Integer.toString(getInteger() - i));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String newValue) {
|
||||
if (validator == null || validator.test(getInteger(newValue))) {
|
||||
super.setText(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateValue(String newValue) {
|
||||
setText(newValue);
|
||||
}
|
||||
|
||||
@@ -301,6 +301,11 @@ nei.options.inventory.guirecipe.handlerInfo=Handler Info Widget
|
||||
nei.options.inventory.guirecipe.handlerInfo.tip=Use shift+d while in the Recipes GUI
|
||||
nei.options.inventory.guirecipe.handlerInfo.true=Enabled
|
||||
nei.options.inventory.guirecipe.handlerInfo.false=Disabled
|
||||
|
||||
nei.options.inventory.guirecipe.scrollPages=Scroll Pages
|
||||
nei.options.inventory.guirecipe.scrollPages.true=Enabled
|
||||
nei.options.inventory.guirecipe.scrollPages.false=Disabled
|
||||
|
||||
nei.options.inventory.guirecipe.maxHeight=Max Height
|
||||
nei.options.inventory.showItemQuantityWidget=Show Item Quantity Widget
|
||||
nei.options.inventory.showItemQuantityWidget.true=Yes
|
||||
@@ -542,7 +547,8 @@ nei.debug.RecipeHandler.Width=Width
|
||||
nei.debug.RecipeHandler.ShowFavorites=Show Favorites
|
||||
nei.debug.RecipeHandler.ShowOverlay=Show Overlays
|
||||
nei.debug.RecipeHandler.ShowBadge=Show Badge
|
||||
nei.debug.RecipeHandler.UseCustomScroll=Use Custom Scroll
|
||||
nei.debug.RecipeHandler.AllowOverflowY=Allow Overflow Y
|
||||
nei.debug.RecipeHandler.AllowOverflowX=Allow Overflow X
|
||||
nei.debug.RecipeHandler.Override=Override
|
||||
nei.debug.RecipeHandler.checkbox.on=On
|
||||
nei.debug.RecipeHandler.checkbox.off=Off
|
||||
|
||||
Reference in new issue
Block a user