VulkanShader_1.21.10-0.0.4-alpha.jar
Download file
package net.vulkanmod.config.gui.widget;
import net.minecraft.class_2561;
import net.minecraft.class_310;
import net.minecraft.class_327;
import net.vulkanmod.config.gui.render.GuiRenderer;
import net.vulkanmod.config.option.SwitchOption;
import net.vulkanmod.vulkan.util.ColorUtil;
public class SwitchOptionWidget extends OptionWidget<SwitchOption> {
private boolean focused;
public SwitchOptionWidget(SwitchOption option, class_2561 name) {
super(option, name);
this.updateDisplayedValue();
}
protected void renderControls(double mouseX, double mouseY) {
int center = this.controlX + this.controlWidth / 2;
int halfWidth = 12;
int x0 = center - halfWidth;
int y0 = this.y + 4;
int height = this.height - 8;
int w1 = halfWidth - 4;
int h1 = height - 4;
if ((Boolean)((SwitchOption)this.option).getNewValue()) {
int x1 = x0 + halfWidth + 2;
int color = ColorUtil.ARGB.pack(0.4F, 0.4F, 0.4F, 1.0F);
GuiRenderer.fillBox(x0 + 2, y0 + 2, x1 - (x0 + 2) - 1, h1, color);
color = ColorUtil.ARGB.pack(1.0F, 1.0F, 1.0F, 1.0F);
GuiRenderer.fillBox(x1, y0 + 2, w1, h1, color);
} else {
int color = ColorUtil.ARGB.pack(1.0F, 1.0F, 1.0F, 0.4F);
GuiRenderer.fillBox(x0 + 2, y0 + 2, w1, h1, color);
}
int var19 = ColorUtil.ARGB.pack(0.6F, 0.6F, 0.6F, 1.0F);
GuiRenderer.renderBoxBorder(x0, y0, halfWidth * 2, height, 1, var19);
var19 = this.active ? -1 : -6250336;
class_327 textRenderer = class_310.method_1551().field_1772;
int margin = Math.max(textRenderer.method_1727(class_2561.method_43471("options.on").getString()) / 3, textRenderer.method_1727(class_2561.method_43471("options.off").getString()) / 3);
int x = this.controlX + this.controlWidth / 2 - (int)((float)halfWidth * 1.5F) - 4 - margin;
int y = this.y + (this.height - 8) / 2;
GuiRenderer.drawCenteredString(textRenderer, this.getDisplayedValue(), x, y, var19);
}
public void onClick(double mouseX, double mouseY) {
((SwitchOption)this.option).setNewValue(!(Boolean)((SwitchOption)this.option).getNewValue());
this.updateDisplayedValue();
}
public void onRelease(double mouseX, double mouseY) {
}
protected void onDrag(double mouseX, double mouseY, double deltaX, double deltaY) {
}
protected void updateDisplayedValue() {
this.displayedValue = (Boolean)((SwitchOption)this.option).getNewValue() ? class_2561.method_43471("options.on") : class_2561.method_43471("options.off");
}
public void method_25365(boolean bl) {
this.focused = bl;
}
public boolean method_25370() {
return this.focused;
}
}
Download file