custom rect setting

This commit is contained in:
ThisIsALegitUsername 2023-04-09 13:18:43 -06:00
parent 973e6bd221
commit 4c3e35b03c
2 changed files with 43 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package dev.resent.visual.ui.clickgui.rewrite;
import dev.resent.client.Resent; import dev.resent.client.Resent;
import dev.resent.module.base.Mod; import dev.resent.module.base.Mod;
import dev.resent.module.base.setting.BooleanSetting; import dev.resent.module.base.setting.BooleanSetting;
import dev.resent.module.base.setting.CustomRectSettingDraw;
import dev.resent.module.base.setting.ModeSetting; import dev.resent.module.base.setting.ModeSetting;
import dev.resent.module.base.setting.NumberSetting; import dev.resent.module.base.setting.NumberSetting;
import dev.resent.module.base.setting.Setting; import dev.resent.module.base.setting.Setting;
@ -15,6 +16,7 @@ import dev.resent.visual.ui.animation.Direction;
import dev.resent.visual.ui.animation.SimpleAnimation; import dev.resent.visual.ui.animation.SimpleAnimation;
import dev.resent.visual.ui.clickgui.rewrite.comp.Comp; 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.CompCheck;
import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompCustom;
import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompMode; import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompMode;
import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompNumber; import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompNumber;
@ -298,18 +300,21 @@ public class ClickGuiRewrite extends GuiScreen {
if (s instanceof BooleanSetting) { if (s instanceof BooleanSetting) {
comps.add(new CompCheck(x+110+settingXOffset, y+125+settingYOffset, selectedMod, s)); comps.add(new CompCheck(x+110+settingXOffset, y+125+settingYOffset, selectedMod, s));
} }
if(s instanceof ModeSetting) { if(s instanceof ModeSetting) {
settingXOffset -= fr.getStringWidth(s.name)+50; settingXOffset -= fr.getStringWidth(s.name)+50;
comps.add(new CompMode(x+90, y+200+settingYOffset+modeSettingYOffset, width, selectedMod, s)); comps.add(new CompMode(x+90, y+200+settingYOffset+modeSettingYOffset, width, selectedMod, s));
modeSettingYOffset += 50; modeSettingYOffset += 50;
} }
if(s instanceof NumberSetting) { if(s instanceof NumberSetting) {
comps.add(new CompNumber(x+135, y+125+settingYOffset, selectedMod, s)); comps.add(new CompNumber(x+135, y+125+settingYOffset, selectedMod, s));
} }
if(s instanceof CustomRectSettingDraw) {
settingYOffset += 25;
settingXOffset = 0;
comps.add(new CompCustom(x+110+settingXOffset, y+125+settingYOffset, selectedMod, s.name, s));
}
if(x+160+settingXOffset+fr.getStringWidth(s.name)*2 > x+width-20) { if(x+180+settingXOffset+fr.getStringWidth(s.name)*2 > x+width-20) {
settingXOffset = 0; settingXOffset = 0;
settingYOffset += 25; settingYOffset += 25;
}else { }else {

View File

@ -0,0 +1,35 @@
package dev.resent.visual.ui.clickgui.rewrite.comp.impl;
import dev.resent.module.base.Mod;
import dev.resent.module.base.setting.CustomRectSettingDraw;
import dev.resent.module.base.setting.Setting;
import dev.resent.util.render.RenderUtils;
import dev.resent.visual.ui.clickgui.rewrite.comp.Comp;
import net.minecraft.client.Minecraft;
public class CompCustom extends Comp{
public String name;
public CompCustom(float x, float y, Mod m, String name, Setting s) {
this.x = x;
this.y = y;
this.mod = m;
this.name = name;
this.setting = s;
}
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
if(isMouseInside(mouseX, mouseY, x, y, x+Minecraft.getMinecraft().fontRendererObj.getStringWidth(name)*2, y+20)) {
((CustomRectSettingDraw)setting).onPress();
}
}
@Override
public void drawScreen(int mouseX, int mouseY) {
RenderUtils.drawRoundedRect(x, y, x+Minecraft.getMinecraft().fontRendererObj.getStringWidth(name)*2, y+20, 8, isMouseInside(mouseX, mouseY, x, y, x+Minecraft.getMinecraft().fontRendererObj.getStringWidth(name)*2, y+20) ? 0xFF181818 : 0xFF000000);
Minecraft.getMinecraft().fontRendererObj.drawString(name, x+Minecraft.getMinecraft().fontRendererObj.getStringWidth(name)/2, y+6, -1, false);
}
}