Fix click

This commit is contained in:
ThisIsALegitUsername 2023-02-27 23:11:47 +00:00
parent 541a1938bd
commit 6c912a9568
5 changed files with 29908 additions and 29909 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -3,52 +3,47 @@ package dev.resent.module.base.setting;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Arrays;
public class ModeSetting extends Setting {
public final class ModeSetting extends Setting {
public List<String> modes = new ArrayList<>();
public int index;
public List<String> modes;
public String current;
public int curr = 0;
public ModeSetting(String name, String description, String... modes) {
super(name, description);
Collections.addAll(this.modes, modes);
if (curr == this.modes.size()) {
curr = 0;
}
current = this.modes.get(curr);
}
public void onChange() {}
public void setValue(String val) {
if (this.modes.contains(val)) {
this.current = val;
}
}
public void next() {
++curr;
if (curr >= this.modes.size()) {
curr = 0;
}
current = this.modes.get(curr);
onChange();
}
public void back() {
--curr;
if (curr <= this.modes.size()) {
curr = 0;
}
current = this.modes.get(curr);
onChange();
public ModeSetting(final String name, final String defaultMode, final String... modes) {
super(name, "");
this.modes = Arrays.asList(modes);
index = this.modes.indexOf(defaultMode);
}
public String getValue() {
return current;
return modes.get(index);
}
public void setValue(final String mode) {
if (modes.contains(mode))
index = this.modes.indexOf(mode);
}
public boolean is(String mode) {
return index == modes.indexOf(mode);
}
public void cycle(boolean forwards) {
if (forwards) {
if (index < modes.size() - 1) {
index++;
} else {
index = 0;
}
}
if (!forwards) {
if (index > 0) {
index--;
} else {
index = modes.size() - 1;
}
}
}
}

View File

@ -193,7 +193,7 @@ public class TabGui extends RenderMod {
((BooleanSetting) setting).toggle();
}
if (setting instanceof ModeSetting) {
((ModeSetting) setting).next();
((ModeSetting) setting).cycle(true);
}
}

View File

@ -99,7 +99,7 @@ public class ClickGUI extends GuiScreen {
if (s instanceof ModeSetting) {
if (isMouseInside(mouseX, mouseY, this.x + 24 + fr.getStringWidth(s.name + ": " + ((ModeSetting)s).getValue()), height - 9 + 50 + var, this.x + 24 + fr.getStringWidth(s.name + ": " + ((ModeSetting)s).getValue() + " >"), height - 9 + 50 + var + 9) && mouseButton == 0)
((ModeSetting)s).next();
((ModeSetting)s).cycle(false);
}
if(s instanceof CustomRectSettingDraw){