mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 02:55:04 +00:00
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
121 lines
3.0 KiB
Java
121 lines
3.0 KiB
Java
package codechicken.nei;
|
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
|
import net.minecraft.util.ChatAllowedCharacters;
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
import static codechicken.lib.gui.GuiDraw.drawString;
|
|
import static codechicken.lib.gui.GuiDraw.getStringWidth;
|
|
import static codechicken.nei.NEIClientUtils.translate;
|
|
|
|
public abstract class SaveLoadButton extends Button
|
|
{
|
|
public SaveLoadButton(String s)
|
|
{
|
|
super(s);
|
|
}
|
|
|
|
@Override
|
|
public boolean handleClick(int mousex, int mousey, int button)
|
|
{
|
|
if(button == 1)
|
|
{
|
|
label = "";
|
|
onTextChange();
|
|
focused = true;
|
|
NEIClientUtils.playClickSound();
|
|
return true;
|
|
}
|
|
return super.handleClick(mousex, mousey, button);
|
|
}
|
|
|
|
public abstract void onTextChange();
|
|
|
|
@Override
|
|
public void onGuiClick(int i, int j)
|
|
{
|
|
if(!contains(i, j))
|
|
focused = false;
|
|
}
|
|
|
|
@Override
|
|
public boolean handleKeyPress(int keyID, char keyChar)
|
|
{
|
|
if(!focused)
|
|
return false;
|
|
|
|
if(keyID == Keyboard.KEY_BACK)
|
|
{
|
|
if(label.length() > 0)
|
|
{
|
|
label = label.substring(0, label.length() - 1);
|
|
onTextChange();
|
|
backdowntime = System.currentTimeMillis();
|
|
}
|
|
}
|
|
else if(keyID == Keyboard.KEY_RETURN)
|
|
{
|
|
focused = false;
|
|
}
|
|
else if(keyChar == 22)//paste
|
|
{
|
|
String pastestring = GuiScreen.getClipboardString();
|
|
if(pastestring == null)
|
|
pastestring = "";
|
|
|
|
label = label + pastestring;
|
|
onTextChange();
|
|
}
|
|
else if(ChatAllowedCharacters.isAllowedCharacter(keyChar))
|
|
{
|
|
label = label + keyChar;
|
|
onTextChange();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void update()
|
|
{
|
|
cursorCounter++;
|
|
if(backdowntime > 0)
|
|
{
|
|
if(Keyboard.isKeyDown(Keyboard.KEY_BACK) && label.length() > 5)
|
|
{
|
|
if(System.currentTimeMillis() - backdowntime > 200 / (1+backs * 0.3F))
|
|
{
|
|
label = label.substring(0, label.length() - 1);
|
|
onTextChange();
|
|
backdowntime = System.currentTimeMillis();
|
|
backs++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
backdowntime = 0;
|
|
backs = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void draw(int mousex, int mousey)
|
|
{
|
|
super.draw(mousex, mousey);
|
|
if(focused && (cursorCounter / 6) % 2 == 0)
|
|
drawString("_", x + (w + getStringWidth(getRenderLabel())) / 2, y + (h - 8) / 2, 0xFFFFFFFF);
|
|
}
|
|
|
|
@Override
|
|
public String getRenderLabel()
|
|
{
|
|
return translate(saved ? "load" : "save") + " " + label;
|
|
}
|
|
|
|
public boolean saved;
|
|
public long backdowntime;
|
|
public int backs;
|
|
public int cursorCounter;
|
|
public boolean focused;
|
|
}
|