2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.client.gui.util;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
|
|
2024-02-13 17:30:01 -06:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public class GuiNpcButton extends GuiButton{
|
2024-02-13 17:30:01 -06:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
protected String[] display;
|
|
|
|
|
private int displayValue = 0;
|
|
|
|
|
public int id;
|
2024-02-13 17:30:01 -06:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public GuiNpcButton(int i, int j, int k, String s) {
|
|
|
|
|
super(i, j, k, StatCollector.translateToLocal(s));
|
|
|
|
|
id = i;
|
|
|
|
|
}
|
|
|
|
|
public GuiNpcButton(int i, int j, int k, String[] display, int val) {
|
|
|
|
|
this(i, j, k, display[val]);
|
|
|
|
|
this.display = display;
|
|
|
|
|
this.displayValue = val;
|
|
|
|
|
}
|
|
|
|
|
public GuiNpcButton(int i, int j, int k, int l, int m, String string) {
|
|
|
|
|
super(i, j, k, l, m, StatCollector.translateToLocal(string));
|
|
|
|
|
id = i;
|
|
|
|
|
}
|
|
|
|
|
public GuiNpcButton(int i, int j, int k, int l, int m, String[] display,
|
|
|
|
|
int val) {
|
|
|
|
|
this(i, j, k, l, m, display.length == 0?"":display[val % display.length]);
|
|
|
|
|
this.display = display;
|
|
|
|
|
this.displayValue = display.length == 0?0:val % display.length;
|
|
|
|
|
}
|
2024-02-13 17:30:01 -06:00
|
|
|
|
|
|
|
|
public GuiNpcButton(int i, int j, int k, int l, int m, Enum<?>[] displayEnums,
|
|
|
|
|
int val) {
|
|
|
|
|
this(i, j, k, l, m, displayEnums.length == 0 ? "" : displayEnums[val % displayEnums.length].toString());
|
|
|
|
|
|
|
|
|
|
ArrayList<String> strings = new ArrayList<>();
|
|
|
|
|
for (Enum<?> e : displayEnums) {
|
|
|
|
|
strings.add(e.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.display = strings.toArray(new String[0]);
|
|
|
|
|
this.displayValue = display.length == 0?0:val % display.length;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void setDisplayText(String text){
|
|
|
|
|
this.displayString = StatCollector.translateToLocal(text);
|
|
|
|
|
}
|
|
|
|
|
public int getValue(){
|
|
|
|
|
return displayValue;
|
|
|
|
|
}
|
2024-02-13 17:30:01 -06:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void setEnabled(boolean bo){
|
|
|
|
|
this.enabled = bo;
|
|
|
|
|
}
|
|
|
|
|
public void setVisible(boolean b) {
|
|
|
|
|
this.visible = b;
|
2024-02-13 17:30:01 -06:00
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
public boolean getVisible() {
|
|
|
|
|
return visible;
|
|
|
|
|
}
|
2024-02-13 17:30:01 -06:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void setDisplay(int value){
|
|
|
|
|
this.displayValue = value;
|
|
|
|
|
this.setDisplayText(display[value]);
|
2024-02-13 17:30:01 -06:00
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void setTextColor(int color){
|
|
|
|
|
this.packedFGColour = color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean mousePressed(Minecraft minecraft, int i, int j)
|
|
|
|
|
{
|
|
|
|
|
boolean bo = super.mousePressed(minecraft, i, j);
|
|
|
|
|
if(bo && display != null && display.length != 0){
|
|
|
|
|
displayValue = (displayValue+1) % display.length;
|
|
|
|
|
this.setDisplayText(display[displayValue]);
|
|
|
|
|
}
|
|
|
|
|
return bo;
|
|
|
|
|
}
|
2024-02-13 17:30:01 -06:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public int getWidth() {
|
|
|
|
|
return width;
|
|
|
|
|
}
|
|
|
|
|
}
|