mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 19:15:13 +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
@@ -8,168 +8,129 @@ import static codechicken.lib.gui.GuiDraw.*;
|
||||
|
||||
public abstract class TextField extends Widget
|
||||
{
|
||||
public TextField(String ident)
|
||||
{
|
||||
public TextField(String ident) {
|
||||
identifier = ident;
|
||||
}
|
||||
|
||||
public int getTextColour()
|
||||
{
|
||||
|
||||
public int getTextColour() {
|
||||
return focused() ? 0xFFE0E0E0 : 0xFF909090;
|
||||
}
|
||||
|
||||
public void drawBox()
|
||||
{
|
||||
drawRect(x, y, width, height, 0xffA0A0A0);
|
||||
drawRect(x + 1, y + 1, width - 2, height - 2, 0xFF000000);
|
||||
|
||||
public void drawBox() {
|
||||
drawRect(x, y, w, h, 0xffA0A0A0);
|
||||
drawRect(x + 1, y + 1, w - 2, h - 2, 0xFF000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey)
|
||||
{
|
||||
public void draw(int mousex, int mousey) {
|
||||
drawBox();
|
||||
|
||||
|
||||
String drawtext = text;
|
||||
|
||||
if(text.length() > getMaxTextLength())
|
||||
{
|
||||
int startOffset = drawtext.length() - getMaxTextLength();
|
||||
if(startOffset < 0 || startOffset > drawtext.length())
|
||||
startOffset = 0;
|
||||
drawtext = drawtext.substring(startOffset);
|
||||
}
|
||||
|
||||
if(focused() && (cursorCounter / 6) % 2 == 0)
|
||||
|
||||
int textWidth;
|
||||
while((textWidth = getStringWidth(drawtext)) > w - 14)
|
||||
drawtext = drawtext.substring(1);
|
||||
|
||||
if (focused() && (cursorCounter / 6) % 2 == 0)
|
||||
drawtext = drawtext + '_';
|
||||
|
||||
int textWidth = getStringWidth(text);
|
||||
int textx = centered ? x+(width-textWidth)/2 : x + 4;
|
||||
int texty = y + (height + 1) / 2 - 3;
|
||||
|
||||
|
||||
int textx = centered ? x + (w - textWidth) / 2 : x + 4;
|
||||
int texty = y + (h + 1) / 2 - 3;
|
||||
|
||||
drawString(drawtext, textx, texty, getTextColour());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClick(int mousex, int mousey)
|
||||
{
|
||||
if(!contains(mousex, mousey))
|
||||
public void onGuiClick(int mousex, int mousey) {
|
||||
if (!contains(mousex, mousey))
|
||||
setFocus(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleClick(int mousex, int mousey, int button)
|
||||
{
|
||||
if(button == 1)
|
||||
public boolean handleClick(int mousex, int mousey, int button) {
|
||||
if (button == 1)
|
||||
setText("");
|
||||
setFocus(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyPress(int keyID, char keyChar)
|
||||
{
|
||||
if(!focused())
|
||||
public boolean handleKeyPress(int keyID, char keyChar) {
|
||||
if (!focused())
|
||||
return false;
|
||||
|
||||
if(keyID == Keyboard.KEY_BACK)
|
||||
{
|
||||
if(text.length() > 0)
|
||||
{
|
||||
|
||||
if (keyID == Keyboard.KEY_BACK) {
|
||||
if (text.length() > 0) {
|
||||
setText(text.substring(0, text.length() - 1));
|
||||
backdowntime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
else if(keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_ESCAPE)
|
||||
{
|
||||
} else if (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_ESCAPE) {
|
||||
setFocus(false);
|
||||
onExit();
|
||||
}
|
||||
else if(keyChar == 22)//paste
|
||||
} else if (keyChar == 22)//paste
|
||||
{
|
||||
String pastestring = GuiScreen.getClipboardString();
|
||||
if(pastestring == null)
|
||||
if (pastestring == null)
|
||||
pastestring = "";
|
||||
|
||||
if(isValid(text + pastestring))
|
||||
|
||||
if (isValid(text + pastestring))
|
||||
setText(text + pastestring);
|
||||
}
|
||||
else if(isValid(text+keyChar))
|
||||
setText(text+keyChar);
|
||||
|
||||
} else if (isValid(text + keyChar))
|
||||
setText(text + keyChar);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onExit()
|
||||
{
|
||||
|
||||
public void onExit() {
|
||||
}
|
||||
|
||||
public abstract void onTextChange(String oldText);
|
||||
|
||||
public boolean isValid(String string)
|
||||
{
|
||||
public boolean isValid(String string) {
|
||||
// Solve the problem that Minecraft can't post Chinese characters
|
||||
return ChatAllowedCharacters.isAllowedCharacter(string.charAt(string.length()-1));
|
||||
return ChatAllowedCharacters.isAllowedCharacter(string.charAt(string.length() - 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
public void update() {
|
||||
cursorCounter++;
|
||||
if(backdowntime > 0)
|
||||
{
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_BACK) && text.length() > 0)
|
||||
{
|
||||
if(System.currentTimeMillis() - backdowntime > 200 / (1+backs * 0.3F))
|
||||
{
|
||||
if (backdowntime > 0) {
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_BACK) && text.length() > 0) {
|
||||
if (System.currentTimeMillis() - backdowntime > 200 / (1 + backs * 0.3F)) {
|
||||
setText(text.substring(0, text.length() - 1));
|
||||
backdowntime = System.currentTimeMillis();
|
||||
backs++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
backdowntime = 0;
|
||||
backs = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(String s)
|
||||
{
|
||||
|
||||
public void setText(String s) {
|
||||
String oldText = text;
|
||||
text = filterText(s);
|
||||
onTextChange(oldText);
|
||||
}
|
||||
|
||||
public String filterText(String s)
|
||||
{
|
||||
|
||||
public String filterText(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
private int getMaxTextLength()
|
||||
{
|
||||
return width / 6 - 2;
|
||||
}
|
||||
|
||||
public void setFocus(boolean focus)
|
||||
{
|
||||
if(focus)
|
||||
{
|
||||
|
||||
public void setFocus(boolean focus) {
|
||||
if (focus) {
|
||||
LayoutManager.setInputFocused(this);
|
||||
}
|
||||
else if(focused())
|
||||
{
|
||||
} else if (focused()) {
|
||||
LayoutManager.setInputFocused(null);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean focused()
|
||||
{
|
||||
|
||||
public boolean focused() {
|
||||
return LayoutManager.getInputFocused() == this;
|
||||
}
|
||||
|
||||
public String text()
|
||||
{
|
||||
|
||||
public String text() {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user