(ui) switches instead of checkboxes in settings

This commit is contained in:
kirillsaint 2024-01-22 12:38:38 +06:00
parent 7f4c28c89e
commit 140a9f8568
6 changed files with 17 additions and 14 deletions

View File

@ -140,7 +140,7 @@ public class ClickGUI extends SilentScreen {
RenderUtil.drawImage(new ResourceLocation(m.getIcon()), modOffsetX + ((65 / 2) - 10), y + modOffsetY - scrollAnimation.getValue() + ((70 / 2) - 10), 20, 20, false); RenderUtil.drawImage(new ResourceLocation(m.getIcon()), modOffsetX + ((65 / 2) - 10), y + modOffsetY - scrollAnimation.getValue() + ((70 / 2) - 10), 20, 20, false);
} }
if(selectedCategory.equals(ModCategory.MODS)) { if(selectedCategory.equals(ModCategory.MODS)) {
Switch.render(mouseX, mouseY, switchX, switchY, m.switchAniamation, m.isEnabled(), m.isForceDisabled(), m.isForceDisabled() ? "Force disabled" : null); Switch.render(mouseX, mouseY, switchX, switchY, m.simpleAnimation, m.isEnabled(), m.isForceDisabled(), m.isForceDisabled() ? "Force disabled" : null);
} }
if(switchHovered || isHovered) { if(switchHovered || isHovered) {

View File

@ -194,10 +194,12 @@ public class ModSettings extends SilentScreen {
} }
if (setting.isCheck()) { if (setting.isCheck()) {
Checkbox.render(mouseX, mouseY, x + 100, settingY - 1, setting.getName(), setting.getValBoolean()); Switch.render(mouseX, mouseY, x + 100, settingY - 1, setting.switchAnimation, setting.getValBoolean(), false);
if(Checkbox.isHovered(mouseX, mouseY, x + 100, settingY - 1)) { if(Switch.isHovered(mouseX, mouseY, x + 100, settingY - 1)) {
cursorType = MouseCursorHandler.CursorType.POINTER; cursorType = MouseCursorHandler.CursorType.POINTER;
} }
Client.getInstance().getSilentFontRenderer().drawString(setting.getName(), x + 100 + 18, settingY + (((float) 8 / 2) - ((float) 12 / 2)) - 1, 12, SilentFontRenderer.FontType.TITLE);
} }
if(setting.isCellGrid()) { if(setting.isCellGrid()) {
MouseCursorHandler.CursorType cellGridCursor = CellGrid.render(mouseX, mouseY, x + 100, settingY, setting); MouseCursorHandler.CursorType cellGridCursor = CellGrid.render(mouseX, mouseY, x + 100, settingY, setting);
@ -230,7 +232,7 @@ public class ModSettings extends SilentScreen {
if(MouseUtils.isInside(mouseX, mouseY, x + width - (10 + 8) - 15, y + 5 + scrollAnimation.getValue(), 10, 10)) { if(MouseUtils.isInside(mouseX, mouseY, x + width - (10 + 8) - 15, y + 5 + scrollAnimation.getValue(), 10, 10)) {
cursorType = MouseCursorHandler.CursorType.POINTER; cursorType = MouseCursorHandler.CursorType.POINTER;
} }
Switch.render(mouseX, mouseY, x + width - (10 + 8), y + 6 + scrollAnimation.getValue(), mod.switchAniamation, mod.isEnabled(), mod.isForceDisabled(), mod.isForceDisabled() ? "Force disabled" : null); Switch.render(mouseX, mouseY, x + width - (10 + 8), y + 6 + scrollAnimation.getValue(), mod.simpleAnimation, mod.isEnabled(), mod.isForceDisabled(), mod.isForceDisabled() ? "Force disabled" : null);
if(Switch.isHovered(mouseX, mouseY, x + width - (10 + 8), y + 6 + scrollAnimation.getValue())) { if(Switch.isHovered(mouseX, mouseY, x + width - (10 + 8), y + 6 + scrollAnimation.getValue())) {
cursorType = MouseCursorHandler.CursorType.POINTER; cursorType = MouseCursorHandler.CursorType.POINTER;
} }
@ -403,7 +405,7 @@ public class ModSettings extends SilentScreen {
} }
if (setting.isCheck()) { if (setting.isCheck()) {
if(Checkbox.isHovered(mouseX, mouseY, x + 100, settingY - 1)) { if(Switch.isHovered(mouseX, mouseY, x + 100, settingY - 1)) {
Sounds.playButtonSound(); Sounds.playButtonSound();
setting.setValBoolean(!setting.getValBoolean()); setting.setValBoolean(!setting.getValBoolean());
mod.onChangeSettingValue(setting); mod.onChangeSettingValue(setting);

View File

@ -171,7 +171,7 @@ public class ModMenu extends SilentScreen {
} }
if(modCategory == ModCategory.MODS) { if(modCategory == ModCategory.MODS) {
Switch.render(mouseX, mouseY, 129, modY + 10 - 4, mod.switchAniamation, mod.isEnabled(), mod.isForceDisabled(), mod.isForceDisabled() ? "Force disabled" : null); Switch.render(mouseX, mouseY, 129, modY + 10 - 4, mod.simpleAnimation, mod.isEnabled(), mod.isForceDisabled(), mod.isForceDisabled() ? "Force disabled" : null);
if(Switch.isHovered(mouseX, mouseY, 129, modY + 10 - 4)) { if(Switch.isHovered(mouseX, mouseY, 129, modY + 10 - 4)) {
cursorType = MouseCursorHandler.CursorType.POINTER; cursorType = MouseCursorHandler.CursorType.POINTER;
} }

View File

@ -7,10 +7,7 @@ import net.minecraft.util.MathHelper;
import net.silentclient.client.Client; import net.silentclient.client.Client;
import net.silentclient.client.gui.SilentScreen; import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.gui.animation.SimpleAnimation; import net.silentclient.client.gui.animation.SimpleAnimation;
import net.silentclient.client.gui.elements.Button; import net.silentclient.client.gui.elements.*;
import net.silentclient.client.gui.elements.Checkbox;
import net.silentclient.client.gui.elements.Input;
import net.silentclient.client.gui.elements.StaticButton;
import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.theme.button.DefaultButtonTheme; import net.silentclient.client.gui.theme.button.DefaultButtonTheme;
import net.silentclient.client.gui.theme.button.RedButtonTheme; import net.silentclient.client.gui.theme.button.RedButtonTheme;
@ -130,10 +127,12 @@ public class ModSettings extends SilentScreen {
} }
} }
if (setting.isCheck()) { if (setting.isCheck()) {
Checkbox.render(mouseX, mouseY, 3, settingY, setting.getName(), setting.getValBoolean()); Switch.render(mouseX, mouseY, 3, settingY, setting.switchAnimation, setting.getValBoolean(), false);
if(Checkbox.isHovered(mouseX, mouseY, 3, settingY)) { if(Switch.isHovered(mouseX, mouseY, 3, settingY)) {
cursorType = MouseCursorHandler.CursorType.POINTER; cursorType = MouseCursorHandler.CursorType.POINTER;
} }
Client.getInstance().getSilentFontRenderer().drawString(setting.getName(), 3 + 18, settingY + (((float) 8 / 2) - ((float) 12 / 2)), 12, SilentFontRenderer.FontType.TITLE);
} }
if(setting.isCellGrid()) { if(setting.isCellGrid()) {
MouseCursorHandler.CursorType cellGridCursor = CellGrid.render(mouseX, mouseY, 3, settingY, setting); MouseCursorHandler.CursorType cellGridCursor = CellGrid.render(mouseX, mouseY, 3, settingY, setting);
@ -263,7 +262,7 @@ public class ModSettings extends SilentScreen {
mc.displayGuiScreen(new ColorPicker(mod, setting.getName(), this)); mc.displayGuiScreen(new ColorPicker(mod, setting.getName(), this));
} }
if (setting.isCheck()) { if (setting.isCheck()) {
if(Checkbox.isHovered(mouseX, mouseY, 3, settingY)) { if(Switch.isHovered(mouseX, mouseY, 3, settingY)) {
Sounds.playButtonSound(); Sounds.playButtonSound();
setting.setValBoolean(!setting.getValBoolean()); setting.setValBoolean(!setting.getValBoolean());
mod.onChangeSettingValue(setting); mod.onChangeSettingValue(setting);

View File

@ -31,7 +31,7 @@ public class Mod implements IMod {
private boolean updated = false; private boolean updated = false;
private boolean newMod = false; private boolean newMod = false;
public SimpleAnimation switchAniamation = new SimpleAnimation(0); public SimpleAnimation simpleAnimation = new SimpleAnimation(0);
public Mod(String name, ModCategory category, String icon, boolean defaultEnabled, boolean updated, boolean newMod) { public Mod(String name, ModCategory category, String icon, boolean defaultEnabled, boolean updated, boolean newMod) {
this.mc = Minecraft.getMinecraft(); this.mc = Minecraft.getMinecraft();

View File

@ -2,6 +2,7 @@ package net.silentclient.client.mods;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.silentclient.client.Client; import net.silentclient.client.Client;
import net.silentclient.client.gui.animation.SimpleAnimation;
import net.silentclient.client.utils.ColorUtils; import net.silentclient.client.utils.ColorUtils;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
@ -49,6 +50,7 @@ public class Setting implements Comparable<Setting> {
private boolean canChangeOpacity = false; private boolean canChangeOpacity = false;
private boolean onlyPremiumPlus = false; private boolean onlyPremiumPlus = false;
public SimpleAnimation switchAnimation = new SimpleAnimation(0);
public Setting(String name, Mod parent, String sval, ArrayList<String> options) { public Setting(String name, Mod parent, String sval, ArrayList<String> options) {
this.name = name; this.name = name;