mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-25 14:34:54 +00:00
Initial Commit
This commit is contained in:
commit
bd9d0a4eff
149 files changed
+18486
No files matched your search
@@ -0,0 +1,66 @@
|
||||
package codechicken.nei.config;
|
||||
|
||||
public class OptionCycled extends OptionButton
|
||||
{
|
||||
public final int count;
|
||||
public final boolean prefixed;
|
||||
|
||||
public OptionCycled(String name, int count, boolean prefixed)
|
||||
{
|
||||
super(name);
|
||||
this.count = count;
|
||||
this.prefixed = prefixed;
|
||||
}
|
||||
|
||||
public OptionCycled(String name, int count)
|
||||
{
|
||||
this(name, count, false);
|
||||
}
|
||||
|
||||
public int value()
|
||||
{
|
||||
return renderTag().getIntValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getButtonText()
|
||||
{
|
||||
return translateN(name+"."+value());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix()
|
||||
{
|
||||
return prefixed ? translateN(name) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button)
|
||||
{
|
||||
if(renderDefault())
|
||||
return false;
|
||||
|
||||
return cycle();
|
||||
}
|
||||
|
||||
public boolean cycle()
|
||||
{
|
||||
int next = value();
|
||||
do
|
||||
{
|
||||
next=(next+1)%count;
|
||||
}
|
||||
while(!optionValid(next));
|
||||
|
||||
if(next == value())
|
||||
return false;
|
||||
|
||||
getTag().setIntValue(next);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean optionValid(int index)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user