Skip to content

Commit

Permalink
UI + Settings cleanup. Added some additional mixins.
Browse files Browse the repository at this point in the history
  • Loading branch information
coltonk9043 committed Apr 2, 2024
1 parent e7c37eb commit 39be1bb
Show file tree
Hide file tree
Showing 55 changed files with 368 additions and 221 deletions.
54 changes: 54 additions & 0 deletions src/main/java/net/aoba/event/events/FoodLevelEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Aoba Hacked Client
* Copyright (C) 2019-2024 coltonk9043
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package net.aoba.event.events;

import java.util.ArrayList;
import java.util.List;

import net.aoba.event.listeners.AbstractListener;
import net.aoba.event.listeners.FoodLevelListener;
import net.aoba.event.listeners.PlayerHealthListener;
import net.minecraft.entity.damage.DamageSource;

public class FoodLevelEvent extends AbstractEvent {
private float foodLevel;

public FoodLevelEvent(float foodLevel) {
this.foodLevel = foodLevel;
}

public float getFoodLevel() {
return foodLevel;
}


@Override
public void Fire(ArrayList<? extends AbstractListener> listeners) {
for(AbstractListener listener : List.copyOf(listeners)) {
FoodLevelListener foodLevelListener = (FoodLevelListener) listener;
foodLevelListener.OnFoodLevelChanged(this);
}
}

@SuppressWarnings("unchecked")
@Override
public Class<FoodLevelListener> GetListenerClassType() {
return FoodLevelListener.class;
}
}
25 changes: 25 additions & 0 deletions src/main/java/net/aoba/event/listeners/FoodLevelListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Aoba Hacked Client
* Copyright (C) 2019-2024 coltonk9043
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package net.aoba.event.listeners;

import net.aoba.event.events.FoodLevelEvent;

public interface FoodLevelListener extends AbstractListener {
public abstract void OnFoodLevelChanged(FoodLevelEvent readPacketEvent);
}
2 changes: 1 addition & 1 deletion src/main/java/net/aoba/gui/AbstractGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void setAlwaysVisible(boolean state) {

public abstract void update();

public abstract void draw(DrawContext drawContext, float partialTicks, Color color);
public abstract void draw(DrawContext drawContext, float partialTicks);

@Override
public void OnLeftMouseDown(LeftMouseDownEvent event) {
Expand Down
42 changes: 14 additions & 28 deletions src/main/java/net/aoba/gui/GuiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,36 +71,30 @@ public class GuiManager implements LeftMouseDownListener, LeftMouseUpListener, K
public Page hudPane = new Page("Hud");

// Global HUD Settings
public ColorSetting color;
public ColorSetting borderColor;
public ColorSetting backgroundColor;
public static ColorSetting foregroundColor;
public static ColorSetting borderColor;
public static ColorSetting backgroundColor;

public FloatSetting effectSpeed = new FloatSetting("color_speed", "Effect Spd", 4, 1, 20, 0.1, null);
public FloatSetting effectSpeed = new FloatSetting("color_speed", "Effect Spd", 4f, 1f, 20f, 0.1f, null);
public BooleanSetting rainbow = new BooleanSetting("rainbow_mode", "Rainbow", false, null);
public BooleanSetting ah = new BooleanSetting("armorhud_toggle", "ArmorHUD", false, null);

private Color currentColor;

public ModuleSelectorHud moduleSelector;
public ArmorHud armorHud;
public RadarHud radarHud;
public InfoHud infoHud;

private RainbowColor rainbowColor;

public GuiManager() {
mc = MinecraftClient.getInstance();

borderColor = new ColorSetting("hud_border_color", "Color of the borders.", new Color(0, 0, 0));
backgroundColor = new ColorSetting("hud_background_color", "Color of the background.", new Color(0, 0, 0, 50));
color = new ColorSetting("hud_foreground_color", "The color of the HUD", new Color(1.0f, 1.0f, 1.0f));
currentColor = color.getValue();
rainbowColor = new RainbowColor();
foregroundColor = new ColorSetting("hud_foreground_color", "The color of the HUD", new Color(1.0f, 1.0f, 1.0f));
clickGuiNavBar = new NavigationBar();

SettingManager.registerSetting(borderColor, Aoba.getInstance().settingManager.config_category);
SettingManager.registerSetting(backgroundColor, Aoba.getInstance().settingManager.config_category);
SettingManager.registerSetting(color, Aoba.getInstance().settingManager.config_category);
SettingManager.registerSetting(foregroundColor, Aoba.getInstance().settingManager.config_category);
SettingManager.registerSetting(clickGuiButton, Aoba.getInstance().settingManager.modules_category);

Aoba.getInstance().eventManager.AddListener(KeyDownListener.class, this);
Expand Down Expand Up @@ -190,14 +184,6 @@ public void SetHudActive(AbstractHud hud, boolean state) {
* Getter for the current color used by the GUI for text rendering.
* @return Current Color
*/
public Color getColor() {
return this.currentColor;
}

public Color getOriginalColor() {
return this.color.getValue();
}

public void update() {
if(!Aoba.getInstance().isGhosted()){

Expand Down Expand Up @@ -225,12 +211,12 @@ public void update() {
* Updates the Color.
* TODO: Remove this and move to event-based.
*/
if(this.rainbow.getValue()) {
rainbowColor.update(this.effectSpeed.getValue().floatValue());
this.currentColor = rainbowColor.getColor();
}else {
this.currentColor = color.getValue();
}
//if(this.rainbow.getValue()) {
// rainbowColor.update(this.effectSpeed.getValue().floatValue());
// this.currentColor = rainbowColor.getColor();
//}else {
// this.currentColor = foregroundColor.getValue();
//}

//Aoba.getInstance().eventManager.Fire(new MouseScrollEvent(5.0f, 5.0f));
}
Expand All @@ -252,14 +238,14 @@ public void draw(DrawContext drawContext, float tickDelta) {
*/
if (this.clickGuiOpen) {
RenderUtils.drawBox(matrixStack, 0, 0, window.getWidth(), window.getHeight(), new Color(26, 26, 26, 100));
clickGuiNavBar.draw(drawContext, tickDelta, this.currentColor);
clickGuiNavBar.draw(drawContext, tickDelta);
}

// Render HUDS
if(!this.clickGuiOpen || this.clickGuiNavBar.getSelectedPage() == this.hudPane) {
for(AbstractGui hud : pinnedHuds.values()) {
if(hud.getVisible()) {
hud.draw(drawContext, tickDelta, this.currentColor);
hud.draw(drawContext, tickDelta);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/aoba/gui/NavigationBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void update() {
}
}

public void draw(DrawContext drawContext, float partialTicks, Color color) {
public void draw(DrawContext drawContext, float partialTicks) {
Window window = mc.getWindow();

int centerX = (window.getWidth() / 2);
Expand All @@ -81,17 +81,17 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) {
int width = 100 * options.size();

GuiManager hudManager = Aoba.getInstance().hudManager;
RenderUtils.drawRoundedBox(matrixStack, centerX - (width / 2), 25, width, 25, 6, hudManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, centerX - (width / 2), 25, width, 25, 6, hudManager.borderColor.getValue());
RenderUtils.drawRoundedBox(matrixStack, centerX - (width / 2), 25, width, 25, 6, GuiManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, centerX - (width / 2), 25, width, 25, 6, GuiManager.borderColor.getValue());

RenderUtils.drawRoundedBox(drawContext.getMatrices(), centerX - (width / 2) + (100 * this.selectedIndex), 25, 100, 25, 5, new Color(150, 150, 150, 100));

for(int i = 0; i < options.size(); i++) {
Page pane = options.get(i);
if(i == selectedIndex) {
pane.render(drawContext, partialTicks, color);
pane.render(drawContext, partialTicks);
}
RenderUtils.drawString(drawContext, pane.title, centerX - (width / 2) + 50 + (100 * i) - mc.textRenderer.getWidth(pane.title), 30, color);
RenderUtils.drawString(drawContext, pane.title, centerX - (width / 2) + 50 + (100 * i) - mc.textRenderer.getWidth(pane.title), 30, GuiManager.foregroundColor.getValue());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/aoba/gui/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public void update() {
}
}

public void render(DrawContext drawContext, float partialTicks, Color color) {
public void render(DrawContext drawContext, float partialTicks) {
if(this.isVisible) {
Iterator<AbstractGui> tabIterator = tabs.iterator();
while(tabIterator.hasNext()) {
tabIterator.next().draw(drawContext, partialTicks, color);
tabIterator.next().draw(drawContext, partialTicks);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/aoba/gui/hud/AbstractHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void update() {
}

@Override
public void draw(DrawContext drawContext, float partialTicks, Color color) {
public void draw(DrawContext drawContext, float partialTicks) {

}
}
3 changes: 1 addition & 2 deletions src/main/java/net/aoba/gui/hud/ArmorHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

package net.aoba.gui.hud;

import net.aoba.gui.Color;
import net.aoba.utils.types.Vector2;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.item.ItemStack;
Expand All @@ -43,7 +42,7 @@ public void update() {
}

@Override
public void draw(DrawContext drawContext, float partialTicks, Color color) {
public void draw(DrawContext drawContext, float partialTicks) {
if(this.visible) {
DefaultedList<ItemStack> armors = mc.player.getInventory().armor;

Expand Down
15 changes: 6 additions & 9 deletions src/main/java/net/aoba/gui/hud/InfoHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package net.aoba.gui.hud;

import net.aoba.Aoba;
import net.aoba.gui.Color;
import net.aoba.gui.GuiManager;
import net.aoba.misc.RenderUtils;
import net.aoba.utils.types.Vector2;
Expand Down Expand Up @@ -73,20 +71,19 @@ public void update() {
}

@Override
public void draw(DrawContext drawContext, float partialTicks, Color color) {
public void draw(DrawContext drawContext, float partialTicks) {
if(this.visible) {
MatrixStack matrixStack = drawContext.getMatrices();
// Draws background depending on components width and height

Vector2 pos = position.getValue();

GuiManager hudManager = Aoba.getInstance().hudManager;
RenderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height, 6, hudManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height, 6, hudManager.borderColor.getValue());
RenderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height, 6, GuiManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height, 6, GuiManager.borderColor.getValue());

RenderUtils.drawString(drawContext, positionText, pos.x + 5, pos.y + 4, color);
RenderUtils.drawString(drawContext, timeText, pos.x + 5, pos.y + 24, color);
RenderUtils.drawString(drawContext, fpsText, pos.x + 5, pos.y + 44, color);
RenderUtils.drawString(drawContext, positionText, pos.x + 5, pos.y + 4, GuiManager.foregroundColor.getValue());
RenderUtils.drawString(drawContext, timeText, pos.x + 5, pos.y + 24, GuiManager.foregroundColor.getValue());
RenderUtils.drawString(drawContext, fpsText, pos.x + 5, pos.y + 44, GuiManager.foregroundColor.getValue());
}
}
}
20 changes: 10 additions & 10 deletions src/main/java/net/aoba/gui/hud/ModuleSelectorHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void update() {
}

@Override
public void draw(DrawContext drawContext, float partialTicks, Color color) {
public void draw(DrawContext drawContext, float partialTicks) {
// Gets the client and window.
MinecraftClient mc = MinecraftClient.getInstance();
MatrixStack matrixStack = drawContext.getMatrices();
Expand All @@ -121,19 +121,19 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) {
Vector2 pos = position.getValue();

// Draws the top bar including "Aoba x.x"
RenderUtils.drawString(drawContext, "Aoba " + AobaClient.VERSION, 8, 8, color);
RenderUtils.drawString(drawContext, "Aoba " + AobaClient.VERSION, 8, 8, GuiManager.foregroundColor.getValue());

// Draws the table including all of the categories.
GuiManager hudManager = Aoba.getInstance().hudManager;
RenderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height * this.categories.length, 6f, hudManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height * this.categories.length, 6f, hudManager.borderColor.getValue());
RenderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height * this.categories.length, 6f, GuiManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height * this.categories.length, 6f, GuiManager.borderColor.getValue());

// For every category, draw a cell for it.
for (int i = 0; i < this.categories.length; i++) {
RenderUtils.drawString(drawContext, ">>", pos.x + width - 24, pos.y + (height * i) + 8, color);
RenderUtils.drawString(drawContext, ">>", pos.x + width - 24, pos.y + (height * i) + 8, GuiManager.foregroundColor.getValue());
// Draws the name of the category dependent on whether it is selected.
if (this.index == i) {
RenderUtils.drawString(drawContext, "> " + this.categories[i].name(), pos.x + 8, pos.y + (height * i) + 8, color);
RenderUtils.drawString(drawContext, "> " + this.categories[i].name(), pos.x + 8, pos.y + (height * i) + 8, GuiManager.foregroundColor.getValue());
} else {
RenderUtils.drawString(drawContext, this.categories[i].name(), pos.x + 8, pos.y + (height * i) + 8, 0xFFFFFF);
}
Expand All @@ -142,15 +142,15 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) {
// If any particular category menu is open.
if (isCategoryMenuOpen) {
// Draw the table underneath
RenderUtils.drawRoundedBox(matrixStack, pos.x + width, pos.y + (height * this.index), 165, height * modules.size(), 6f, hudManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, pos.x + width, pos.y + (height * this.index), 165, height * modules.size(), 6f, hudManager.borderColor.getValue());
RenderUtils.drawRoundedBox(matrixStack, pos.x + width, pos.y + (height * this.index), 165, height * modules.size(), 6f, GuiManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, pos.x + width, pos.y + (height * this.index), 165, height * modules.size(), 6f, GuiManager.borderColor.getValue());

// For every mod, draw a cell for it.
for (int i = 0; i < modules.size(); i++) {
if (this.indexMods == i) {
RenderUtils.drawString(drawContext, "> " + modules.get(i).getName(), pos.x + width + 5,
pos.y + (i * height) + (this.index * height) + 8,
modules.get(i).getState() ? 0x00FF00 : color.getColorAsInt());
modules.get(i).getState() ? 0x00FF00 : GuiManager.foregroundColor.getValue().getColorAsInt());
} else {
RenderUtils.drawString(drawContext, modules.get(i).getName(), pos.x + width + 5,
pos.y + (i * height) + (this.index * height) + 8,
Expand All @@ -166,7 +166,7 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) {
if(mod.getState()) {
RenderUtils.drawString(drawContext, mod.getName(),
(float) (window.getWidth() - ((mc.textRenderer.getWidth(mod.getName()) + 5) * 2)), 10 + (iteration*20),
color.getColorAsInt());
GuiManager.foregroundColor.getValue().getColorAsInt());
iteration++;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/aoba/gui/hud/RadarHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ public RadarHud( int x, int y, int width, int height) {
}

@Override
public void draw(DrawContext drawContext, float partialTicks, Color color) {
public void draw(DrawContext drawContext, float partialTicks) {
if(this.visible) {
MatrixStack matrixStack = drawContext.getMatrices();

Vector2 pos = position.getValue();

// Draws background depending on components width and height
GuiManager hudManager = Aoba.getInstance().hudManager;
RenderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height, 6, hudManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height, 6, hudManager.borderColor.getValue());
RenderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height, 6, GuiManager.backgroundColor.getValue());
RenderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height, 6, GuiManager.borderColor.getValue());

// Draw the 'Radar'
RenderUtils.drawBox(matrixStack, pos.x , pos.y + (height / 2), width - 1, 1, new Color(128,128,128, 255));
RenderUtils.drawBox(matrixStack, pos.x + (width / 2), pos.y, 1, height, new Color(128,128,128, 255));
RenderUtils.drawBox(matrixStack, pos.x + (width / 2) - 2, pos.y + (height / 2) - 2, 5, 5, Aoba.getInstance().hudManager.getColor());
RenderUtils.drawBox(matrixStack, pos.x + (width / 2) - 2, pos.y + (height / 2) - 2, 5, 5, GuiManager.foregroundColor.getValue());

float sin_theta = (float) Math.sin(Math.toRadians(-mc.player.getRotationClient().y));
float cos_theta = (float) Math.cos(Math.toRadians(-mc.player.getRotationClient().y));
Expand Down Expand Up @@ -101,7 +101,7 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) {
float radius_y = (float)((sin_theta * (fake_x - center_x)) + (cos_theta * (fake_y - center_y))) + center_y;

RenderUtils.drawBox(matrixStack, (int)(Math.min(pos.x + width - 5, Math.max(pos.x, radius_x))), (int)(Math.min(pos.y + 25 + height, Math.max(pos.y, radius_y))), 3, 3, new Color(255, 255, 255, 255));
RenderUtils.drawStringWithScale(drawContext, entity.getName().getString(), (int)(Math.min(pos.x + width - 5, Math.max(pos.x, radius_x))) - (mc.textRenderer.getWidth(entity.getName()) * 0.5f), (int)(Math.min(pos.y + 25 + height, Math.max(pos.y, radius_y))) - 10, color, 1.0f);
RenderUtils.drawStringWithScale(drawContext, entity.getName().getString(), (int)(Math.min(pos.x + width - 5, Math.max(pos.x, radius_x))) - (mc.textRenderer.getWidth(entity.getName()) * 0.5f), (int)(Math.min(pos.y + 25 + height, Math.max(pos.y, radius_y))) - 10, GuiManager.foregroundColor.getValue(), 1.0f);
}
}
}
Expand Down
Loading

0 comments on commit 39be1bb

Please sign in to comment.