aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
diff options
context:
space:
mode:
authorefefury <69400149+efefury@users.noreply.github.com>2023-01-31 22:04:33 +0000
committerGitHub <noreply@github.com>2023-01-31 23:04:33 +0100
commit7d34b5456f9978d063b9098ab095256109d522c2 (patch)
tree3752f4adb11ef6bf77c017102343121141e3571b /src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
parent291860435d5487562b122aaddbe57c178a8734de (diff)
downloadnotenoughupdates-7d34b5456f9978d063b9098ab095256109d522c2.tar.gz
notenoughupdates-7d34b5456f9978d063b9098ab095256109d522c2.tar.bz2
notenoughupdates-7d34b5456f9978d063b9098ab095256109d522c2.zip
Levels page in Profile Viewer (#562)
* ughidontwannafigureouthowtousethis * not finished hgdt< * Make use of new collections api in collectionspage * final commit HOPEFULLY * fix infer v1 * fix mithril powder going over cap my beloved * Formatting :thumbsup: * More Formatting :thumbsup: important * ea sports its in the game * maybe fix cache * change location of weight and networth and config option for weght requested by alea * Fix jump at CAP powder * Code formatting and deleted unused variables. * Used KUUDRA_TIERS array from CrimsonIslePage in SlayingTaskLevel. * Used SLAYERS array from PROFILEVIEWER in SlayingTaskLevel. * Intellij Code Cleanup. * revert fun things Please efe put formatting in another PR. * fix issues idk * Import fixes and formatting. And an unnecessary empty space in 2.1.1 for jani. * fix nea issue --------- Co-authored-by: nea <nea@nea.moe> Co-authored-by: jani270 <jani270@gmx.de> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java251
1 files changed, 130 insertions, 121 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
index 47df3c6e..8a48dd2c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
@@ -19,13 +19,13 @@
package io.github.moulberry.notenoughupdates.profileviewer;
-import com.google.common.base.Splitter;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.authlib.GameProfile;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
+import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage;
import io.github.moulberry.notenoughupdates.profileviewer.weight.lily.LilyWeight;
import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight;
import io.github.moulberry.notenoughupdates.util.Constants;
@@ -53,11 +53,12 @@ import org.apache.commons.lang3.text.WordUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL14;
import java.awt.*;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -72,6 +73,34 @@ import static io.github.moulberry.notenoughupdates.util.Utils.roundToNearestInt;
public class BasicPage extends GuiProfileViewerPage {
private static final ResourceLocation pv_basic = new ResourceLocation("notenoughupdates:pv_basic.png");
+
+ public static final ItemStack skull = Utils.createSkull(
+ "egirlefe",
+ "152de44a-43a3-46e1-badc-66cca2793471",
+ "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODdkODg1YjMyYjBkZDJkNmI3ZjFiNTgyYTM0MTg2ZjhhNTM3M2M0NjU4OWEyNzM0MjMxMzJiNDQ4YjgwMzQ2MiJ9fX0="
+ );
+
+ private static final LinkedHashMap<String, ItemStack> dungeonsModeIcons = new LinkedHashMap<String, ItemStack>() {
+ {
+ put(
+ "first_page",
+ Utils.editItemStackInfo(
+ new ItemStack(Items.paper),
+ EnumChatFormatting.GRAY + "Front Page",
+ true
+ )
+ );
+ put(
+ "second_page",
+ Utils.editItemStackInfo(
+ skull,
+ EnumChatFormatting.GRAY + "Level Page",
+ true
+ )
+ );
+ }
+ };
+
private static final ExecutorService profileLoader = Executors.newFixedThreadPool(1);
public EntityOtherPlayerMP entityPlayer = null;
private ResourceLocation playerLocationSkin = null;
@@ -88,9 +117,14 @@ public class BasicPage extends GuiProfileViewerPage {
private int backgroundClickedX = -1;
+ private boolean onSecondPage;
+
+ private final LevelPage levelPage;
+
public BasicPage(GuiProfileViewer instance) {
super(instance);
this.guiProfileViewer = instance;
+ this.levelPage = new LevelPage(guiProfileViewer, this);
}
@Override
@@ -101,6 +135,11 @@ public class BasicPage extends GuiProfileViewerPage {
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
+ if (onSecondPage) {
+ levelPage.drawPage(mouseX, mouseY);
+ return;
+ }
+
String location = null;
JsonObject status = profile.getPlayerStatus();
if (status != null && status.has("mode")) {
@@ -280,7 +319,7 @@ public class BasicPage extends GuiProfileViewerPage {
EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD +
GuiProfileViewer.numberFormat.format(networth),
fr,
- guiLeft + 63,
+ guiLeft + 165,
guiTop + 38,
true,
0
@@ -297,11 +336,10 @@ public class BasicPage extends GuiProfileViewerPage {
);
String networthIRLMoney = GuiProfileViewer.numberFormat.format(Math.round(
((networthInCookies * 325) / 675) * 4.99));
- if (
- mouseX > guiLeft + 8 &&
- mouseX < guiLeft + 8 + fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth))
- ) {
- if (mouseY > guiTop + 32 && mouseY < guiTop + 32 + fr.FONT_HEIGHT) {
+
+ int fontWidth = fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth));
+ if (mouseX > guiLeft + 165 - fontWidth / 2 && mouseX < guiLeft + 165 + fontWidth / 2) {
+ if (mouseY > guiTop + 32 && mouseY < guiTop + 38 + fr.FONT_HEIGHT) {
getInstance().tooltipToDisplay = new ArrayList<>();
getInstance()
.tooltipToDisplay.add(
@@ -349,7 +387,7 @@ public class BasicPage extends GuiProfileViewerPage {
Utils.drawStringCentered(
EnumChatFormatting.GREEN + "Net Worth: " + stateStr,
fr,
- guiLeft + 63,
+ guiLeft + 165,
guiTop + 38,
true,
0
@@ -534,116 +572,29 @@ public class BasicPage extends GuiProfileViewerPage {
);
}
- PlayerStats.Stats stats = profile.getStats(profileId);
+ // sb lvlL
- if (stats != null) {
- Splitter splitter = Splitter.on(" ").omitEmptyStrings().limit(2);
- for (int i = 0; i < PlayerStats.defaultStatNames.length; i++) {
- String statName = PlayerStats.defaultStatNames[i];
- //if (statName.equals("mining_fortune") || statName.equals("mining_speed")) continue;
- String statNamePretty = PlayerStats.defaultStatNamesPretty[i];
+ int sbLevelX = guiLeft + 162;
+ int sbLevelY = guiTop + 90;
- int val = Math.round(stats.get(statName));
+ double skyblockLevel = profile.getSkyblockLevel(profileId);
+ EnumChatFormatting skyblockLevelColour = profile.getSkyblockLevelColour(profileId);
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(
- GL11.GL_SRC_ALPHA,
- GL11.GL_ONE_MINUS_SRC_ALPHA,
- GL11.GL_ONE,
- GL11.GL_ONE_MINUS_SRC_ALPHA
- );
- Utils.renderAlignedString(
- statNamePretty,
- EnumChatFormatting.WHITE.toString() + val,
- guiLeft + 132,
- guiTop + 21 + 11f * i,
- 80
- );
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(sbLevelX, sbLevelY, 0);
+ GlStateManager.scale(1.5f, 1.5f, 1);
+ Utils.drawItemStack(skull, 0, 0);
+ GlStateManager.popMatrix();
+ Utils.drawStringScaled(skyblockLevelColour.toString() + (int) skyblockLevel, fr,
+ sbLevelX - 2, sbLevelY - 15, true, 0, 1.5f
+ );
- if (mouseX > guiLeft + 132 && mouseX < guiLeft + 212) {
- if (mouseY > guiTop + 21 + 11f * i && mouseY < guiTop + 37 + 11f * i) {
- List<String> split = splitter.splitToList(statNamePretty);
- PlayerStats.Stats baseStats = PlayerStats.getBaseStats();
- getInstance().tooltipToDisplay = new ArrayList<>();
- getInstance().tooltipToDisplay.add(statNamePretty);
- int base = Math.round(baseStats.get(statName));
- getInstance()
- .tooltipToDisplay.add(
- EnumChatFormatting.GRAY +
- "Base " +
- split.get(1) +
- ": " +
- EnumChatFormatting.GREEN +
- base +
- " " +
- split.get(0)
- );
- int passive = Math.round(profile.getPassiveStats(profileId).get(statName) - baseStats.get(statName));
- getInstance()
- .tooltipToDisplay.add(
- EnumChatFormatting.GRAY +
- "Passive " +
- split.get(1) +
- " Bonus: +" +
- EnumChatFormatting.YELLOW +
- passive +
- " " +
- split.get(0)
- );
- int itemBonus = Math.round(stats.get(statName) - profile.getPassiveStats(profileId).get(statName));
- getInstance()
- .tooltipToDisplay.add(
- EnumChatFormatting.GRAY +
- "Item " +
- split.get(1) +
- " Bonus: +" +
- EnumChatFormatting.DARK_PURPLE +
- itemBonus +
- " " +
- split.get(0)
- );
- int finalStat = Math.round(stats.get(statName));
- getInstance()
- .tooltipToDisplay.add(
- EnumChatFormatting.GRAY +
- "Final " +
- split.get(1) +
- ": +" +
- EnumChatFormatting.RED +
- finalStat +
- " " +
- split.get(0)
- );
- }
- }
- }
- } else {
- Utils.drawStringCentered(
- EnumChatFormatting.RED + "Skill/Inv/Coll",
- Minecraft.getMinecraft().fontRendererObj,
- guiLeft + 172,
- guiTop + 101 - 10,
- true,
- 0
- );
- Utils.drawStringCentered(
- EnumChatFormatting.RED + "APIs not",
- Minecraft.getMinecraft().fontRendererObj,
- guiLeft + 172,
- guiTop + 101,
- true,
- 0
- );
- Utils.drawStringCentered(
- EnumChatFormatting.RED + "enabled!",
- Minecraft.getMinecraft().fontRendererObj,
- guiLeft + 172,
- guiTop + 101 + 10,
- true,
- 0
- );
- }
+ float progress = (float) (skyblockLevel - (long) skyblockLevel);
+ getInstance().renderBar(sbLevelX - 30, sbLevelY + 30, 80, progress);
+
+ Utils.drawStringScaled(EnumChatFormatting.YELLOW.toString() + (int) (progress * 100) + "/100", fr,
+ sbLevelX - 30, sbLevelY + 20, true, 0, 0.9f
+ );
if (skyblockInfo != null) {
int position = 0;
@@ -672,6 +623,12 @@ public class BasicPage extends GuiProfileViewerPage {
getInstance().renderBar(x, y + 6, 80, level.level % 1);
}
+ if (mouseX >= guiLeft + 128 && mouseX <= guiLeft + 216) {
+ if (mouseY >= guiTop + 69 && mouseY <= guiTop + 131) {
+ if (Mouse.isButtonDown(0)) onSecondPage = true;
+ }
+ }
+
if (mouseX > x && mouseX < x + 80) {
if (mouseY > y - 4 && mouseY < y + 13) {
getInstance().tooltipToDisplay = new ArrayList<>();
@@ -759,7 +716,8 @@ public class BasicPage extends GuiProfileViewerPage {
);
}
- renderWeight(mouseX, mouseY, skyblockInfo, profileInfo);
+ drawSideButtons();
+ if (NotEnoughUpdates.INSTANCE.config.profileViewer.displayWeight) renderWeight(mouseX, mouseY, skyblockInfo, profileInfo);
}
private String getIcon(String gameModeType) {
@@ -830,14 +788,13 @@ public class BasicPage extends GuiProfileViewerPage {
weight = profile.getSoopyWeightLeaderboardPosition();
}
-
Utils.drawStringCentered(
EnumChatFormatting.GREEN +
"Senither Weight: " +
EnumChatFormatting.GOLD +
GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getTotalWeight().getRaw())),
fr,
- guiLeft + 63,
+ guiLeft + 165,
guiTop + 18,
true,
0
@@ -847,7 +804,7 @@ public class BasicPage extends GuiProfileViewerPage {
"Senither Weight: " +
GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getTotalWeight().getRaw()))
);
- if (mouseX > guiLeft + 63 - textWidth / 2 && mouseX < guiLeft + 63 + textWidth / 2) {
+ if (mouseX > guiLeft + 165 - textWidth / 2 && mouseX < guiLeft + 165 + textWidth / 2) {
if (mouseY > guiTop + 12 && mouseY < guiTop + 12 + fr.FONT_HEIGHT) {
getInstance().tooltipToDisplay = new ArrayList<>();
getInstance()
@@ -905,7 +862,7 @@ public class BasicPage extends GuiProfileViewerPage {
EnumChatFormatting.GOLD +
GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getTotalWeight().getRaw())),
fr,
- guiLeft + 63,
+ guiLeft + 165,
guiTop + 28,
true,
0
@@ -914,7 +871,7 @@ public class BasicPage extends GuiProfileViewerPage {
int fontWidth = fr.getStringWidth(
"Lily Weight: " + GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getTotalWeight().getRaw()))
);
- if (mouseX > guiLeft + 63 - fontWidth / 2 && mouseX < guiLeft + 63 + fontWidth / 2) {
+ if (mouseX > guiLeft + 165 - fontWidth / 2 && mouseX < guiLeft + 165 + fontWidth / 2) {
if (mouseY > guiTop + 22 && mouseY < guiTop + 22 + fr.FONT_HEIGHT) {
getInstance().tooltipToDisplay = new ArrayList<>();
getInstance()
@@ -992,10 +949,62 @@ public class BasicPage extends GuiProfileViewerPage {
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
+ @Override
+ public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ int guiLeft = GuiProfileViewer.getGuiLeft();
+ int guiTop = GuiProfileViewer.getGuiTop();
+
+ int i = onSlotToChangePage(mouseX, mouseY, guiLeft, guiTop);
+ switch (i) {
+ case 1:
+ onSecondPage = false;
+ break;
+ case 2:
+ onSecondPage = true;
+ break;
+
+ default:
+ break;
+ }
+
+ return false;
+ }
+
+ public int onSlotToChangePage(int mouseX, int mouseY, int guiLeft, int guiTop) {
+ if (mouseX >= guiLeft - 29 && mouseX <= guiLeft) {
+ if (mouseY >= guiTop && mouseY <= guiTop + 28) {
+ return 1;
+ } else if (mouseY + 28 >= guiTop && mouseY <= guiTop + 28 * 2) {
+ return 2;
+ }
+ }
+ return 0;
+ }
+
public String getGameModeType(JsonObject profileInfo) {
if (profileInfo != null && profileInfo.has("game_mode")) {
return profileInfo.get("game_mode").getAsString();
}
return "";
}
+
+ public void drawSideButtons() {
+ GlStateManager.enableDepth();
+ GlStateManager.translate(0, 0, 5);
+ if (onSecondPage) {
+ Utils.drawPvSideButton(1, dungeonsModeIcons.get("second_page"), true, guiProfileViewer);
+ } else {
+ Utils.drawPvSideButton(0, dungeonsModeIcons.get("first_page"), true, guiProfileViewer);
+ }
+ GlStateManager.translate(0, 0, -3);
+
+ GlStateManager.translate(0, 0, -2);
+ if (!onSecondPage) {
+ Utils.drawPvSideButton(1, dungeonsModeIcons.get("second_page"), false, guiProfileViewer);
+ } else {
+ Utils.drawPvSideButton(0, dungeonsModeIcons.get("first_page"), false, guiProfileViewer);
+ }
+ GlStateManager.disableDepth();
+ }
}