mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-28 07:55:59 +00:00
Cleaned and generalised item loading/searching
Reimplemented subsets Added regex searching Fixed format error on delete all Fixed GuiButton handling clicks before NEI widgets could override Re-Implemented banned blocks implementation Added brewing recipes again note test obf ASM beacons Fixed some calls being intercepted by item panel when mouse was over a gui element Fixed crash on closing potion window with escape Disabled fast transfer, scrolling, and drag 'n' drop in creative Added item panel sorting Removed TMI uninstaller Fixed /give command Updated to 1.7.10
This commit is contained in:
1 parent
3c9ebc6961
commit
3c84527806
67 files changed
+3251
-2319
No files matched your search
@@ -6,11 +6,7 @@ import codechicken.core.gui.GuiScrollSlot;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -27,73 +23,55 @@ public class GuiOptionList extends GuiScreenWidget
|
||||
public class OptionScrollSlot extends GuiScrollSlot
|
||||
{
|
||||
public ArrayList<Option> options = new ArrayList<Option>();
|
||||
|
||||
public OptionScrollSlot()
|
||||
{
|
||||
|
||||
public OptionScrollSlot() {
|
||||
super(0, 0, 0, 0);
|
||||
setMargins(0, 4, 20, 4);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAdded(GuiScreen s)
|
||||
{
|
||||
public void onAdded(GuiScreen s) {
|
||||
super.onAdded(s);
|
||||
for(Option o : optionList.optionList)
|
||||
for (Option o : optionList.optionList)
|
||||
options.add(o);
|
||||
for(Option o : options)
|
||||
for (Option o : options)
|
||||
o.onAdded(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotHeight()
|
||||
{
|
||||
return 24;
|
||||
public int getSlotHeight(int slot) {
|
||||
return options.get(slot).getHeight()+4;
|
||||
}
|
||||
|
||||
public int contentWidth()
|
||||
{
|
||||
return width-20;
|
||||
|
||||
public int slotWidth() {
|
||||
return windowBounds().width-24;
|
||||
}
|
||||
|
||||
private Rectangle slotBounds(int slot) {
|
||||
return new Rectangle(24, 2, slotWidth(), getSlotHeight(slot)-4);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumSlots()
|
||||
{
|
||||
protected int getNumSlots() {
|
||||
return options.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectNext()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPrev()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSlotSelected(int slot)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawSlot(int slot, int x, int y, int mousex, int mousey, boolean selected, float frame)
|
||||
{
|
||||
GL11.glTranslatef(x, y, 0);
|
||||
protected void drawSlot(int slot, int x, int y, int mx, int my, float frame) {
|
||||
Option o = options.get(slot);
|
||||
if(o.showWorldSelector() && world)
|
||||
drawWorldSelector(o, mousex, mousey);
|
||||
o.draw(mousex, mousey, frame);
|
||||
GL11.glTranslatef(-x, -y, 0);
|
||||
GL11.glTranslatef(x, y, 0);
|
||||
if (o.showWorldSelector() && world)
|
||||
drawWorldSelector(o, mx, my);
|
||||
GL11.glTranslatef(24, 2, 0);
|
||||
o.draw(mx-24, my-2, frame);
|
||||
GL11.glTranslatef(-x-24, -y-2, 0);
|
||||
}
|
||||
|
||||
public Rectangle4i worldButtonSize()
|
||||
{
|
||||
return new Rectangle4i(-24, 2, 20, 20);
|
||||
|
||||
public Rectangle4i worldButtonSize() {
|
||||
return new Rectangle4i(0, 2, 20, 20);
|
||||
}
|
||||
|
||||
private void drawWorldSelector(Option o, int mousex, int mousey)
|
||||
{
|
||||
|
||||
private void drawWorldSelector(Option o, int mousex, int mousey) {
|
||||
Rectangle4i b = worldButtonSize();
|
||||
boolean set = o.hasWorldOverride();
|
||||
boolean mouseover = b.contains(mousex, mousey);
|
||||
@@ -103,276 +81,193 @@ public class GuiOptionList extends GuiScreenWidget
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOverlay(float frame)
|
||||
{
|
||||
drawOverlayTex(0, 0, parentScreen.width, y);
|
||||
drawOverlayTex(0, y+height, parentScreen.width, parentScreen.height-y-height);
|
||||
drawOverlayGrad(0, parentScreen.width, y, y+4);
|
||||
drawOverlayGrad(0, parentScreen.width, y+height, y+height-4);
|
||||
public void drawBackground(float frame) {
|
||||
Rectangle sbar = scrollbarBounds();
|
||||
drawRect(sbar.x, y, sbar.x + sbar.width, y + height, 0xFF000000);
|
||||
}
|
||||
|
||||
public void drawOverlayTex(int x, int y, int w, int h)
|
||||
{
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
renderEngine.bindTexture(Gui.optionsBackground);
|
||||
Tessellator t = Tessellator.instance;
|
||||
t.startDrawingQuads();
|
||||
t.addVertexWithUV(x, y, zLevel, 0, 0);
|
||||
t.addVertexWithUV(x, y+h, zLevel, 0, h/16D);
|
||||
t.addVertexWithUV(x+w, y+h, zLevel, w/16D, h/16D);
|
||||
t.addVertexWithUV(x+w, y, zLevel, w/16D, 0);
|
||||
t.draw();
|
||||
}
|
||||
|
||||
public void drawOverlayGrad(int x1, int x2, int y1, int y2)
|
||||
{
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator t = Tessellator.instance;
|
||||
t.startDrawingQuads();
|
||||
t.setColorRGBA_I(0, 255);
|
||||
t.addVertex(x2, y1, zLevel);
|
||||
t.addVertex(x1, y1, zLevel);
|
||||
t.setColorRGBA_I(0, 0);
|
||||
t.addVertex(x1, y2, zLevel);
|
||||
t.addVertex(x2, y2, zLevel);
|
||||
t.draw();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawSlotBox(float frame)
|
||||
{
|
||||
public void drawOverlay(float frame) {
|
||||
OptionScrollPane.drawOverlay(y, height, parentScreen.width, zLevel);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean drawLineGuide()
|
||||
{
|
||||
return false;
|
||||
public int scrollbarGuideAlignment() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getScrollBarWidth()
|
||||
{
|
||||
return 6;
|
||||
public Dimension scrollbarDim() {
|
||||
Dimension dim = super.scrollbarDim();
|
||||
dim.width = 6;
|
||||
return dim;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawScrollBar(float frame)
|
||||
{
|
||||
int sbarw = getScrollBarWidth();
|
||||
int sbarx = x + width - sbarw;
|
||||
drawRect(sbarx, y, sbarx+sbarw, y+height, 0xFF000000);
|
||||
|
||||
super.drawScrollBar(frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
public void update() {
|
||||
super.update();
|
||||
for(Option o : options)
|
||||
for (Option o : options)
|
||||
o.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void slotClicked(int slot, int button, int mousex, int mousey, boolean doubleclick)
|
||||
{
|
||||
options.get(slot).mouseClicked(mousex, mousey, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mousex, int mousey, int button)
|
||||
{
|
||||
for(Option o : options)
|
||||
o.onMouseClicked(mousex, mousey, button);
|
||||
|
||||
super.mouseClicked(mousex, mousey, button);
|
||||
|
||||
int slot = getClickedSlot(mousey);
|
||||
if(slot >= 0)
|
||||
{
|
||||
Option o = options.get(slot);
|
||||
if(world && o.showWorldSelector() && worldButtonSize().contains(mousex-contentx, mousey-getSlotY(slot)))
|
||||
{
|
||||
if(button == 1 && o.hasWorldOverride())
|
||||
{
|
||||
o.useGlobals();
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
else if(button == 0 && !o.hasWorldOverride())
|
||||
{
|
||||
o.copyGlobals();
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
protected void slotClicked(int slot, int button, int mx, int my, int count) {
|
||||
Option o = options.get(slot);
|
||||
if (world && o.showWorldSelector() && worldButtonSize().contains(mx, my)) {
|
||||
if (button == 1 && o.hasWorldOverride()) {
|
||||
o.useGlobals();
|
||||
Option.playClickSound();
|
||||
} else if (button == 0 && !o.hasWorldOverride()) {
|
||||
o.copyGlobals();
|
||||
Option.playClickSound();
|
||||
}
|
||||
}
|
||||
else if(slotBounds(slot).contains(mx, my))
|
||||
options.get(slot).mouseClicked(mx-24, my-2, button);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int keycode)
|
||||
{
|
||||
public void mouseClicked(int mx, int my, int button) {
|
||||
for (Option o : options)
|
||||
o.onMouseClicked(mx, my, button);
|
||||
|
||||
super.mouseClicked(mx, my, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int keycode) {
|
||||
super.keyTyped(c, keycode);
|
||||
for(Option o : options)
|
||||
for (Option o : options)
|
||||
o.keyTyped(c, keycode);
|
||||
}
|
||||
|
||||
public void resize()
|
||||
{
|
||||
int width = Math.min(parentScreen.width-80, 320);
|
||||
setSize((parentScreen.width-width)/2, 20, width, parentScreen.height-50);
|
||||
setContentSize(x, y+4, height-8);
|
||||
public void resize() {
|
||||
int width = Math.min(parentScreen.width - 80, 320);
|
||||
setSize((parentScreen.width - width) / 2, 20, width, parentScreen.height - 50);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseScrolled(int x, int y, int scroll)
|
||||
{
|
||||
public void mouseScrolled(int x, int y, int scroll) {
|
||||
scroll(-scroll);
|
||||
}
|
||||
|
||||
public GuiOptionList getGui()
|
||||
{
|
||||
return ((GuiOptionList)parentScreen);
|
||||
public GuiOptionList getGui() {
|
||||
return ((GuiOptionList) parentScreen);
|
||||
}
|
||||
|
||||
public List<String> handleTooltip(int mousex, int mousey, List<String> tooltip)
|
||||
{
|
||||
for(int slot = 0; slot < getNumSlots(); slot++)
|
||||
{
|
||||
int sloty = getSlotY(slot);
|
||||
if(sloty > contenty - getSlotHeight() && sloty < contenty + contentheight)
|
||||
tooltip = handleTooltip(slot, mousex-contentx, mousey-sloty, tooltip);
|
||||
}
|
||||
public List<String> handleTooltip(int mx, int my, List<String> tooltip) {
|
||||
int sy = my-y+scrolledPixels();
|
||||
int slot = getSlot(sy);
|
||||
if(slot >= 0)
|
||||
tooltip = handleTooltip(slot, mx - x, sy-getSlotY(slot), tooltip);
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
private List<String> handleTooltip(int slot, int mousex, int mousey, List<String> tooltip)
|
||||
{
|
||||
private List<String> handleTooltip(int slot, int mx, int my, List<String> tooltip) {
|
||||
Option o = options.get(slot);
|
||||
if(world && o.showWorldSelector() && worldButtonSize().contains(mousex, mousey))
|
||||
tooltip.add(translateToLocal("nei.options.wbutton.tip."+(o.hasWorldOverride() ? "1" : "0")));
|
||||
|
||||
return o.handleTooltip(mousex, mousey, tooltip);
|
||||
if (world && o.showWorldSelector() && worldButtonSize().contains(mx, my))
|
||||
tooltip.add(translateToLocal("nei.options.wbutton.tip." + (o.hasWorldOverride() ? "1" : "0")));
|
||||
if(slotBounds(slot).contains(mx, my))
|
||||
return o.handleTooltip(mx-24, my-2, tooltip);
|
||||
return tooltip;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final GuiScreen parent;
|
||||
private final OptionList optionList;
|
||||
private boolean world;
|
||||
|
||||
|
||||
private OptionScrollSlot slot;
|
||||
private GuiCCButton backButton;
|
||||
private GuiCCButton worldButton;
|
||||
|
||||
public GuiOptionList(GuiScreen parent, OptionList optionList, boolean world)
|
||||
{
|
||||
|
||||
public GuiOptionList(GuiScreen parent, OptionList optionList, boolean world) {
|
||||
this.parent = parent;
|
||||
this.optionList = optionList;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
public void initGui() {
|
||||
xSize = width;
|
||||
ySize = height;
|
||||
super.initGui();
|
||||
|
||||
if(slot != null)
|
||||
{
|
||||
|
||||
if (slot != null) {
|
||||
slot.resize();
|
||||
backButton.width = Math.min(200, width-40);
|
||||
backButton.x = (width-backButton.width)/2;
|
||||
backButton.y = height-25;
|
||||
backButton.width = Math.min(200, width - 40);
|
||||
backButton.x = (width - backButton.width) / 2;
|
||||
backButton.y = height - 25;
|
||||
worldButton.width = 60;
|
||||
worldButton.x = width-worldButton.width-15;
|
||||
worldButton.x = width - worldButton.width - 15;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addWidgets()
|
||||
{
|
||||
public void addWidgets() {
|
||||
add(slot = new OptionScrollSlot());
|
||||
add(backButton = new GuiCCButton(0, 0, 0, 20, translateToLocal("nei.options.back")).setActionCommand("back"));
|
||||
add(worldButton = new GuiCCButton(0, 2, 0, 16, worldButtonName()).setActionCommand("world"));
|
||||
initGui();
|
||||
}
|
||||
|
||||
private String worldButtonName()
|
||||
{
|
||||
|
||||
private String worldButtonName() {
|
||||
return translateToLocal("nei.options." + (world ? "world" : "global"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(String ident, Object... params)
|
||||
{
|
||||
if(ident.equals("back"))
|
||||
{
|
||||
if(parent instanceof GuiOptionList)
|
||||
((GuiOptionList)parent).world = world;
|
||||
public void actionPerformed(String ident, Object... params) {
|
||||
if (ident.equals("back")) {
|
||||
if (parent instanceof GuiOptionList)
|
||||
((GuiOptionList) parent).world = world;
|
||||
Minecraft.getMinecraft().displayGuiScreen(parent);
|
||||
}
|
||||
else if(ident.equals("world"))
|
||||
{
|
||||
} else if (ident.equals("world")) {
|
||||
world = !world;
|
||||
worldButton.text = worldButtonName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawBackground()
|
||||
{
|
||||
public void drawBackground() {
|
||||
drawDefaultBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground()
|
||||
{
|
||||
drawCenteredString(fontRenderer, translateToLocal(optionList.fullName()), width/2, 6, -1);
|
||||
drawTooltip();
|
||||
}
|
||||
|
||||
private void drawTooltip()
|
||||
{
|
||||
List<String> tooltip = new LinkedList<String>();
|
||||
Point mouse = getMousePosition();
|
||||
if(worldButton.pointInside(mouse.x, mouse.y))
|
||||
tooltip.addAll(Arrays.asList(translateToLocal("nei.options.global.tip." + (world ? "1" : "0")).split(":")));
|
||||
|
||||
tooltip = slot.handleTooltip(mouse.x, mouse.y, tooltip);
|
||||
drawMultilineTip(mouse.x+12, mouse.y-12, tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame()
|
||||
{
|
||||
public void drawForeground() {
|
||||
drawCenteredString(fontRenderer, translateToLocal(optionList.fullName()), width / 2, 6, -1);
|
||||
drawTooltip();
|
||||
}
|
||||
|
||||
private void drawTooltip() {
|
||||
List<String> tooltip = new LinkedList<String>();
|
||||
Point mouse = getMousePosition();
|
||||
if (worldButton.pointInside(mouse.x, mouse.y))
|
||||
tooltip.addAll(Arrays.asList(translateToLocal("nei.options.global.tip." + (world ? "1" : "0")).split(":")));
|
||||
|
||||
tooltip = slot.handleTooltip(mouse.x, mouse.y, tooltip);
|
||||
drawMultilineTip(mouse.x + 12, mouse.y - 12, tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int keycode)
|
||||
{
|
||||
public void keyTyped(char c, int keycode) {
|
||||
if (keycode == 1)//esc
|
||||
{
|
||||
GuiScreen p = parent;
|
||||
while(p instanceof GuiOptionList)
|
||||
p = ((GuiOptionList)p).parent;
|
||||
while (p instanceof GuiOptionList)
|
||||
p = ((GuiOptionList) p).parent;
|
||||
|
||||
Minecraft.getMinecraft().displayGuiScreen(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
super.keyTyped(c, keycode);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean worldConfig()
|
||||
{
|
||||
public boolean worldConfig() {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user