Skip to content

Commit

Permalink
Periodic bug fixes. EventManager is faster and module list is cooler.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Jun 17, 2024
1 parent c49e0f2 commit ac69f4a
Show file tree
Hide file tree
Showing 21 changed files with 261 additions and 166 deletions.
1 change: 0 additions & 1 deletion src/main/java/dev/heliosclient/HeliosClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,5 @@ public void registerEvents() {
EventManager.register(TickRate.INSTANCE);
EventManager.register(DamageUtils.INSTANCE);
EventManager.register(RotationSimulator.INSTANCE);

}
}
1 change: 1 addition & 0 deletions src/main/java/dev/heliosclient/addon/AddonManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static void initializeAddons() {

public void loadAddons() {
HeliosClient.LOGGER.info("Loading Addons....");

// Get the current working directory
String currentWorkingDir = System.getProperty("user.dir");

Expand Down
103 changes: 86 additions & 17 deletions src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
import dev.heliosclient.managers.EventManager;
import dev.heliosclient.managers.ModuleManager;
import dev.heliosclient.module.Module_;
import dev.heliosclient.module.settings.BooleanSetting;
import dev.heliosclient.module.settings.CycleSetting;
import dev.heliosclient.module.settings.DoubleSetting;
import dev.heliosclient.module.settings.SettingGroup;
import dev.heliosclient.module.settings.*;
import dev.heliosclient.util.ColorUtils;
import dev.heliosclient.util.render.Renderer2D;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;

import java.awt.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import static dev.heliosclient.hud.hudelements.ModuleList.ColorMode.METEOR;
Expand Down Expand Up @@ -46,13 +45,49 @@ public class ModuleList extends HudElement implements Listener {
.build()
);
private final BooleanSetting background = sgSettings.add(new BooleanSetting.Builder()
.name("Render Background")
.description("Renders a gray background behind the text")
.name("Render Module Background")
.description("Renders a background behind the module name and info")
.onSettingChange(this)
.value(true)
.defaultValue(true)
.build()
);
public RGBASetting backgroundColor = sgSettings.add(new RGBASetting.Builder()
.name("Background Color")
.description("Color of the background")
.defaultValue(new Color(0x66222222))
.onSettingChange(this)
.shouldRender(()-> background.value)
.build());
private final BooleanSetting glow = sgSettings.add(new BooleanSetting.Builder()
.name("Render Glow")
.description("Renders a glow behind the text depending on the color of text")
.onSettingChange(this)
.defaultValue(false)
.shouldRender(()-> background.value)
.build()
);
private final CycleSetting glowMode = sgSettings.add(new CycleSetting.Builder()
.name("Glow Mode")
.description("Mode of glow")
.value(List.of(GlowMode.values()))
.onSettingChange(this)
.defaultListOption(GlowMode.LOW_BG_ALPHA)
.shouldRender(()-> glow.value && background.value)
.build()
);
private final DoubleSetting glowRadius = sgSettings.add(new DoubleSetting.Builder()
.name("Glow Radius")
.onSettingChange(this)
//For some reason the glowing breaks at radius less than 11
.min(5)
.max(50)
.roundingPlace(0)
.defaultValue(4d)
.shouldRender(() -> glow.value && background.value )
.build()
);

private final BooleanSetting sideLines = sgSettings.add(new BooleanSetting.Builder()
.name("Side Lines")
.description("Renders a vertical separator line side of the module name")
Expand All @@ -61,6 +96,16 @@ public class ModuleList extends HudElement implements Listener {
.defaultValue(true)
.build()
);
private final DoubleSetting distance = sgSettings.add(new DoubleSetting.Builder()
.name("Distance / Y offset")
.description("Distance between each module name (aka y offset")
.onSettingChange(this)
.min(0)
.max(10)
.roundingPlace(0)
.defaultValue(2d)
.build()
);
private final CycleSetting colorMode = sgSettings.add(new CycleSetting.Builder()
.name("Color Mode")
.description("Mode of the color displayed")
Expand All @@ -69,14 +114,15 @@ public class ModuleList extends HudElement implements Listener {
.defaultListOption(METEOR)
.build()
);

private final DoubleSetting rainbowSpeed = sgSettings.add(new DoubleSetting.Builder()
.name("Rainbow Speed")
.description("Speed of rainbow")
.onSettingChange(this)
.min(0.001d)
.max(0.2d)
.roundingPlace(3)
.value(0.05d)
.value(0.01d)
.shouldRender(() -> colorMode.getOption() == METEOR)
.build()
);
Expand All @@ -87,7 +133,8 @@ public class ModuleList extends HudElement implements Listener {
.min(0.001f)
.max(0.05f)
.roundingPlace(3)
.defaultValue(0.1d)
.defaultValue(0.017d)
.value(0.017d)
.shouldRender(() -> colorMode.getOption() == METEOR)
.build()
);
Expand Down Expand Up @@ -120,12 +167,18 @@ public class ModuleList extends HudElement implements Listener {
private double rainbowHue1;
private double rainbowHue2;

private Color colorToRenderIn = new Color(-1);

public ModuleList() {
super(DATA);
this.width = 50;
EventManager.register(this);
addSettingGroup(sgSettings);
removeSettingGroup(sgUI);

}

@Override
public void onLoad() {
}

@Override
Expand All @@ -149,6 +202,7 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
// Render each module with a different color
this.width = maxWidth + (sideLines.value ? 4 : 0);
int yOffset = this.y; // Start rendering from this.y

for (Module_ m : enabledModules) {
if (!m.showInModulesList.value) continue;

Expand All @@ -158,25 +212,36 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
if (colorMode.getOption() == METEOR) {
rainbowHue2 += rainbowSpread.value;
rainbow = new Color(Color.HSBtoRGB((float) rainbowHue2, (float) rainbowSaturation.value, (float) rainbowBrightness.value));
colorToRenderIn = rainbow;
}

float textX = x - (sideLines.value? 4: 0) + width - nameWidth;

if (background.value)
if (background.value) {
// Draw a background rectangle for each module
Renderer2D.drawRectangle(drawContext.getMatrices().peek().getPositionMatrix(),
textX - 2, yOffset, nameWidth + 4,
Math.round(Renderer2D.getStringHeight()) + 2, 0x66222222);
int bgColor = (glowMode.getOption() == GlowMode.LOW_BG_ALPHA) ? ColorUtils.changeAlpha(backgroundColor.getColor(),100).getRGB() : backgroundColor.getColor().getRGB();

if (glow.value) {
Renderer2D.drawRectangleWithShadow(drawContext.getMatrices(),
textX - 2, yOffset, nameWidth + 4,
Math.round(Renderer2D.getStringHeight()) + 2, bgColor, colorToRenderIn, (int) glowRadius.value);
} else {
Renderer2D.drawRectangle(drawContext.getMatrices().peek().getPositionMatrix(),
textX - 2, yOffset, nameWidth + 4,
Math.round(Renderer2D.getStringHeight()) + 2, bgColor);
}
}

if (sideLines.value)
// Draw a vertical separator line
Renderer2D.drawRectangle(drawContext.getMatrices().peek().getPositionMatrix(),
x - 2 + width, yOffset, 2,
Math.round(Renderer2D.getStringHeight()) + 3, rainbow.getRGB());
x - 2.3f + width, yOffset, 2,
Math.round(Renderer2D.getStringHeight()) + 3, colorToRenderIn.getRGB());

// Draw the module name
Renderer2D.drawString(drawContext.getMatrices(), m.name,
textX, 1 + yOffset,
rainbow.getRGB());
colorToRenderIn.getRGB());

//Render the module info
if (moduleInfo.value && !info.isEmpty()) {
Expand All @@ -186,7 +251,7 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
}


yOffset += Math.round(Renderer2D.getStringHeight()) + 2;
yOffset += (int) (Math.round(Renderer2D.getStringHeight()) + distance.value);
}
this.height = Math.max(yOffset - this.y + 2, 40);
}
Expand All @@ -213,5 +278,9 @@ public enum ColorMode {

public static HudElementData<ModuleList> DATA = new HudElementData<>("Module List", "Shows enabled modules", ModuleList::new);

public enum GlowMode{
LOW_BG_ALPHA,
NORMAL
}

}
72 changes: 50 additions & 22 deletions src/main/java/dev/heliosclient/managers/ColorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.heliosclient.event.events.TickEvent;
import dev.heliosclient.event.listener.Listener;
import dev.heliosclient.module.modules.render.GUI;
import dev.heliosclient.module.sysmodules.ClickGUI;
import dev.heliosclient.ui.clickgui.Tooltip;
import dev.heliosclient.util.ColorUtils;

Expand All @@ -13,6 +14,9 @@
public class ColorManager implements Listener {

public static final ColorManager INSTANCE = new ColorManager();

public static boolean SYNC_ACCENT = false;

//ClickGui
public final int clickGuiPrimary = new Color(17, 18, 19, 255).getRGB();
//Global
Expand Down Expand Up @@ -77,53 +81,77 @@ public int clickGuiPaneText() {
}
}

@SuppressWarnings("all")
@SubscribeEvent
public void onTick(TickEvent e) {
public void onTick(TickEvent.CLIENT e) {
if (HeliosClient.CLICKGUI == null) return;
ColorManager.SYNC_ACCENT = HeliosClient.CLICKGUI.syncAccentColor.value;



Tooltip.tooltip.mode = HeliosClient.CLICKGUI.TooltipMode.value;
Tooltip.tooltip.fixedPos = HeliosClient.CLICKGUI.TooltipPos.value;

//Sync accent color with the rest of the client.
//Hud color is synced in HUDModule.java
if(SYNC_ACCENT){
updateClickGuiSecondary(HeliosClient.CLICKGUI.AccentColor.getColor(), HeliosClient.CLICKGUI.AccentColor.isRainbow());

updatePrimaryGradients(HeliosClient.CLICKGUI.AccentColor.getColor(),HeliosClient.CLICKGUI.AccentColor.getColor());
return;
}



float hue = (System.currentTimeMillis() % 10000) / 10000f;

GUI gui = (ModuleManager.get(GUI.class));

if (ModuleManager.get(GUI.class).ColorMode.value == 0) {
this.primaryGradientStart = ModuleManager.get(GUI.class).staticColor.getColor();
this.primaryGradientEnd = ModuleManager.get(GUI.class).staticColor.getColor();

if (gui.ColorMode.value == 0) {
updatePrimaryGradients(gui.staticColor.getColor(),gui.staticColor.getColor());
}
if (ModuleManager.get(GUI.class).ColorMode.value == 1) {
switch (ModuleManager.get(GUI.class).GradientType.value) {
if (gui.ColorMode.value == 1) {
switch (gui.GradientType.value) {
case 0 -> {
this.primaryGradientStart = ColorUtils.getRainbowColor();
this.primaryGradientEnd = ColorUtils.getRainbowColor2();
updatePrimaryGradients(ColorUtils.getRainbowColor(),ColorUtils.getRainbowColor2());
}
case 1 -> {
this.primaryGradientStart = ColorUtils.getDaySkyColors(hue)[0];
this.primaryGradientEnd = ColorUtils.getDaySkyColors(hue)[1];
updatePrimaryGradients(ColorUtils.getDaySkyColors(hue)[0],ColorUtils.getDaySkyColors(hue)[1]);
}
case 2 -> {
this.primaryGradientStart = ColorUtils.getEveningSkyColors(hue)[0];
this.primaryGradientEnd = ColorUtils.getEveningSkyColors(hue)[1];
updatePrimaryGradients(ColorUtils.getEveningSkyColors(hue)[0],ColorUtils.getEveningSkyColors(hue)[1]);
}
case 3 -> {
this.primaryGradientStart = ColorUtils.getNightSkyColors(hue)[0];
this.primaryGradientEnd = ColorUtils.getNightSkyColors(hue)[1];
updatePrimaryGradients(ColorUtils.getNightSkyColors(hue)[0],ColorUtils.getNightSkyColors(hue)[1]);
}
case 4 -> {
this.primaryGradientStart = (ModuleManager.get(GUI.class)).linear2Start.getColor();
this.primaryGradientEnd = (ModuleManager.get(GUI.class)).linear2end.getColor();
updatePrimaryGradients(gui.linear2Start.getColor(),gui.linear2end.getColor());
}
}
}


this.clickGuiSecondaryAlpha = HeliosClient.CLICKGUI.AccentColor.getColor().getAlpha();
this.clickGuiSecondary = HeliosClient.CLICKGUI.AccentColor.getColor().getRGB();
this.clickGuiSecondaryRainbow = HeliosClient.CLICKGUI.AccentColor.isRainbow();
updateClickGuiSecondary(HeliosClient.CLICKGUI.AccentColor.getColor(), HeliosClient.CLICKGUI.AccentColor.isRainbow());

this.defaultTextColor = HeliosClient.CLICKGUI.TextColor.getColor().getRGB();

this.clickGuiPaneTextAlpha = HeliosClient.CLICKGUI.PaneTextColor.getColor().getAlpha();
this.clickGuiPaneText = HeliosClient.CLICKGUI.PaneTextColor.getColor().getRGB();
this.clickGuiPaneTextRainbow = HeliosClient.CLICKGUI.PaneTextColor.isRainbow();
updateClickGuiPaneText(HeliosClient.CLICKGUI.PaneTextColor.getColor(), HeliosClient.CLICKGUI.PaneTextColor.isRainbow());
}

public void updatePrimaryGradients(Color start, Color end){
this.primaryGradientStart = start;
this.primaryGradientEnd = end;
}

public void updateClickGuiSecondary(Color color, boolean rainbow){
this.clickGuiSecondaryAlpha = color.getAlpha();
this.clickGuiSecondary = color.getRGB();
this.clickGuiSecondaryRainbow = rainbow;
}
public void updateClickGuiPaneText(Color color, boolean rainbow){
this.clickGuiPaneTextAlpha = color.getAlpha();
this.clickGuiPaneText = color.getRGB();
this.clickGuiPaneTextRainbow = rainbow;
}
}
Loading

0 comments on commit ac69f4a

Please sign in to comment.