begin rewrite

This commit is contained in:
ThisIsALegitUsername 2023-03-08 15:47:06 +00:00
parent 458f28ebc4
commit c501b8899d
4 changed files with 96 additions and 8 deletions

View File

@ -17,4 +17,9 @@ public class FuncUtils {
}
return ret;
}
public static boolean isInside(int mouseX, int mouseY, double x, double y, double width, double height) {
return (mouseX > x && mouseX < (x + width)) && (mouseY > y && mouseY < (y + height));
}
}

View File

@ -1,29 +1,48 @@
package dev.resent.visual.ui.clickgui.rewrite;
import java.util.ArrayList;
import dev.resent.client.Resent;
import dev.resent.module.base.Mod;
import dev.resent.module.base.setting.BooleanSetting;
import dev.resent.module.base.setting.Setting;
import dev.resent.util.misc.GlUtils;
import dev.resent.visual.ui.Theme;
import dev.resent.visual.ui.animation.Animation;
import dev.resent.visual.ui.animation.Direction;
import dev.resent.visual.ui.clickgui.rewrite.comp.Comp;
import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompCheck;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
public class ClickGuiRewrite extends GuiScreen{
public ArrayList<Comp> comps = new ArrayList<>();
public int x, y, width, height, offset;
public Animation introAnimation;
public int x, y, width, height;
public ScaledResolution sr;
public boolean closing;
public Mod selectedMod;
@Override
public void drawScreen(int mouseX, int mouseY, float var3) {
GlUtils.startScale((this.x + this.width) / 2, (this.y + this.height) / 2, introAnimation != null ? (float) introAnimation.getValue() : 1);
for(Mod m : Resent.INSTANCE.modManager.modules){
}
GlUtils.stopScale();
if(selectedMod != null){
for (Comp comp : comps) {
comp.drawScreen(mouseX, mouseY);
}
}
if (closing) {
comps.clear();
if(introAnimation == null) {
mc.displayGuiScreen(null);
return;
@ -37,7 +56,26 @@ public class ClickGuiRewrite extends GuiScreen{
}
@Override
protected void mouseClicked(int parInt1, int parInt2, int parInt3) {
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
for(Mod m : Resent.INSTANCE.modManager.modules){
//replace params with gear icon pos
if(isMouseInside(mouseX, mouseY, width-20, y+20, width-40, y+40) && mouseButton == 0){
for(Setting s : m.settings){
if(s instanceof BooleanSetting){
comps.add(new CompCheck(4, 4, selectedMod, s));
}
}
}
}
if(selectedMod != null){
for(Comp c : comps){
c.mouseClicked(mouseX, mouseY, mouseButton);
}
}
}
@ -52,10 +90,16 @@ public class ClickGuiRewrite extends GuiScreen{
}
@Override
protected void keyTyped(char par1, int par2) {
if (par2 == 0x01 || par2 == Minecraft.getMinecraft().gameSettings.keyBindClickGui.keyCode) {
protected void keyTyped(char par1, int key) {
if (key == 0x01 || key == Minecraft.getMinecraft().gameSettings.keyBindClickGui.keyCode) {
closing = true;
}
if(selectedMod != null){
for(Comp c : comps){
c.keyTyped(par1, key);
}
}
}
public boolean isMouseInside(double mouseX, double mouseY, double x, double y, double width, double height) {

View File

@ -1,9 +1,17 @@
package dev.resent.visual.ui.clickgui.rewrite.comp;
import dev.resent.module.base.Mod;
import dev.resent.module.base.setting.Setting;
public abstract class Comp {
public abstract void draw();
public void mouseClicked() { }
public int x, y;
public Mod mod;
public Setting setting;
public int x, y, width, height;
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {}
public void mouseReleased(int mouseX, int mouseY, int state) {}
public void drawScreen(int mouseX, int mouseY) {}
public void keyTyped(char typedChar, int keyCode) {}
}

View File

@ -0,0 +1,31 @@
package dev.resent.visual.ui.clickgui.rewrite.comp.impl;
import dev.resent.module.base.Mod;
import dev.resent.module.base.setting.BooleanSetting;
import dev.resent.module.base.setting.Setting;
import dev.resent.util.misc.FuncUtils;
import dev.resent.visual.ui.clickgui.rewrite.comp.Comp;
public class CompCheck extends Comp{
public CompCheck(int x, int y, Mod m, Setting s){
this.x = x;
this.y = y;
this.mod = m;
this.setting = s;
}
@Override
public void drawScreen(int mouseX, int mouseY) {
}
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
//replace with checkbox location
if(FuncUtils.isInside(mouseX, mouseY, x, y, width, height)){
((BooleanSetting)setting).toggle();
}
}
}