mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 02:04:59 +00:00
* Licensed under LGPL * Remove TMI style * Remove Load/Save inventory state * Reworked ItemPanel so it's no longer used statically * BookmarkPanel inherits from ItemPanel * Rework LayoutManager * Bookmarks - including loading & saving * Utility/Cheat buttons line up and wrap based on GUI size
45 lines
1.0 KiB
Java
45 lines
1.0 KiB
Java
package codechicken.nei;
|
|
|
|
public class ItemQuantityField extends TextField
|
|
{
|
|
public ItemQuantityField(String ident) {
|
|
super(ident);
|
|
centered = true;
|
|
}
|
|
|
|
// Find a way to work this this back in
|
|
public boolean isValid(String string) {
|
|
if (string.equals(""))
|
|
return true;
|
|
|
|
try {
|
|
return Integer.parseInt(string) >= 0;
|
|
} catch (NumberFormatException nfe) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public int intValue() {
|
|
return intValue(text());
|
|
}
|
|
|
|
public int intValue(String s) {
|
|
try {
|
|
return Integer.parseInt(s);
|
|
} catch (NumberFormatException nfe) {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void loseFocus() {
|
|
setText(Integer.toString(NEIClientConfig.getItemQuantity()));
|
|
}
|
|
|
|
@Override
|
|
public void onTextChange(String oldText) {
|
|
if (intValue(oldText) != intValue())//hacky recursion stopper
|
|
NEIClientUtils.setItemQuantity(intValue());
|
|
}
|
|
}
|