From f55ee05b748e8ca13c27f42705ead21bbe3df707 Mon Sep 17 00:00:00 2001 From: DoKM Date: Thu, 29 Jul 2021 19:44:40 +0200 Subject: Add a open in Skycrypt (sky.shiiyu.moe) button also added a generic playSound util --- .../profileviewer/GuiProfileViewer.java | 28 ++++++++++++++++++++++ .../moulberry/notenoughupdates/util/Utils.java | 9 ++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 735f4ba2..a6152340 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -42,6 +42,8 @@ import org.lwjgl.opengl.GL20; import java.awt.*; import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.text.NumberFormat; import java.util.*; import java.util.List; @@ -175,12 +177,23 @@ public class GuiProfileViewer extends GuiScreen { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); if(profile != null) { + //Render Profile chooser button renderBlurredBackground(width, height, guiLeft+2, guiTop+sizeY+3+2, 100-4, 20-4); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown); Utils.drawTexturedRect(guiLeft, guiTop+sizeY+3, 100, 20, 0, 100/200f, 0, 20/185f, GL11.GL_NEAREST); Utils.drawStringCenteredScaledMaxWidth(profileId, Minecraft.getMinecraft().fontRendererObj, guiLeft+50, guiTop+sizeY+3+10, true, 90, new Color(63, 224, 208, 255).getRGB()); + //Render Open In Skycrypt button + renderBlurredBackground(width, height, guiLeft+100+6+2, guiTop+sizeY+3+2, 100-4, 20-4); + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown); + Utils.drawTexturedRect(guiLeft+100+6, guiTop+sizeY+3, 100, 20, + 0, 100/200f, 0, 20/185f, GL11.GL_NEAREST); + Utils.drawStringCenteredScaledMaxWidth("Open in Skycrypt", Minecraft.getMinecraft().fontRendererObj, guiLeft+50+100+6, + guiTop+sizeY+3+10, true, 90, new Color(63, 224, 208, 255).getRGB()); + + + if(profileDropdownSelected && !profile.getProfileIds().isEmpty() && scaledResolution.getScaleFactor() != 4) { int dropdownOptionSize = scaledResolution.getScaleFactor()==3?10:20; @@ -382,6 +395,21 @@ public class GuiProfileViewer extends GuiScreen { return; } } + if(mouseX > guiLeft+106 && mouseX < guiLeft+106+100 && profile != null && !profile.getProfileIds().isEmpty() && profileId != null) { + if(mouseY > guiTop+sizeY+3 && mouseY < guiTop+sizeY+23) { + try{ + Desktop desk = Desktop.getDesktop(); + desk.browse(new URI("https://sky.shiiyu.moe/stats/"+profile.getHypixelProfile().get("displayname").getAsString()+"/"+profileId)); + Utils.playPressSound(); + return; + } catch (IOException | URISyntaxException ignored) { + //no idea how this sounds, but ya know just in case + Utils.playSound(new ResourceLocation("game.player.hurt"), true); + return; + } + } + } + if(mouseX > guiLeft && mouseX < guiLeft+100 && profile != null && !profile.getProfileIds().isEmpty()) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); if(mouseY > guiTop+sizeY+3 && mouseY < guiTop+sizeY+23) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 37e9c600..c40101ca 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -492,9 +492,12 @@ public class Utils { } public static void playPressSound() { - if(NotEnoughUpdates.INSTANCE.config.misc.guiButtonClicks) { - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create( - new ResourceLocation("gui.button.press"), 1.0F)); + playSound(new ResourceLocation("gui.button.press"), true); + } + + public static void playSound(ResourceLocation sound, boolean gui) { + if(NotEnoughUpdates.INSTANCE.config.misc.guiButtonClicks || !gui) { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(sound, 1.0F)); } } -- cgit