redo compmode to be adaptable

This commit is contained in:
ThisIsALegitUsername 2023-04-09 11:58:06 -06:00
parent aba3627ebf
commit c800a79511
3 changed files with 96 additions and 13 deletions

View File

@ -4,6 +4,7 @@ import dev.resent.client.Resent;
import dev.resent.module.base.Mod;
import dev.resent.module.base.setting.BooleanSetting;
import dev.resent.module.base.setting.ModeSetting;
import dev.resent.module.base.setting.NumberSetting;
import dev.resent.module.base.setting.Setting;
import dev.resent.util.misc.GlUtils;
import dev.resent.util.render.Color;
@ -15,6 +16,7 @@ import dev.resent.visual.ui.animation.SimpleAnimation;
import dev.resent.visual.ui.clickgui.rewrite.comp.Comp;
import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompCheck;
import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompMode;
import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompNumber;
import java.io.IOException;
import java.util.ArrayList;
@ -147,7 +149,7 @@ public class ClickGuiRewrite extends GuiScreen {
/* !------------- SETTINGS ----------------! */
if (selectedMod != null) {
RenderUtils.drawRoundedRect(x+80, y+105, x+width-20, y+390, 16, secondaryColor);
RenderUtils.drawRoundedRect(x+80, y+105, x+width-20, height+30, 16, secondaryColor);
fr.drawString("<", x+90, y+115+offset, -1, false);
for (Comp comp : comps) {
@ -297,10 +299,14 @@ public class ClickGuiRewrite extends GuiScreen {
if(s instanceof ModeSetting) {
settingXOffset -= fr.getStringWidth(s.name)+50;
comps.add(new CompMode(x+135, y+175+settingYOffset+modeSettingYOffset, selectedMod, s));
comps.add(new CompMode(x+90, y+200+settingYOffset+modeSettingYOffset, width, selectedMod, s));
modeSettingYOffset += 50;
}
if(s instanceof NumberSetting) {
comps.add(new CompNumber(x+135, y+125+settingYOffset, selectedMod, s));
}
if(x+160+settingXOffset+fr.getStringWidth(s.name)*2 > x+width-20) {
settingXOffset = 0;
settingYOffset += 25;
@ -309,4 +315,13 @@ public class ClickGuiRewrite extends GuiScreen {
}
}
}
@Override
protected void mouseReleased(int i, int j, int k) {
if (selectedMod != null) {
for (Comp c : comps) {
c.mouseReleased(i, j, k);
}
}
}
}

View File

@ -11,35 +11,36 @@ import net.minecraft.client.Minecraft;
public class CompMode extends Comp{
public CompMode(float x, float y, Mod m, Setting s) {
public CompMode(float x, float y, float width, Mod m, Setting s) {
this.x = x;
this.y = y;
this.width = width;
this.mod = m;
this.setting = s;
}
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
if(isMouseInside(mouseX, mouseY, x-2, y-3, x+6, y+9)) {
if(isMouseInside(mouseX, mouseY, x+8, y-3, x+18, y+9)) {
((ModeSetting)setting).cycle(false);
}
if(isMouseInside(mouseX, mouseY, x*3-12, y-3, x*3-4, y+9)) {
if(isMouseInside(mouseX, mouseY, x+width-138, y-3, x+width-130, y+9)) {
((ModeSetting)setting).cycle(true);
}
}
@Override
public void drawScreen(int mouseX, int mouseY) {
RenderUtils.drawRoundedRect(x-20, y-10, x*3+10, y+20, 8, 0xFF000000);
GlUtils.startScale((x-20+x*3+10)/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(setting.name)/2, y-20, 1.4f);
Minecraft.getMinecraft().fontRendererObj.drawString(setting.name, (x-20+x*3+10)/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(setting.name)/2-4, y-24, -1, false);
RenderUtils.drawRoundedRect(x, y-10, x-90+width-30, y+20, 8, 0xFF000000);
GlUtils.startScale((x+x-90+width-30)/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(setting.name)/2, y-20, 1.4f);
Minecraft.getMinecraft().fontRendererObj.drawString(setting.name, (x+x-90+width-30)/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(setting.name)/2-4, y-24, -1, false);
GlStateManager.popMatrix();
Minecraft.getMinecraft().fontRendererObj.drawString(((ModeSetting)setting).getValue(), (x-20+x*3+10)/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(((ModeSetting)setting).getValue())/2, y, -1, false);
Minecraft.getMinecraft().fontRendererObj.drawString("<", x, y, -1, false);
//RenderUtils.drawRectOutline(x-2, y-3, x+6, y+9, -1);
Minecraft.getMinecraft().fontRendererObj.drawString(">", x*3-10, y, -1, false);
//RenderUtils.drawRectOutline(x*3-12, y-3, x*3-4, y+9, -1);
Minecraft.getMinecraft().fontRendererObj.drawString(((ModeSetting)setting).getValue(), (x+x-90+width-30)/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(((ModeSetting)setting).getValue())/2, y, -1, false);
Minecraft.getMinecraft().fontRendererObj.drawString("<", x+10, y, -1, false);
//RenderUtils.drawRectOutline(x+8, y-3, x+18, y+9, -1);
Minecraft.getMinecraft().fontRendererObj.drawString(">", x+width-135, y, -1, false);
//RenderUtils.drawRectOutline(x+width-138, y-3, x+width-130, y+9, -1);
}
}

View File

@ -0,0 +1,67 @@
package dev.resent.visual.ui.clickgui.rewrite.comp.impl;
import dev.resent.module.base.Mod;
import dev.resent.module.base.setting.NumberSetting;
import dev.resent.module.base.setting.Setting;
import dev.resent.util.render.Color;
import dev.resent.util.render.RenderUtils;
import dev.resent.visual.ui.clickgui.rewrite.comp.Comp;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
public class CompNumber extends Comp{
public boolean draggingNumber;
public boolean settingDrag;
public int sliderOffset;
public CompNumber(float x, float y, Mod m, Setting s) {
this.x = x;
this.y = y;
this.mod = m;
this.setting = s;
}
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
if(isMouseInside(mouseX, mouseY, x*2+sliderOffset, y-3, x*2+10+sliderOffset, y+7)) {
draggingNumber = true;
}
}
@Override
public void drawScreen(int mouseX, int mouseY) {
NumberSetting ss = ((NumberSetting)setting);
Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(setting.name + ": sof " + sliderOffset + ", val: " + ss.getValue(), x, y, -1);
Gui.drawRect(x*2, y, x*2+100, y+4, -1);
RenderUtils.drawRoundedRect(x*2+sliderOffset, y-3, x*2+10+sliderOffset, y+7, 4, Color.RED.getRGB());
if (settingDrag) {
sliderOffset = (int) (mouseX - x*2);
ss.setValue(sliderOffset * (ss.max / 100));
} else {
sliderOffset = (int) ((ss.getValue() * 100) / ss.max);
}
if (sliderOffset < 0) {
settingDrag = false;
sliderOffset = 0;
} else if (draggingNumber) {
settingDrag = true;
}
if (sliderOffset > 100) {
settingDrag = false;
sliderOffset = 100;
} else if (draggingNumber) {
settingDrag = true;
}
}
@Override
public void mouseReleased(int mouseX, int mouseY, int state) {
draggingNumber = false;
settingDrag = false;
}
}