diff options
Diffstat (limited to 'src/main/java/io')
8 files changed, 116 insertions, 33 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java index e59a6a14..20031ec3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java @@ -46,6 +46,10 @@ public class StringUtils { return Integer.parseInt(str); } + public static String shortNumberFormat(int n) { + return shortNumberFormat(n, 0); + } + public static String shortNumberFormat(double n) { return shortNumberFormat(n, 0); } @@ -74,7 +78,9 @@ public class StringUtils { double d = ((long) n / 100) / 10.0; boolean isRound = (d * 10) % 10 == 0; - return d < 1000 ? (isRound || d > 9.99 ? (int) d * 10 / 10 : d + "") + "" + sizeSuffix[iteration] : shortNumberFormat(d, iteration + 1); + return d < 1000 + ? (isRound || d > 9.99 ? (int) d * 10 / 10 : d + "") + "" + sizeSuffix[iteration] + : shortNumberFormat(d, iteration + 1); } public static String removeLastWord(String string, String splitString) { 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 7b21e6a1..0011272f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -83,7 +83,7 @@ public class BasicPage extends GuiProfileViewerPage { "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODdkODg1YjMyYjBkZDJkNmI3ZjFiNTgyYTM0MTg2ZjhhNTM3M2M0NjU4OWEyNzM0MjMxMzJiNDQ4YjgwMzQ2MiJ9fX0=" ); - private static final LinkedHashMap<String, ItemStack> dungeonsModeIcons = new LinkedHashMap<String, ItemStack>() { + private static final LinkedHashMap<String, ItemStack> pageModeIcon = new LinkedHashMap<String, ItemStack>() { { put( "first_page", @@ -1001,7 +1001,7 @@ public class BasicPage extends GuiProfileViewerPage { int guiLeft = GuiProfileViewer.getGuiLeft(); int guiTop = GuiProfileViewer.getGuiTop(); - int i = onSlotToChangePage(mouseX, mouseY, guiLeft, guiTop); + int i = ProfileViewerUtils.onSlotToChangePage(mouseX, mouseY, guiLeft, guiTop); switch (i) { case 1: onSecondPage = false; @@ -1017,32 +1017,21 @@ public class BasicPage extends GuiProfileViewerPage { 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 void drawSideButtons() { GlStateManager.enableDepth(); GlStateManager.translate(0, 0, 5); if (onSecondPage) { - Utils.drawPvSideButton(1, dungeonsModeIcons.get("second_page"), true, guiProfileViewer); + Utils.drawPvSideButton(1, pageModeIcon.get("second_page"), true, guiProfileViewer); } else { - Utils.drawPvSideButton(0, dungeonsModeIcons.get("first_page"), true, guiProfileViewer); + Utils.drawPvSideButton(0, pageModeIcon.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); + Utils.drawPvSideButton(1, pageModeIcon.get("second_page"), false, guiProfileViewer); } else { - Utils.drawPvSideButton(0, dungeonsModeIcons.get("first_page"), false, guiProfileViewer); + Utils.drawPvSideButton(0, pageModeIcon.get("first_page"), false, guiProfileViewer); } GlStateManager.disableDepth(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java index e8e9f171..333ae591 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -76,6 +76,7 @@ public class CollectionsPage extends GuiProfileViewerPage { private int page = 0; private int maxPage = 0; + public CollectionsPage(GuiProfileViewer instance) { super(instance); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java index b03c87dd..d53e44d0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -74,7 +74,7 @@ public class DungeonPage extends GuiProfileViewerPage { "fa06cb0c471c1c9bc169af270cd466ea701946776056e472ecdaeb49f0f4a4dc", "a435164c05cea299a3f016bbbed05706ebb720dac912ce4351c2296626aecd9a", }; - private static final LinkedHashMap<String, ItemStack> dungeonsModeIcons = new LinkedHashMap<String, ItemStack>() { + private static final LinkedHashMap<String, ItemStack> pageModeIcon = new LinkedHashMap<String, ItemStack>() { { put( "catacombs", @@ -650,17 +650,17 @@ public class DungeonPage extends GuiProfileViewerPage { GlStateManager.enableDepth(); GlStateManager.translate(0, 0, 5); if (onMasterMode) { - Utils.drawPvSideButton(1, dungeonsModeIcons.get("master_catacombs"), true, getInstance()); + Utils.drawPvSideButton(1, pageModeIcon.get("master_catacombs"), true, getInstance()); } else { - Utils.drawPvSideButton(0, dungeonsModeIcons.get("catacombs"), true, getInstance()); + Utils.drawPvSideButton(0, pageModeIcon.get("catacombs"), true, getInstance()); } GlStateManager.translate(0, 0, -3); GlStateManager.translate(0, 0, -2); if (!onMasterMode) { - Utils.drawPvSideButton(1, dungeonsModeIcons.get("master_catacombs"), false, getInstance()); + Utils.drawPvSideButton(1, pageModeIcon.get("master_catacombs"), false, getInstance()); } else { - Utils.drawPvSideButton(0, dungeonsModeIcons.get("catacombs"), false, getInstance()); + Utils.drawPvSideButton(0, pageModeIcon.get("catacombs"), false, getInstance()); } GlStateManager.disableDepth(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java index 5d23eede..c4dc7cd6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -24,6 +24,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.miscfeatures.profileviewer.SacksPage; import io.github.moulberry.notenoughupdates.profileviewer.info.QuiverInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -131,8 +132,35 @@ public class InventoriesPage extends GuiProfileViewerPage { put("intelligence",2f); }}; + private boolean onSacksPage; + private final SacksPage sacksPage; + + private static final LinkedHashMap<String, ItemStack> pageModeIcon = new LinkedHashMap<String, ItemStack>() { + { + put( + "inventories", + Utils.editItemStackInfo( + new ItemStack(Items.painting), + EnumChatFormatting.GRAY + "Inventories", + true + ) + ); + put( + "sacks", + Utils.editItemStackInfo( + NotEnoughUpdates.INSTANCE.manager.jsonToStack( + NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("LARGE_ENCHANTED_MINING_SACK") + ), + EnumChatFormatting.GRAY + "Sacks", + true + ) + ); + } + }; + public InventoriesPage(GuiProfileViewer instance) { super(instance); + this.sacksPage = new SacksPage(getInstance()); } @Override @@ -140,6 +168,13 @@ public class InventoriesPage extends GuiProfileViewerPage { int guiLeft = GuiProfileViewer.getGuiLeft(); int guiTop = GuiProfileViewer.getGuiTop(); + drawSideButtons(); + + if (onSacksPage) { + sacksPage.drawPage(mouseX, mouseY, partialTicks); + return; + } + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_invs); Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST); getInstance().inventoryTextField.setSize(88, 20); @@ -512,15 +547,31 @@ public class InventoriesPage extends GuiProfileViewerPage { int guiLeft = GuiProfileViewer.getGuiLeft(); int guiTop = GuiProfileViewer.getGuiTop(); - getInstance().inventoryTextField.setSize(88, 20); - if (mouseX > guiLeft + 19 && mouseX < guiLeft + 19 + 88) { - if (mouseY > guiTop + getInstance().sizeY - 26 - 20 && mouseY < guiTop + getInstance().sizeY - 26) { - getInstance().inventoryTextField.mouseClicked(mouseX, mouseY, mouseButton); - getInstance().playerNameTextField.otherComponentClick(); - return true; + if (!onSacksPage) { + getInstance().inventoryTextField.setSize(88, 20); + if (mouseX > guiLeft + 19 && mouseX < guiLeft + 19 + 88) { + if (mouseY > guiTop + getInstance().sizeY - 26 - 20 && mouseY < guiTop + getInstance().sizeY - 26) { + getInstance().inventoryTextField.mouseClicked(mouseX, mouseY, mouseButton); + getInstance().playerNameTextField.otherComponentClick(); + return true; + } } } - return false; + + int i = ProfileViewerUtils.onSlotToChangePage(mouseX, mouseY, guiLeft, guiTop); + switch (i) { + case 1: + onSacksPage = false; + break; + case 2: + onSacksPage = true; + break; + + default: + break; + } + + return sacksPage.mouseClick(mouseX, mouseY, mouseButton); } @Override @@ -844,4 +895,23 @@ public class InventoriesPage extends GuiProfileViewerPage { return 6; } } + + private void drawSideButtons() { + GlStateManager.enableDepth(); + GlStateManager.translate(0, 0, 5); + if (onSacksPage) { + Utils.drawPvSideButton(1, pageModeIcon.get("sacks"), true, getInstance()); + } else { + Utils.drawPvSideButton(0, pageModeIcon.get("inventories"), true, getInstance()); + } + GlStateManager.translate(0, 0, -3); + + GlStateManager.translate(0, 0, -2); + if (!onSacksPage) { + Utils.drawPvSideButton(1, pageModeIcon.get("sacks"), false, getInstance()); + } else { + Utils.drawPvSideButton(0, pageModeIcon.get("inventories"), false, getInstance()); + } + GlStateManager.disableDepth(); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java index ef4d5aa9..417ca9e6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java @@ -294,4 +294,15 @@ public class ProfileViewerUtils { } }); } + + public static 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; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java index c30f869e..59084548 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java @@ -84,6 +84,7 @@ public class Constants { public static JsonObject SBLEVELS; public static JsonObject MUSEUM; public static JsonObject BESTIARY; + public static JsonObject SACKS; private static final ReentrantLock lock = new ReentrantLock(); @@ -111,6 +112,7 @@ public class Constants { SBLEVELS = Utils.getConstant("sblevels", gson); MUSEUM = Utils.getConstant("museum", gson); BESTIARY = Utils.getConstant("bestiary", gson); + SACKS = Utils.getConstant("sacks", gson); parseEssenceCosts(); } catch (Exception ex) { 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 f879631e..6d44e4b7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1171,6 +1171,10 @@ public class Utils { drawStringCentered(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, colour); } + public static void drawStringCentered(String str, int x, int y, boolean shadow, int colour) { + drawStringCentered(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, colour); + } + @Deprecated public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) { int strLen = fr.getStringWidth(str); |