vastly improve the hud

This commit is contained in:
Saturn5Vfive 2022-03-19 01:35:07 -05:00
parent fce9226b6b
commit 1ef0c10cf3
9 changed files with 135 additions and 12 deletions

View file

@ -75,6 +75,7 @@ public class HudRenderer {
he.add(new SpeedHud());
he.add(new TabGui());
he.add(new InfoHUD());
he.add(new ModuleList());
return he;
}

View file

@ -65,12 +65,12 @@ public abstract class HudElement {
FontRenderers.getRenderer().drawString(Renderer.R3D.getEmptyMatrixStack(), id, posX, rpoY, 0xFFFFFF);
}
public abstract void renderIntern(MatrixStack stack);
public abstract void renderIntern(MatrixStack stack, double posX2, double posY2);
public void render() {
stack.push();
stack.translate(posX, posY, 0);
renderIntern(stack);
renderIntern(stack, posX, posY);
stack.pop();
}

View file

@ -4,10 +4,15 @@
package net.shadow.client.feature.gui.hud.element;
import java.util.List;
import net.minecraft.client.util.math.MatrixStack;
import net.shadow.client.ShadowMain;
import net.shadow.client.feature.module.ModuleRegistry;
import net.shadow.client.feature.module.impl.render.Hud;
import net.shadow.client.helper.render.MSAAFramebuffer;
import net.shadow.client.mixin.IDebugHudAccessor;
import net.shadow.client.mixin.IInGameHudAccessor;
public class InfoHUD extends HudElement {
net.shadow.client.feature.module.impl.render.TabGui tgui;
@ -18,8 +23,26 @@ public class InfoHUD extends HudElement {
@Override
public void renderIntern(MatrixStack stack) {
public void renderIntern(MatrixStack stack, double px, double py) {
stack.push();
double heightOffsetLeft = 0, heightOffsetRight = 0;
if (ShadowMain.client.options.debugEnabled) {
double heightAccordingToMc = 9;
List<String> lt = ((IDebugHudAccessor) ((IInGameHudAccessor) ShadowMain.client.inGameHud).getDebugHud()).callGetLeftText();
List<String> rt = ((IDebugHudAccessor) ((IInGameHudAccessor) ShadowMain.client.inGameHud).getDebugHud()).callGetRightText();
heightOffsetLeft = 2 + heightAccordingToMc * (lt.size() + 3);
heightOffsetRight = 2 + heightAccordingToMc * rt.size() + 5;
}
double oneThird = ShadowMain.client.getWindow().getWidth() / 6;
if(px < oneThird){
if(py < heightOffsetLeft){
stack.translate(0, heightOffsetLeft - py, 0);
}
}else if (px > oneThird * 2){
if(py < heightOffsetRight){
stack.translate(0, heightOffsetRight- py, 0);
}
}
ModuleRegistry.getByClass(Hud.class).drawTopLeft(stack);
stack.pop();
}

View file

@ -0,0 +1,50 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.feature.gui.hud.element;
import java.util.List;
import net.minecraft.client.util.math.MatrixStack;
import net.shadow.client.ShadowMain;
import net.shadow.client.feature.module.ModuleRegistry;
import net.shadow.client.feature.module.impl.render.Hud;
import net.shadow.client.helper.font.FontRenderers;
import net.shadow.client.helper.render.MSAAFramebuffer;
import net.shadow.client.mixin.IDebugHudAccessor;
import net.shadow.client.mixin.IInGameHudAccessor;
public class ModuleList extends HudElement {
net.shadow.client.feature.module.impl.render.TabGui tgui;
public ModuleList() {
super("Modules", 5, 5, 55, 100);
}
@Override
public void renderIntern(MatrixStack stack, double px, double py) {
stack.push();
double heightOffsetLeft = 0, heightOffsetRight = 0;
if (ShadowMain.client.options.debugEnabled) {
double heightAccordingToMc = 9;
List<String> lt = ((IDebugHudAccessor) ((IInGameHudAccessor) ShadowMain.client.inGameHud).getDebugHud()).callGetLeftText();
List<String> rt = ((IDebugHudAccessor) ((IInGameHudAccessor) ShadowMain.client.inGameHud).getDebugHud()).callGetRightText();
heightOffsetLeft = 2 + heightAccordingToMc * (lt.size() + 3);
heightOffsetRight = 2 + heightAccordingToMc * rt.size() + 5;
}
double oneThird = ShadowMain.client.getWindow().getWidth() / 6;
if(px < oneThird){
if(py < heightOffsetLeft){
stack.translate(0, heightOffsetLeft - py, 0);
}
}else if (px > oneThird * 2){
if(py < heightOffsetRight){
stack.translate(0, heightOffsetRight- py, 0);
}
}
ModuleRegistry.getByClass(Hud.class).drawModuleList(stack, px, py);
stack.pop();
}
}

View file

@ -26,7 +26,7 @@ public class SpeedHud extends HudElement {
}
@Override
public void renderIntern(MatrixStack stack) {
public void renderIntern(MatrixStack stack, double px, double py) {
if (ModuleRegistry.getByClass(Hud.class).speed.getValue()) {
double size = speedSaved.size();
double incrX = width / (size - 1);

View file

@ -4,10 +4,15 @@
package net.shadow.client.feature.gui.hud.element;
import java.util.List;
import net.minecraft.client.util.math.MatrixStack;
import net.shadow.client.ShadowMain;
import net.shadow.client.feature.module.ModuleRegistry;
import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.font.FontRenderers;
import net.shadow.client.mixin.IDebugHudAccessor;
import net.shadow.client.mixin.IInGameHudAccessor;
public class TabGui extends HudElement {
net.shadow.client.feature.module.impl.render.TabGui tgui;
@ -28,8 +33,26 @@ public class TabGui extends HudElement {
}
@Override
public void renderIntern(MatrixStack stack) {
public void renderIntern(MatrixStack stack, double px, double py) {
stack.push();
double heightOffsetLeft = 0, heightOffsetRight = 0;
if (ShadowMain.client.options.debugEnabled) {
double heightAccordingToMc = 9;
List<String> lt = ((IDebugHudAccessor) ((IInGameHudAccessor) ShadowMain.client.inGameHud).getDebugHud()).callGetLeftText();
List<String> rt = ((IDebugHudAccessor) ((IInGameHudAccessor) ShadowMain.client.inGameHud).getDebugHud()).callGetRightText();
heightOffsetLeft = 2 + heightAccordingToMc * (lt.size() + 3);
heightOffsetRight = 2 + heightAccordingToMc * rt.size() + 5;
}
double oneThird = ShadowMain.client.getWindow().getWidth() / 6;
if(px < oneThird){
if(py < heightOffsetLeft){
stack.translate(0, heightOffsetLeft, 0);
}
}else if (px > oneThird * 2){
if(py < heightOffsetRight){
stack.translate(0, heightOffsetRight, 0);
}
}
getTgui().render(stack);
stack.pop();
}

View file

@ -18,7 +18,7 @@ public class Taco extends HudElement {
}
@Override
public void renderIntern(MatrixStack stack) {
public void renderIntern(MatrixStack stack, double px, double py) {
if (!net.shadow.client.feature.command.impl.Taco.config.enabled) {
return;
}

View file

@ -17,7 +17,7 @@ public class TargetHUD extends HudElement {
}
@Override
public void renderIntern(MatrixStack stack) {
public void renderIntern(MatrixStack stack, double px, double py) {
ModuleRegistry.getByClass(TargetHud.class).draw(stack);
}
}

View file

@ -35,6 +35,11 @@ import net.shadow.client.mixin.IInGameHudAccessor;
import net.shadow.client.mixin.IMinecraftClientAccessor;
import java.awt.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -162,7 +167,7 @@ public class Hud extends Module {
if (modules.getValue()) {
ms.push();
ms.translate(0, heightOffsetRight, 0);
drawModuleList(ms);
//drawModuleList(ms);
ms.pop();
}
@ -232,9 +237,11 @@ public class Hud extends Module {
FontRenderers.getRenderer().drawCenteredString(ms, drawStr, widgetX + widgetWidth / 2d, widgetY + 3 + imgHeight + 3, 0xAAAAAA);
}
void drawModuleList(MatrixStack ms) {
public void drawModuleList(MatrixStack ms, double posX, double posY){
posX += 55;
double width = ShadowMain.client.getWindow().getScaledWidth();
double y = 0;
double whalf = width / 4;
for (ModuleEntry moduleEntry : moduleList.stream().sorted(Comparator.comparingDouble(value -> -value.getRenderWidth())).toList()) {
double prog = moduleEntry.getAnimProg() * 2;
if (prog == 0) {
@ -244,17 +251,36 @@ public class Hud extends Module {
double slideProg = MathHelper.clamp(prog - 1, 0, 1); // 1-2 as 0-1 from 0-2
double hei = (FontRenderers.getRenderer().getMarginHeight() + 2);
double wid = moduleEntry.getRenderWidth() + 2;
Renderer.R2D.renderQuad(ms, ThemeManager.getMainTheme().getActive(), width - (wid + 1), y, width, y + hei * expandProg);
ms.push();
ms.translate((1 - slideProg) * wid, 0, 0);
//time for some hacker tier byte shit
//--BEGIN BYTE FUCKARY--
/*ByteArrayOutputStream bar = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bar);
os.writeObject((Object)ms);
os.flush();
byte[] matrix = bar.toByteArray();
ByteArrayInputStream bir = new ByteArrayInputStream(matrix);
ObjectInputStream input = new ObjectInputStream(bir);
MatrixStack b = (MatrixStack)input.readObject();*/
//--END BYTE FUCKARY--
//was gonna try harder on this but realised it looks better without it anyways :D
ms.translate(-ShadowMain.client.getWindow().getScaledWidth() + ((1 - slideProg) * wid) + 55, (posY > whalf) ? 85 : 0, 0);
Renderer.R2D.renderQuad(ms, ThemeManager.getMainTheme().getActive(), width - (wid + 1), y, width, y + hei * expandProg);
Renderer.R2D.beginScissor(0, 0, posX, ShadowMain.client.getWindow().getScaledHeight()); //wait holy shit this WORKS???!?!? Im supposed to be shit at rendering!
Renderer.R2D.renderQuad(ms, ThemeManager.getMainTheme().getModule(), width - wid, y, width, y + hei * expandProg);
double nameW = FontRenderers.getRenderer().getStringWidth(moduleEntry.module.getName());
FontRenderers.getRenderer().drawString(ms, moduleEntry.module.getName(), width - wid + 1, y + 1, 0xFFFFFF);
if (moduleEntry.module.getContext() != null && !moduleEntry.module.getContext().isEmpty()) {
FontRenderers.getRenderer().drawString(ms, " " + moduleEntry.module.getContext(), width - wid + 1 + nameW, y + 1, 0xAAAAAA);
}
Renderer.R2D.endScissor();
ms.pop();
y += hei * expandProg;
if(posY > whalf){
y -= hei * expandProg;
}else{
y += hei * expandProg;
}
}
}