show tooltips over toggle buttons

This commit is contained in:
dags- 2020-03-12 10:25:20 +00:00
parent c6eec52518
commit d193d2ebda
1 changed files with 9 additions and 0 deletions

View File

@ -30,11 +30,14 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraftforge.common.util.Constants;
import java.util.List;
public class Toggle extends TerraButton {
private final String prefix;
private final CompoundNBT value;
private final ListNBT options;
private final List<String> tooltip;
private int index;
private Runnable callback = () -> {};
@ -43,6 +46,7 @@ public class Toggle extends TerraButton {
super(value.getString("value"));
this.value = value;
this.prefix = prefix;
this.tooltip = Element.readTooltip(value);
this.options = value.getList("#options", Constants.NBT.TAG_STRING);
for (int i = 0; i < options.size(); i++) {
String s = options.getString(i);
@ -59,6 +63,11 @@ public class Toggle extends TerraButton {
return this;
}
@Override
public List<String> getTooltip() {
return tooltip;
}
@Override
public boolean mouseClicked(double mx, double my, int button) {
if (super.isValidClickButton(button)) {