mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-21 20:52:11 +00:00
Initial Commit
This commit is contained in:
commit
bd9d0a4eff
149 files changed
+18486
No files matched your search
@@ -0,0 +1,56 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public class ItemQuantityField extends TextField
|
||||
{
|
||||
public ItemQuantityField(String ident)
|
||||
{
|
||||
super(ident);
|
||||
centered = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user