fixed some shit and added switches

This commit is contained in:
kone 2023-04-10 20:43:10 -04:00
parent e01b2e3752
commit 2be86ec0f9
3 changed files with 61 additions and 16 deletions

View File

@ -4,6 +4,7 @@ import dev.resent.annotation.Module;
import dev.resent.module.base.setting.Setting; import dev.resent.module.base.setting.Setting;
import dev.resent.util.render.RenderUtils; import dev.resent.util.render.RenderUtils;
import dev.resent.visual.ui.Theme; import dev.resent.visual.ui.Theme;
import dev.resent.visual.ui.animation.Animation;
import dev.resent.visual.ui.animation.SimpleAnimation; import dev.resent.visual.ui.animation.SimpleAnimation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -19,6 +20,10 @@ public abstract class Mod {
private boolean hasSetting; private boolean hasSetting;
private boolean admin; private boolean admin;
public SimpleAnimation toggleAnimation = new SimpleAnimation(0); public SimpleAnimation toggleAnimation = new SimpleAnimation(0);
public Animation switchAnim;
public Animation switchColorRAnim;
public Animation switchColorGAnim;
public Animation switchColorBAnim;
public List<Setting> settings = new ArrayList<>(); public List<Setting> settings = new ArrayList<>();

View File

@ -116,16 +116,16 @@ public class RenderUtils {
worldrenderer.pos(idk, idk2, 0); worldrenderer.pos(idk, idk2, 0);
} }
public static void drawRoundedRect(final float paramInt1, final float paramInt2, final float paramInt3, final float paramInt4, final float radius, final int color, boolean... forceOverride) { public static void drawRoundedRect(final float left, final float top, final float right, final float bottom, final float radius, final int color, boolean... forceOverride) {
final float f1 = (color >> 24 & 0xFF) / 255.0f; final float f1 = (color >> 24 & 0xFF) / 255.0f;
final float f2 = (color >> 16 & 0xFF) / 255.0f; final float f2 = (color >> 16 & 0xFF) / 255.0f;
final float f3 = (color >> 8 & 0xFF) / 255.0f; final float f3 = (color >> 8 & 0xFF) / 255.0f;
final float f4 = (color & 0xFF) / 255.0f; final float f4 = (color & 0xFF) / 255.0f;
GlStateManager.color(f2, f3, f4, f1); GlStateManager.color(f2, f3, f4, f1);
if (Theme.getRounded() || forceOverride[0]) { if (Theme.getRounded() || forceOverride[0]) {
drawRoundedRect(paramInt1, paramInt2, paramInt3, paramInt4, radius); drawRoundedRect(left, top, right, bottom, radius);
} else { } else {
Gui.drawRect((int) paramInt1, (int) paramInt2, (int) paramInt3, (int) paramInt4, color); Gui.drawRect((int) left, (int) top, (int) right, (int) bottom, color);
} }
} }

View File

@ -54,6 +54,7 @@ public class ClickGuiRewrite extends GuiScreen {
public String part = "Home"; public String part = "Home";
public Animation bgDimAnim; public Animation bgDimAnim;
public Animation searchCursorAnim; public Animation searchCursorAnim;
public Animation switchAnim;
@Override @Override
public void drawScreen(int mouseX, int mouseY, float var3) { public void drawScreen(int mouseX, int mouseY, float var3) {
//GlStateManager.scale(1f,1f,0f); //GlStateManager.scale(1f,1f,0f);
@ -69,10 +70,10 @@ public class ClickGuiRewrite extends GuiScreen {
/* !-------------- NECESSARY ELEMENTS -----------------! */ /* !-------------- NECESSARY ELEMENTS -----------------! */
//Navigation bar //Navigation bar
RenderUtils.drawRoundedRect(x, y, x+width-60, y+height, 32, secondaryColor); RenderUtils.drawRoundedRect(x, y, x+width-60, y+height, 16, secondaryColor);
//Background overlay //Background overlay
RenderUtils.drawRoundedRect(x+60, y, x+width, y+height, 32, backgroundColor); RenderUtils.drawRoundedRect(x+60, y, x+width, y+height, 16, backgroundColor);
Gui.drawRect(x+60, y, x+102, y+height, backgroundColor); Gui.drawRect(x+60, y, x+102, y+height, backgroundColor);
//Separating line //Separating line
@ -142,23 +143,34 @@ public class ClickGuiRewrite extends GuiScreen {
if (!m.isAdmin() && m.getName().toLowerCase().startsWith(searchString.toLowerCase()) && selectedMod == null) { if (!m.isAdmin() && m.getName().toLowerCase().startsWith(searchString.toLowerCase()) && selectedMod == null) {
if (y+125+offset+scrollOffset > y+95 && y+155+offset+scrollOffset < y+height) { if (y+125+offset+scrollOffset > y+95 && y+155+offset+scrollOffset < y+height) {
//Body //Body
RenderUtils.drawRoundedRect(x+80, y+125+offset+scrollOffset, x+width-20, y+155+offset+scrollOffset, 16, secondaryColor); RenderUtils.drawRoundedRect(x+80, y+125+offset+scrollOffset, x+width-20, y+175+offset+scrollOffset, 8, secondaryColor);
//Gear //Gear
if (m.doesHaveSetting()) { if (m.doesHaveSetting()) {
if (isMouseInside(mouseX, mouseY, x+width-60, (int) y+140+offset+scrollOffset, (x+width-60) + 20, ((int) y+140+offset+scrollOffset) + 20)) {
RenderUtils.drawRoundedRect(x+width-65, (int) y+135+offset+scrollOffset, (x+width-60) + 25, ((int) y+140+offset+scrollOffset) + 25, 8, secondaryFontColor.getRGB());
}
GlStateManager.color(1, 1, 1); GlStateManager.color(1, 1, 1);
mc.getTextureManager().bindTexture(new ResourceLocation("eagler:gui/gear2.png")); mc.getTextureManager().bindTexture(new ResourceLocation("eagler:gui/gear2.png"));
Gui.drawModalRectWithCustomSizedTexture(x+width-60, (int) y+120+offset+scrollOffset, 0, 0, 20, 20, 20, 20);
Gui.drawModalRectWithCustomSizedTexture(x+width-60, (int) y+140+offset+scrollOffset, 0, 0, 20, 20, 20, 20);
} }
//Toggle //Toggle
RenderUtils.drawRoundedRect(x+100, y+135+offset+scrollOffset, x+110, y+145+offset+scrollOffset, 8, m.isEnabled() ? onSurfaceColor : new Color(66, 66, 66).getRGB());
RenderUtils.drawRoundedRect(x+90, y+140+offset+scrollOffset, x+125, y+155+offset+scrollOffset, 8,
new Color(66 + (int) m.switchColorRAnim.getValue(), 66 + (int) m.switchColorGAnim.getValue(), 66 + (int) m.switchColorBAnim.getValue()).getRGB());
new Color(187, 134, 252);
RenderUtils.drawRoundedRect((x+90) + (int) m.switchAnim.getValue(), y+140+offset+scrollOffset, (x+105) + (int) m.switchAnim.getValue(), y+155+offset+scrollOffset, 8, new Color(255, 255, 255).getRGB());
GlUtils.startScale(x+90, y+140+offset+scrollOffset, 2); GlUtils.startScale(x+90, y+140+offset+scrollOffset, 2);
int i = fr.drawString(m.getName(), x+120, y+140+offset+scrollOffset, -1, false); int i = fr.drawString(m.getName(), x+120, y+140+offset+scrollOffset, -1, false);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
GlUtils.startScale(x+120+i / 2, y+120+offset+scrollOffset, 1.5f); GlUtils.startScale(x+120+i / 2, y+120+offset+scrollOffset, 1.2f);
fr.drawString(m.getDescription(), x+20+i, y+122+offset+scrollOffset, -1, false); if (m.getDescription() != "No Description Set.") {
fr.drawString(m.getDescription(), x+20+i, y+140+offset+scrollOffset, -1, false);
}
GlStateManager.popMatrix(); GlStateManager.popMatrix();
// if (isMouseInside(mouseX, mouseY, x+i+80, y+115+offset+scrollOffset, x+width-20, y+185+offset+scrollOffset)) { // if (isMouseInside(mouseX, mouseY, x+i+80, y+115+offset+scrollOffset, x+width-20, y+185+offset+scrollOffset)) {
// fr.drawString(m.getDescription(), mousex+8, mouseY, onSurfaceColor, false); // fr.drawString(m.getDescription(), mousex+8, mouseY, onSurfaceColor, false);
@ -231,15 +243,29 @@ public class ClickGuiRewrite extends GuiScreen {
drawSetting(); drawSetting();
} }
if (isMouseInside(mouseX, mouseY, x+80, y+125+offset+scrollOffset, x+width-20, y+155+offset+scrollOffset)) { if (m.doesHaveSetting() && isMouseInside(mouseX, mouseY, x+width-60, (int) y+140+offset+scrollOffset, (x+width-60) + 20, ((int) y+140+offset+scrollOffset) + 20)) {
if (mouseButton == 1 && m.doesHaveSetting()) {
selectedMod = m; selectedMod = m;
drawSetting(); drawSetting();
} }
if (isMouseInside(mouseX, mouseY, x+90, y+140+offset+scrollOffset, x+125, y+155+offset+scrollOffset)) {
if (mouseButton == 0 && selectedMod == null) { if (mouseButton == 0 && selectedMod == null) {
m.toggle(); m.toggle();
if (m.isEnabled()) {
m.switchAnim = new EaseInOutQuad(200, 20);
m.switchColorRAnim = new EaseInOutQuad(200, 121);
m.switchColorGAnim = new EaseInOutQuad(200, 68);
m.switchColorBAnim = new EaseInOutQuad(200, 186);
}
else {
m.switchAnim = new EaseInOutQuad(200, 20, Direction.BACKWARDS);
m.switchColorRAnim = new EaseInOutQuad(200, 121, Direction.BACKWARDS);
m.switchColorGAnim = new EaseInOutQuad(200, 68, Direction.BACKWARDS);
m.switchColorBAnim = new EaseInOutQuad(200, 186, Direction.BACKWARDS);
}
} }
} }
} }
@ -271,6 +297,20 @@ public class ClickGuiRewrite extends GuiScreen {
searchCursorAnim = new EaseInOutQuad(300, 255); searchCursorAnim = new EaseInOutQuad(300, 255);
fr = mc.fontRendererObj; fr = mc.fontRendererObj;
partAnimation = new SimpleAnimation(0.0F); partAnimation = new SimpleAnimation(0.0F);
for (Mod m : Resent.INSTANCE.modManager.modules) {
if (m.isEnabled()) {
m.switchAnim = new EaseInOutQuad(200, 20);
m.switchColorRAnim = new EaseInOutQuad(200, 121);
m.switchColorGAnim = new EaseInOutQuad(200, 68);
m.switchColorBAnim = new EaseInOutQuad(200, 186);
}
else {
m.switchAnim = new EaseInOutQuad(200, 20, Direction.BACKWARDS);
m.switchColorRAnim = new EaseInOutQuad(200, 121, Direction.BACKWARDS);
m.switchColorGAnim = new EaseInOutQuad(200, 68, Direction.BACKWARDS);
m.switchColorBAnim = new EaseInOutQuad(200, 186, Direction.BACKWARDS);
}
}
} }
@Override @Override