New Main Menu

This commit is contained in:
kirillsaint 2023-07-07 23:38:03 +06:00
parent abe966717a
commit 2eb811c8f7
7 changed files with 259 additions and 7 deletions

View File

@ -20,7 +20,6 @@ import net.silentclient.client.gui.clickgui.ClickGUI;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.util.BackgroundPanorama;
import net.silentclient.client.keybinds.KeyBindManager;
import net.silentclient.client.mixin.SilentClientTweaker;
import net.silentclient.client.mods.ModInstances;
import net.silentclient.client.mods.SettingsManager;
import net.silentclient.client.mods.settings.FPSBoostMod;
@ -137,7 +136,7 @@ public class Client {
}
logger.info("---------[ Silent Client Initialising ]---------");
logger.info("MC Version: 1.8.9");
logger.info("SC Version: " + getVersion());
logger.info("SC Version: " + getFullVersion());
logger.info("Width: " + Minecraft.getMinecraft().displayWidth);
logger.info("Height: " + Minecraft.getMinecraft().displayHeight);
logger.info("Fullscreen: " + Minecraft.getMinecraft().isFullScreen());
@ -472,6 +471,10 @@ public class Client {
}
public String getVersion() {
return version;
}
public String getFullVersion() {
return "v" + version + "-" + getBuildData().getCommit() + "-" + getBuildData().getBranch();
}

View File

@ -5,6 +5,7 @@ import java.net.URI;
import java.util.Random;
import net.minecraft.client.gui.*;
import net.silentclient.client.gui.silentmainmenu.SilentMainMenu;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GLContext;
@ -143,6 +144,7 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback
this.buttonList.add(new IconButton(88, 4, 5, new ResourceLocation("silentclient/icons/news.png")));
this.buttonList.add(cosmetics = new IconButton(87, 26, 5, new ResourceLocation("silentclient/icons/settings/cosmetics.png")));
this.buttonList.add(new IconButton(89, 48, 5, new ResourceLocation("silentclient/icons/back.png")));
if (this.mc.isDemo())
{
this.addDemoButtons(j, 24);
@ -219,6 +221,10 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback
this.mc.displayGuiScreen(new GuiMultiplayer(this));
}
if(button.id == 89) {
mc.displayGuiScreen(new SilentMainMenu());
}
if (button.id == 14 && this.realmsButton.visible)
{
this.switchToRealms();

View File

@ -0,0 +1,51 @@
package net.silentclient.client.gui.silentmainmenu;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.GuiButton;
import net.silentclient.client.Client;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.mods.settings.GeneralMod;
import net.silentclient.client.utils.TimerUtils;
import java.awt.*;
public class MenuButton extends GuiButton {
private int animatedOpcaity = 0;
private TimerUtils animateTimer = new TimerUtils();
public MenuButton(int buttonId, int x, int y, String buttonText) {
super(buttonId, x, y, 80, 20, buttonText);
}
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
RenderUtil.drawRoundedRect(this.xPosition, this.yPosition, 80, 20, 1, new Color(20, 20, 20, 102).getRGB());
RenderUtil.drawRoundedRect(xPosition, yPosition, width, height, 1, new Color(255, 255, 255, animatedOpcaity).getRGB());
RenderUtil.drawRoundedOutline(this.xPosition, this.yPosition, 80, 20, 1, 1, new Color(214, 213, 210).getRGB());
Client.getInstance().getSilentFontRenderer().drawCenteredString(this.displayString, this.xPosition + 40, this.yPosition + 3, 14, SilentFontRenderer.FontType.TITLE, 70);
if (this.hovered && this.enabled) {
if (this.animatedOpcaity < 75 && animateTimer.delay(30)) {
this.animatedOpcaity += 15;
animateTimer.reset();
}
} else {
if (this.animatedOpcaity != 0 && animateTimer.delay(30)) {
this.animatedOpcaity -= 15;
animateTimer.reset();
}
}
}
@Override
public void playPressSound(SoundHandler soundHandlerIn) {
if(!Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Silent Button Sounds").getValBoolean()) {
return;
}
super.playPressSound(soundHandlerIn);
}
}

View File

@ -0,0 +1,193 @@
package net.silentclient.client.gui.silentmainmenu;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import net.silentclient.client.admin.AdminRender;
import net.silentclient.client.cosmetics.gui.CosmeticsGui;
import net.silentclient.client.gui.GuiNews;
import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.gui.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.clickgui.utils.RenderUtils;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.minecraft.GuiMainMenu;
import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.utils.SCTextureManager;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URI;
import java.util.Random;
public class SilentMainMenu extends SilentScreen {
public static ResourceLocation imageLocation = null;
public static BufferedImage image = null;
public static boolean loading = false;
public static boolean initPanel = false;
private MenuButton singleplayerButton;
private MenuButton multiplayerButton;
private MenuButton quitGameButton;
@Override
public void initGui() {
super.initGui();
this.buttonList.clear();
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
this.buttonList.add(this.singleplayerButton = new MenuButton(1, this.width / 2 - 130, 40, "Singleplayer"));
this.buttonList.add(this.multiplayerButton = new MenuButton(2, this.width / 2 - 40, 40, "Multiplayer"));
this.buttonList.add(this.quitGameButton = new MenuButton(3, this.width / 2 + 50, 40, "Quit Game"));
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.loadPanels();
GlStateManager.disableAlpha();
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
GlStateManager.enableAlpha();
this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB());
this.drawHeader();
this.drawBlock(mouseX, mouseY);
this.drawFooter();
super.drawScreen(mouseX, mouseY, partialTicks);
}
private void drawBlock(int mouseX, int mouseY) {
int blockY = this.height / 2 - 75;
int blockX = this.width / 2 - 160;
if(blockY < 70) {
blockY = 70;
}
RenderUtils.drawRect(blockX, blockY, 320, 150, new Color(20, 20, 20).getRGB());
if(imageLocation != null) {
RenderUtil.drawImage(imageLocation, blockX + 78, blockY + 10, 231, 130, false);
}
int optionY = blockY + 10;
this.drawOptionButton(mouseX, mouseY, blockX + 5, optionY, new ResourceLocation("silentclient/icons/settings/cosmetics.png"), "Cosmetics");
optionY += 15;
this.drawOptionButton(mouseX, mouseY, blockX + 5, optionY, new ResourceLocation("silentclient/icons/store_icon.png"), "Store");
optionY += 15;
this.drawOptionButton(mouseX, mouseY, blockX + 5, optionY, new ResourceLocation("silentclient/icons/settings.png"), "Options");
optionY += 15;
this.drawOptionButton(mouseX, mouseY, blockX + 5, optionY, new ResourceLocation("silentclient/icons/language.png"), "Language");
optionY += 15;
this.drawOptionButton(mouseX, mouseY, blockX + 5, optionY, new ResourceLocation("silentclient/icons/back.png"), "Vanilla Menu");
}
private void drawOptionButton(int mouseX, int mouseY, int x, int y, ResourceLocation icon, String text) {
if(Client.getInstance().getSilentFontRenderer().getStringWidth(text, 12, SilentFontRenderer.FontType.TITLE) > 60) {
int difference = -(60 - Client.getInstance().getSilentFontRenderer().getStringWidth(text, 12, SilentFontRenderer.FontType.TITLE));
int oneSymbolWidth = Client.getInstance().getSilentFontRenderer().getStringWidth("a", 12, SilentFontRenderer.FontType.TITLE);
int symbolsCount = difference / oneSymbolWidth;
text = text.substring(0, text.length() - symbolsCount - 3);
text += "...";
}
if(optionHovered(mouseX, mouseY, x - 5, y)) {
RenderUtils.drawRect(x - 5, y, 75, 15, new Color(255, 255, 255, 70).getRGB());
}
RenderUtil.drawImage(icon, x, y + 3, 10, 10);
Client.getInstance().getSilentFontRenderer().drawString(text, x + 13, y + 2, 12, SilentFontRenderer.FontType.TITLE);
}
private boolean optionHovered(int mouseX, int mouseY, int x, int y) {
return MouseUtils.isInside(mouseX, mouseY, x, y, 70, 15);
}
private void drawHeader() {
RenderUtils.drawRect(0, 0, this.width, 25, new Color(20, 20, 20).getRGB());
RenderUtil.drawImage(new ResourceLocation("silentclient/logos/logo.png"), this.width / 2 - 48.8F, 3, 97.7F, 19);
}
private void drawFooter() {
Client.getInstance().getSilentFontRenderer().drawString("Silent Client " + Client.getInstance().getVersion(), 5, this.height - 17, 14, SilentFontRenderer.FontType.TITLE);
Client.getInstance().getSilentFontRenderer().drawString("Version 1.8.9", this.width - (Client.getInstance().getSilentFontRenderer().getStringWidth("Version 1.8.9", 14, SilentFontRenderer.FontType.TITLE)) - 5, this.height - 17, 14, SilentFontRenderer.FontType.TITLE);
}
private void loadPanels() {
if(image == null && !loading && GuiNews.news != null) {
loading = true;
(new Thread("NewsThread") {
public void run() {
SilentMainMenu.image = SCTextureManager.getImage(GuiNews.news.getItem().getCover());
SilentMainMenu.loading = false;
}
}).start();
}
if(image != null && !initPanel) {
imageLocation = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("image_panel_" + new Random().nextLong(), new DynamicTexture(image));
initPanel = true;
}
}
@Override
protected void actionPerformed(GuiButton button) throws IOException {
super.actionPerformed(button);
switch (button.id) {
case 1:
mc.displayGuiScreen(new GuiSelectWorld(this));
break;
case 2:
mc.displayGuiScreen(new GuiMultiplayer(this));
break;
case 3:
mc.shutdown();
break;
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
int blockX = this.width / 2 - 160;
int blockY = this.height / 2 - 75;
if(blockY < 70) {
blockY = 70;
}
int optionY = blockY + 10;
if(this.optionHovered(mouseX, mouseY, blockX, optionY)) {
mc.displayGuiScreen(new CosmeticsGui());
return;
}
optionY += 15;
if(this.optionHovered(mouseX, mouseY, blockX, optionY)) {
try {
Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://store.silentclient.net/")});
} catch (Throwable err) {
err.printStackTrace();
}
return;
}
optionY += 15;
if(this.optionHovered(mouseX, mouseY, blockX, optionY)) {
mc.displayGuiScreen(new GuiOptions(this, mc.gameSettings));
return;
}
optionY += 15;
if(this.optionHovered(mouseX, mouseY, blockX, optionY)) {
mc.displayGuiScreen(new GuiLanguage(this, mc.gameSettings, mc.getLanguageManager()));
return;
}
optionY += 15;
if(this.optionHovered(mouseX, mouseY, blockX, optionY)) {
mc.displayGuiScreen(new GuiMainMenu());
}
}
@Override
public void updateScreen() {
super.updateScreen();
Client.backgroundPanorama.tickPanorama();
}
}

View File

@ -18,7 +18,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.world.WorldSettings;
import net.silentclient.client.Client;
import net.silentclient.client.event.impl.*;
import net.silentclient.client.gui.GuiNews;
import net.silentclient.client.gui.silentmainmenu.SilentMainMenu;
import net.silentclient.client.gui.util.BackgroundPanorama;
import net.silentclient.client.hooks.MinecraftHook;
import net.silentclient.client.mods.render.AnimationsMod;
@ -38,7 +38,6 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.io.File;
@ -60,7 +59,7 @@ public abstract class MinecraftMixin {
if(Client.backgroundPanorama == null) {
Client.backgroundPanorama = new BackgroundPanorama(Minecraft.getMinecraft());
}
displayGuiScreen(new GuiNews());
displayGuiScreen(new SilentMainMenu());
}
@Inject(method = "shutdownMinecraftApplet", at = @At("HEAD"))
@ -70,7 +69,7 @@ public abstract class MinecraftMixin {
@Redirect(method = "createDisplay", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"))
public void setWindowTitle(String newTitle) {
Display.setTitle("Silent Client " + Client.getInstance().getVersion() + " (1.8.9)");
Display.setTitle("Silent Client " + Client.getInstance().getFullVersion() + " (1.8.9)");
}
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;info(Ljava/lang/String;)V", ordinal = 1))
@ -123,7 +122,7 @@ public abstract class MinecraftMixin {
Client.backgroundPanorama = new BackgroundPanorama(Minecraft.getMinecraft());
}
if(guiScreenIn instanceof GuiMainMenu) {
displayGuiScreen(new net.silentclient.client.gui.minecraft.GuiMainMenu());
displayGuiScreen(new SilentMainMenu());
return;
}
if(guiScreenIn instanceof GuiIngameMenu) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB