mirror of
https://github.com/Shiewk/Widgets.git
synced 2026-04-28 11:34:17 +02:00
Add option to set show condition on widget options
This commit is contained in:
@@ -6,6 +6,7 @@ import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class WidgetSettingOption implements Drawable, Widget {
|
||||
@@ -14,6 +15,7 @@ public abstract class WidgetSettingOption implements Drawable, Widget {
|
||||
private int x = 0;
|
||||
private int y = 0;
|
||||
private boolean focused = false;
|
||||
private BooleanSupplier shouldShow = WidgetUtils.TRUE_SUPPLIER;
|
||||
|
||||
protected WidgetSettingOption(String id, Text name) {
|
||||
this.id = id;
|
||||
@@ -83,4 +85,13 @@ public abstract class WidgetSettingOption implements Drawable, Widget {
|
||||
public void setFocused(boolean focused) {
|
||||
this.focused = focused;
|
||||
}
|
||||
|
||||
public boolean shouldShow(){
|
||||
return shouldShow.getAsBoolean();
|
||||
}
|
||||
|
||||
public WidgetSettingOption setShowCondition(BooleanSupplier shouldShow){
|
||||
this.shouldShow = shouldShow;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user