-
Notifications
You must be signed in to change notification settings - Fork 308
Expand file tree
/
Copy pathSwitchOptionWidget.java
More file actions
40 lines (30 loc) · 1021 Bytes
/
SwitchOptionWidget.java
File metadata and controls
40 lines (30 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package net.vulkanmod.config.widget;
import net.minecraft.network.chat.Component;
import net.vulkanmod.config.SwitchOption;
public class SwitchOptionWidget extends OptionWidget {
SwitchOption option;
private boolean focused;
public SwitchOptionWidget(SwitchOption option, int x, int y, int width, int height, Component name) {
super(x, y, width, height, name);
this.option = option;
updateDisplayedValue();
}
public void onClick(double mouseX, double mouseY) {
this.option.setValue(!this.option.getValue());
updateDisplayedValue();
}
private void updateDisplayedValue() {
this.displayedValue = option.getValue() ? Component.nullToEmpty("On") : Component.nullToEmpty("Off");
}
public Component getTooltip() {
return this.option.getTooltip();
}
@Override
public void setFocused(boolean bl) {
this.focused = bl;
}
@Override
public boolean isFocused() {
return this.focused;
}
}