Skip to content

Commit

Permalink
fix background manager and prepare glide for a big change
Browse files Browse the repository at this point in the history
gatooooooo committed Dec 31, 2024
1 parent c192bfd commit edbc053
Showing 48 changed files with 163 additions and 156 deletions.
22 changes: 11 additions & 11 deletions src/main/java/me/eldodebug/soar/gui/GuiGameMenu.java
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import me.eldodebug.soar.Glide;
import me.eldodebug.soar.management.nanovg.NanoVGManager;
import me.eldodebug.soar.management.nanovg.font.Fonts;
import me.eldodebug.soar.management.nanovg.font.Icon;
import me.eldodebug.soar.management.nanovg.font.LegacyIcon;
import me.eldodebug.soar.utils.animation.normal.Animation;
import me.eldodebug.soar.utils.animation.normal.Direction;
import me.eldodebug.soar.utils.animation.normal.easing.EaseInOutCirc;
@@ -57,32 +57,32 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {

private void drawNanoVG(NanoVGManager nvg) {
nvg.drawRect(-5, -5, scaledWidth + 10, scaledHeight + 10, new Color(0,0,0, 140));
nvg.drawText(Icon.ARROW_LEFT, x, y + 5, new Color(255,255,255, 140),11, Fonts.ICON);
nvg.drawCenteredText("Game Menu", centre, y + 5, new Color(255,255,255, 200), 13, Fonts.MEDIUM);
nvg.drawText(LegacyIcon.ARROW_LEFT, x, y + 5, new Color(255,255,255, 140),11, Fonts.LEGACYICON);
nvg.drawCenteredText("Game Menu", centre, y + 5, new Color(255,255,255, 200), 13, Fonts.DEMIBOLD);

float standardPadding = 29.5f;
float offset = 29.5F;
drawButton(nvg, "Minecraft Options", Icon.SLIDERS, offset);
drawButton(nvg, "Minecraft Options", LegacyIcon.SLIDERS, offset);
offset += standardPadding;
if(this.mc.isSingleplayer() && !this.mc.getIntegratedServer().getPublic()){
drawButton(nvg, "Open to Lan", Icon.USERS, offset);
drawButton(nvg, "Open to Lan", LegacyIcon.USERS, offset);
} else {
drawButton(nvg, "Edit Hud", Icon.LAYOUT, offset);
drawButton(nvg, "Edit Hud", LegacyIcon.LAYOUT, offset);
}
offset += standardPadding;
drawButton(nvg, "Statistics", Icon.ARCHIVE, offset);
drawButton(nvg, "Statistics", LegacyIcon.ARCHIVE, offset);
offset += standardPadding;
drawButton(nvg, "Achievements", Icon.MAP, offset);
drawButton(nvg, "Achievements", LegacyIcon.MAP, offset);
offset += standardPadding;
drawButton(nvg, "Open Glide Menu", Icon.SOAR, offset);
drawButton(nvg, "Open Glide Menu", LegacyIcon.SOAR, offset);
offset += standardPadding;
drawButton(nvg, !this.mc.isIntegratedServerRunning() ? "Disconnect" : "Return to Main Menu", Icon.LOGOUT, offset);
drawButton(nvg, !this.mc.isIntegratedServerRunning() ? "Disconnect" : "Return to Main Menu", LegacyIcon.LOGOUT, offset);
}

private void drawButton(NanoVGManager nvg, String s, String i, Float offset){
nvg.drawRoundedRect(x, y + offset, width , 22, 6, new Color(230, 230, 230, 80));
float startX = (nvg.getTextWidth(s, 9.5F, Fonts.MEDIUM) + 14) /2;
nvg.drawText(i, centre - startX, y + offset + 5.5F, Color.WHITE, 9.5F, Fonts.ICON);
nvg.drawText(i, centre - startX, y + offset + 5.5F, Color.WHITE, 9.5F, Fonts.LEGACYICON);
nvg.drawText(s, centre - startX + 14, y + offset + 7F, Color.WHITE, 9.5F, Fonts.MEDIUM);
}

4 changes: 2 additions & 2 deletions src/main/java/me/eldodebug/soar/gui/GuiSplashScreen.java
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
import me.eldodebug.soar.Glide;
import me.eldodebug.soar.management.nanovg.NanoVGManager;
import me.eldodebug.soar.management.nanovg.font.Fonts;
import me.eldodebug.soar.management.nanovg.font.Icon;
import me.eldodebug.soar.management.nanovg.font.LegacyIcon;
import me.eldodebug.soar.utils.GlUtils;
import me.eldodebug.soar.utils.animation.normal.Animation;
import me.eldodebug.soar.utils.animation.normal.Direction;
@@ -64,7 +64,7 @@ public void draw() {

nvg.setupAndDraw(() -> {
nvg.drawRect(0, 0, sr.getScaledWidth(), sr.getScaledHeight(), Color.BLACK);
nvg.drawCenteredText(Icon.SOAR, sr.getScaledWidth() / 2, (sr.getScaledHeight() / 2) - (nvg.getTextHeight(Icon.SOAR, 130, Fonts.ICON) / 2) - 1, new Color(255, 255, 255, (int) (fadeAnimation.getValue() * 255)), 130, Fonts.ICON);
nvg.drawCenteredText(LegacyIcon.SOAR, sr.getScaledWidth() / 2, (sr.getScaledHeight() / 2) - (nvg.getTextHeight(LegacyIcon.SOAR, 130, Fonts.LEGACYICON) / 2) - 1, new Color(255, 255, 255, (int) (fadeAnimation.getValue() * 255)), 130, Fonts.LEGACYICON);
});

framebuffer.unbindFramebuffer();
6 changes: 3 additions & 3 deletions src/main/java/me/eldodebug/soar/gui/GuiWaypoint.java
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
import me.eldodebug.soar.management.color.palette.ColorType;
import me.eldodebug.soar.management.nanovg.NanoVGManager;
import me.eldodebug.soar.management.nanovg.font.Fonts;
import me.eldodebug.soar.management.nanovg.font.Icon;
import me.eldodebug.soar.management.nanovg.font.LegacyIcon;
import me.eldodebug.soar.management.waypoint.Waypoint;
import me.eldodebug.soar.management.waypoint.WaypointManager;
import me.eldodebug.soar.ui.comp.impl.field.CompTextBox;
@@ -102,7 +102,7 @@ private void drawNanoVG(int mouseX, int mouseY, float partialTicks) {
nvg.drawRoundedRect(x + 16, y + 14 + offsetY + 26, 18, 18, 4, waypoint.getColor());
nvg.drawText(waypoint.getName(), x + 40, y + 45.5F + offsetY, palette.getFontColor(ColorType.DARK), 9.5F, Fonts.REGULAR);

nvg.drawText(Icon.TRASH, x + 162, y + 44 + offsetY, palette.getMaterialRed(), 11, Fonts.ICON);
nvg.drawText(LegacyIcon.TRASH, x + 162, y + 44 + offsetY, palette.getMaterialRed(), 11, Fonts.LEGACYICON);

offsetY+=38;
index++;
@@ -125,7 +125,7 @@ private void drawNanoVG(int mouseX, int mouseY, float partialTicks) {
nvg.drawRoundedRect(x + width - 120 + offsetX, y + 84 + offsetY, 13, 13, 2, c);

if(currentColor.equals(c)) {
nvg.drawText(Icon.CHECK, x + width - 118 + offsetX, y + 86.5F + offsetY, Color.WHITE, 9, Fonts.ICON);
nvg.drawText(LegacyIcon.CHECK, x + width - 118 + offsetX, y + 86.5F + offsetY, Color.WHITE, 9, Fonts.LEGACYICON);
}

offsetX+=17;
17 changes: 7 additions & 10 deletions src/main/java/me/eldodebug/soar/gui/mainmenu/GuiGlideMainMenu.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.eldodebug.soar.gui.mainmenu;

import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

@@ -12,11 +11,10 @@
import me.eldodebug.soar.Glide;
import me.eldodebug.soar.gui.mainmenu.impl.BackgroundScene;
import me.eldodebug.soar.gui.mainmenu.impl.MainScene;
import me.eldodebug.soar.management.color.palette.ColorPalette;
import me.eldodebug.soar.management.event.impl.EventRenderNotification;
import me.eldodebug.soar.management.nanovg.NanoVGManager;
import me.eldodebug.soar.management.nanovg.font.Fonts;
import me.eldodebug.soar.management.nanovg.font.Icon;
import me.eldodebug.soar.management.nanovg.font.LegacyIcon;
import me.eldodebug.soar.management.profile.mainmenu.impl.Background;
import me.eldodebug.soar.management.profile.mainmenu.impl.CustomBackground;
import me.eldodebug.soar.management.profile.mainmenu.impl.DefaultBackground;
@@ -27,7 +25,6 @@
import me.eldodebug.soar.utils.mouse.MouseUtils;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.ResourceLocation;

public class GuiGlideMainMenu extends GuiScreen {

@@ -137,32 +134,32 @@ private void drawButtons(int mouseX, int mouseY, ScaledResolution sr, NanoVGMana
closeFocusAnimation.setAnimation(MouseUtils.isInside(mouseX, mouseY, sr.getScaledWidth() - 28, 6, 22, 22) ? 1.0F : 0.0F, 16);

nvg.drawRoundedRect(sr.getScaledWidth() - 28, 6, 22, 22, 4, this.getBackgroundColor());
nvg.drawCenteredText(Icon.X, sr.getScaledWidth() - 19F, 8F, new Color(255, 255 - (int) (closeFocusAnimation.getValue() * 200), 255 - (int) (closeFocusAnimation.getValue() * 200)), 18, Fonts.ICON);
nvg.drawCenteredText(LegacyIcon.X, sr.getScaledWidth() - 19F, 8F, new Color(255, 255 - (int) (closeFocusAnimation.getValue() * 200), 255 - (int) (closeFocusAnimation.getValue() * 200)), 18, Fonts.LEGACYICON);

backgroundSelectFocusAnimation.setAnimation(MouseUtils.isInside(mouseX, mouseY, sr.getScaledWidth() - 28 - 28, 6, 22, 22) ? 1.0F : 0.0F, 16);

nvg.drawRoundedRect(sr.getScaledWidth() - 28 - 28, 6, 22, 22, 4, this.getBackgroundColor());
nvg.drawCenteredText(Icon.IMAGE, sr.getScaledWidth() - 19F - 26.5F, 9.5F, new Color(255 - (int) (backgroundSelectFocusAnimation.getValue() * 200), 255, 255 - (int) (backgroundSelectFocusAnimation.getValue() * 200)), 15, Fonts.ICON);
nvg.drawCenteredText(LegacyIcon.IMAGE, sr.getScaledWidth() - 19F - 26.5F, 9.5F, new Color(255 - (int) (backgroundSelectFocusAnimation.getValue() * 200), 255, 255 - (int) (backgroundSelectFocusAnimation.getValue() * 200)), 15, Fonts.LEGACYICON);
}

private void drawSplashScreen(ScaledResolution sr, NanoVGManager nvg) {

if(fadeIconAnimation == null) {
fadeIconAnimation = new DecelerateAnimation(1000, 1);
fadeIconAnimation = new DecelerateAnimation(100, 1);
fadeIconAnimation.setDirection(Direction.FORWARDS);
fadeIconAnimation.reset();
}

if(fadeIconAnimation != null) {

if(fadeIconAnimation.isDone(Direction.FORWARDS) && fadeBackgroundAnimation == null) {
fadeBackgroundAnimation = new DecelerateAnimation(1000, 1);
fadeBackgroundAnimation = new DecelerateAnimation(500, 1);
fadeBackgroundAnimation.setDirection(Direction.FORWARDS);
fadeBackgroundAnimation.reset();
}

nvg.drawRect(0, 0, sr.getScaledWidth(), sr.getScaledHeight(), new Color(0, 0, 0, fadeBackgroundAnimation != null ? (int) (255 - (fadeBackgroundAnimation.getValue() * 255)) : 255));
nvg.drawCenteredText(Icon.SOAR, sr.getScaledWidth() / 2, (sr.getScaledHeight() / 2) - (nvg.getTextHeight(Icon.SOAR, 130, Fonts.ICON) / 2) - 1, new Color(255, 255, 255, (int) (255 - (fadeIconAnimation.getValue() * 255))), 130, Fonts.ICON);
nvg.drawCenteredText(LegacyIcon.SOAR, sr.getScaledWidth() / 2, (sr.getScaledHeight() / 2) - (nvg.getTextHeight(LegacyIcon.SOAR, 130, Fonts.LEGACYICON) / 2) - 1, new Color(255, 255, 255, (int) (255 - (fadeIconAnimation.getValue() * 255))), 130, Fonts.LEGACYICON);
}
}

@@ -181,7 +178,7 @@ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
mc.shutdown();
}

if(MouseUtils.isInside(mouseX, mouseY, sr.getScaledWidth() - 28 - 28, 6, 22, 22)) {
if(MouseUtils.isInside(mouseX, mouseY, sr.getScaledWidth() - 28 - 28, 6, 22, 22) && !this.getCurrentScene().equals(getSceneByClass(BackgroundScene.class))) {
this.setCurrentScene(this.getSceneByClass(BackgroundScene.class));
}

Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
import java.io.File;
import java.io.IOException;

import me.eldodebug.soar.utils.animation.normal.Animation;
import me.eldodebug.soar.utils.animation.normal.Direction;
import me.eldodebug.soar.utils.animation.normal.easing.EaseInOutCirc;
import me.eldodebug.soar.utils.buffer.ScreenAnimation;
import org.lwjgl.input.Keyboard;

import me.eldodebug.soar.Glide;
@@ -14,8 +18,7 @@
import me.eldodebug.soar.management.language.TranslateText;
import me.eldodebug.soar.management.nanovg.NanoVGManager;
import me.eldodebug.soar.management.nanovg.font.Fonts;
import me.eldodebug.soar.management.nanovg.font.Icon;
import me.eldodebug.soar.management.notification.NotificationType;
import me.eldodebug.soar.management.nanovg.font.LegacyIcon;
import me.eldodebug.soar.management.profile.mainmenu.BackgroundManager;
import me.eldodebug.soar.management.profile.mainmenu.impl.Background;
import me.eldodebug.soar.management.profile.mainmenu.impl.CustomBackground;
@@ -28,19 +31,27 @@

public class BackgroundScene extends MainMenuScene {

private Animation introAnimation;
private final ScreenAnimation screenAnimation = new ScreenAnimation();
private Scroll scroll = new Scroll();

public BackgroundScene(GuiGlideMainMenu parent) {
super(parent);
public BackgroundScene(GuiGlideMainMenu parent) {super(parent);}

@Override
public void initScene() {
introAnimation = new EaseInOutCirc(250, 1.0F);
introAnimation.setDirection(Direction.FORWARDS);
}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
ScaledResolution sr = new ScaledResolution(mc);
Glide instance = Glide.getInstance();
NanoVGManager nvg = instance.getNanoVGManager();

nvg.setupAndDraw(() -> drawNanoVG(mouseX, mouseY, sr, instance, nvg));
screenAnimation.wrap(() -> drawNanoVG(mouseX, mouseY, sr, instance, nvg), 0, 0, sr.getScaledWidth(), sr.getScaledHeight(), 2 - introAnimation.getValueFloat(), Math.min(introAnimation.getValueFloat(), 1), false);
if(introAnimation.isDone(Direction.BACKWARDS)) {
this.setCurrentScene(this.getSceneByClass(MainScene.class));
}
}

private void drawNanoVG(int mouseX, int mouseY, ScaledResolution sr, Glide instance, NanoVGManager nvg) {
@@ -60,8 +71,7 @@ private void drawNanoVG(int mouseX, int mouseY, ScaledResolution sr, Glide insta
scroll.onAnimation();

nvg.drawRoundedRect(acX, acY, acWidth, acHeight, 8, this.getBackgroundColor());
nvg.drawRect(acX, acY + 24, acWidth, 0.8F, Color.WHITE);
nvg.drawCenteredText(TranslateText.SELECT_BACKGROUND.getText(), acX + (acWidth / 2), acY + 8, Color.WHITE, 14, Fonts.REGULAR);
nvg.drawCenteredText(TranslateText.SELECT_BACKGROUND.getText(), acX + (acWidth / 2), acY + 8, Color.WHITE, 14, Fonts.DEMIBOLD);

nvg.save();
nvg.scissor(acX, acY + 25, acWidth, acHeight - 25);
@@ -77,7 +87,7 @@ private void drawNanoVG(int mouseX, int mouseY, ScaledResolution sr, Glide insta
// Draw selection highlight and glow effect
if(isSelected) {
// Outer glow
nvg.drawRoundedRect(itemX - 3, itemY - 3, itemWidth + 6, itemHeight + 6, 8, new Color(255, 255, 255, 40));
nvg.drawGradientShadow(itemX - 1, itemY - 1, itemWidth + 2, itemHeight + 2, 7, new Color(255, 255, 255, 180),new Color(255, 255, 255, 180));
// Inner highlight
nvg.drawRoundedRect(itemX - 1, itemY - 1, itemWidth + 2, itemHeight + 2, 7, new Color(255, 255, 255, 180));
}
@@ -92,7 +102,7 @@ private void drawNanoVG(int mouseX, int mouseY, ScaledResolution sr, Glide insta

if(bg.getId() == 999) {
nvg.drawRoundedRect(acX + 11 + offsetX, acY + 35 + offsetY, 102.5F, 57.5F, 6, Color.BLACK);
nvg.drawCenteredText(Icon.PLUS, acX + 10 + offsetX + (102.5F / 2), acY + 42.5F + offsetY, Color.WHITE, 26, Fonts.ICON);
nvg.drawCenteredText(LegacyIcon.PLUS, acX + 10 + offsetX + (102.5F / 2), acY + 42.5F + offsetY, Color.WHITE, 26, Fonts.LEGACYICON);
} else {
nvg.drawRoundedImage(defBackground.getImage(), acX + 11 + offsetX, acY + 35 + offsetY, 102.5F, 57.5F, 6);
}
@@ -104,7 +114,7 @@ private void drawNanoVG(int mouseX, int mouseY, ScaledResolution sr, Glide insta
cusBackground.getTrashAnimation().setAnimation(MouseUtils.isInside(mouseX, mouseY, acX + 11 + offsetX, acY + 35 + offsetY + scroll.getValue(), 102.5F, 57.5F) ? 1.0F : 0.0F, 16);

nvg.drawRoundedImage(cusBackground.getImage(), acX + 11 + offsetX, acY + 35 + offsetY, 102.5F, 57.5F, 6);
nvg.drawText(Icon.TRASH, acX + offsetX + 100, acY + 38 + offsetY, palette.getMaterialRed((int) (cusBackground.getTrashAnimation().getValue() * 255)), 10, Fonts.ICON);
nvg.drawText(LegacyIcon.TRASH, acX + offsetX + 100, acY + 38 + offsetY, palette.getMaterialRed((int) (cusBackground.getTrashAnimation().getValue() * 255)), 10, Fonts.LEGACYICON);
}

nvg.drawRoundedRectVarying(acX + offsetX + 11, acY + offsetY + 76.5F, 102.5F, 16, 0, 0, 6, 6, this.getBackgroundColor());
@@ -142,10 +152,13 @@ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
int offsetY = (int) (0 + scroll.getValue());
int index = 1;

if(!MouseUtils.isInside(mouseX, mouseY, acX, acY, acWidth, acHeight) && !MouseUtils.isInside(mouseX, mouseY, sr.getScaledWidth() - 28 - 28, 6, 22, 22)){
introAnimation.setDirection(Direction.BACKWARDS);
}

for(Background bg : backgroundManager.getBackgrounds()) {

if(mouseButton == 0) {

if(MouseUtils.isInside(mouseX, mouseY, acX + 11 + offsetX, acY + 35 + offsetY, 102.5F, 57.5F)) {

if(bg.getId() == 999) {
@@ -193,7 +206,7 @@ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
@Override
public void keyTyped(char typedChar, int keyCode) {
if(keyCode == Keyboard.KEY_ESCAPE) {
this.setCurrentScene(this.getSceneByClass(MainScene.class));
introAnimation.setDirection(Direction.BACKWARDS);
}
}
}
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import me.eldodebug.soar.management.language.TranslateText;
import me.eldodebug.soar.management.nanovg.NanoVGManager;
import me.eldodebug.soar.management.nanovg.font.Fonts;
import me.eldodebug.soar.management.nanovg.font.Icon;
import me.eldodebug.soar.management.nanovg.font.LegacyIcon;
import me.eldodebug.soar.utils.mouse.MouseUtils;
import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiOptions;
@@ -40,7 +40,7 @@ private void drawNanoVG(NanoVGManager nvg) {

float yPos = sr.getScaledHeight() / 2 - 22;

nvg.drawCenteredText(Icon.SOAR, sr.getScaledWidth() / 2, sr.getScaledHeight() / 2 - (nvg.getTextHeight(Icon.SOAR, 54, Fonts.ICON) / 2) - 60, Color.WHITE, 54, Fonts.ICON);
nvg.drawCenteredText(LegacyIcon.SOAR, sr.getScaledWidth() / 2, sr.getScaledHeight() / 2 - (nvg.getTextHeight(LegacyIcon.SOAR, 54, Fonts.LEGACYICON) / 2) - 60, Color.WHITE, 54, Fonts.LEGACYICON);

nvg.drawRoundedRect(sr.getScaledWidth() / 2 - (180 / 2), yPos, 180, 20, 4.5F, this.getBackgroundColor());
nvg.drawCenteredText(TranslateText.SINGLEPLAYER.getText(), sr.getScaledWidth() / 2, yPos + 6.5F, Color.WHITE, 9.5F, Fonts.REGULAR);
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
import me.eldodebug.soar.management.color.ColorManager;
import me.eldodebug.soar.management.nanovg.NanoVGManager;
import me.eldodebug.soar.management.nanovg.font.Fonts;
import me.eldodebug.soar.management.nanovg.font.Icon;
import me.eldodebug.soar.management.nanovg.font.LegacyIcon;
import me.eldodebug.soar.utils.ColorUtils;
import me.eldodebug.soar.utils.animation.normal.Animation;
import me.eldodebug.soar.utils.animation.normal.Direction;
@@ -93,7 +93,7 @@ private void drawNanoVG() {

color.getAnimation().setAnimation(color.equals(currentColor) ? 1.0F : 0.0F, 16);

nvg.drawCenteredText(Icon.CHECK, x + offsetX + 10 + (32 / 2), y + offsetY + 40 + 8, new Color(255, 255, 255, (int) (color.getAnimation().getValue() * 255)), 16, Fonts.ICON);
nvg.drawCenteredText(LegacyIcon.CHECK, x + offsetX + 10 + (32 / 2), y + offsetY + 40 + 8, new Color(255, 255, 255, (int) (color.getAnimation().getValue() * 255)), 16, Fonts.LEGACYICON);

offsetX+=40;

Loading

0 comments on commit edbc053

Please sign in to comment.