Files
NotEnoughItems/src/main/java/codechicken/nei/config/OptionCycled.java
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
1.3 KiB
Java
Raw Normal View History

2014-04-29 10:54:20 +10:00
package codechicken.nei.config;
public class OptionCycled extends OptionButton {
2014-04-29 10:54:20 +10:00
public final int count;
public final boolean prefixed;
public OptionCycled(String name, int count, boolean prefixed) {
2014-04-29 10:54:20 +10:00
super(name);
this.count = count;
this.prefixed = prefixed;
}
public OptionCycled(String name, int count) {
2014-04-29 10:54:20 +10:00
this(name, count, false);
}
public int value() {
2014-04-29 10:54:20 +10:00
return renderTag().getIntValue();
}
@Override
public String getButtonText() {
return translateN(name + "." + value());
2014-04-29 10:54:20 +10:00
}
2014-04-29 10:54:20 +10:00
@Override
public String getPrefix() {
2014-04-29 10:54:20 +10:00
return prefixed ? translateN(name) : null;
}
2024-12-23 12:21:28 +02:00
@Override
public String getTooltip() {
String tooltip = name + "." + value() + ".tip";
String s = translateN(tooltip);
if (!s.equals(namespaced(tooltip))) {
return s;
}
return super.getTooltip();
}
2014-04-29 10:54:20 +10:00
@Override
public boolean onClick(int button) {
2014-04-29 10:54:20 +10:00
return cycle();
}
public boolean cycle() {
2014-04-29 10:54:20 +10:00
int next = value();
do next = (next + 1) % count; while (!optionValid(next));
if (next == value()) return false;
2014-04-29 10:54:20 +10:00
getTag().setIntValue(next);
return true;
}
public boolean optionValid(int index) {
2014-04-29 10:54:20 +10:00
return true;
}
}