diff options
author | syeyoung <cyong06@naver.com> | 2021-07-21 15:29:43 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-07-21 15:29:43 +0900 |
commit | d392b203a93a8897a184f75634338b7c866510f3 (patch) | |
tree | a27505fbdc2bc754c674a026915c27065984c00e /src/main | |
parent | 4850d1a1f795f625286b9a2058143f688265dc3d (diff) | |
download | Skyblock-Dungeons-Guide-d392b203a93a8897a184f75634338b7c866510f3.tar.gz Skyblock-Dungeons-Guide-d392b203a93a8897a184f75634338b7c866510f3.tar.bz2 Skyblock-Dungeons-Guide-d392b203a93a8897a184f75634338b7c866510f3.zip |
custom party finder
Diffstat (limited to 'src/main')
13 files changed, 874 insertions, 20 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index 927684e4..860cd86a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -32,6 +32,7 @@ import kr.syeyoung.dungeonsguide.features.impl.etc.*; import kr.syeyoung.dungeonsguide.features.impl.etc.ability.FeatureAbilityCooldown; import kr.syeyoung.dungeonsguide.features.impl.party.APIKey; import kr.syeyoung.dungeonsguide.features.impl.party.FeatureGoodParties; +import kr.syeyoung.dungeonsguide.features.impl.party.customgui.FeatureCustomPartyFinder; import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin; import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureActions; import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureFreezePathfind; @@ -112,6 +113,7 @@ public class FeatureRegistry { public static final APIKey PARTYKICKER_APIKEY = register(new APIKey()); public static final FeatureViewPlayerOnJoin PARTYKICKER_VIEWPLAYER = register(new FeatureViewPlayerOnJoin()); public static final FeatureGoodParties PARTYKICKER_GOODPARTIES = register(new FeatureGoodParties()); + public static final FeatureCustomPartyFinder PARTYKICKER_CUSTOM = register(new FeatureCustomPartyFinder()); public static final FeatureWarningOnPortal BOSSFIGHT_WARNING_ON_PORTAL = register(new FeatureWarningOnPortal()); public static final SimpleFeature BOSSFIGHT_CHESTPRICE = register(new FeatureChestPrice()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/FeatureCustomPartyFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/FeatureCustomPartyFinder.java new file mode 100644 index 00000000..34daadf8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/FeatureCustomPartyFinder.java @@ -0,0 +1,61 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.events.WindowUpdateEvent; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraftforge.client.event.GuiOpenEvent; + +public class FeatureCustomPartyFinder extends SimpleFeature implements GuiOpenListener, GuiUpdateListener { + public FeatureCustomPartyFinder() { + super("Party Kicker","Custom Party Finder","Custom Party Finder", "party.customfinder", true); + } + + GuiCustomPartyFinder guiCustomPartyFinder; + @Override + public void onGuiOpen(GuiOpenEvent event) { + if (event.gui == null) guiCustomPartyFinder = null; + if (!isEnabled()) return; + if (!(event.gui instanceof GuiChest)) return; + GuiChest chest = (GuiChest) event.gui; + if (!(chest.inventorySlots instanceof ContainerChest)) return; + ContainerChest containerChest = (ContainerChest) chest.inventorySlots; + IInventory lower = containerChest.getLowerChestInventory(); + if (lower == null || !lower.getName().equals("Party Finder")) return; + + if (guiCustomPartyFinder == null) { + guiCustomPartyFinder = new GuiCustomPartyFinder(); + } + guiCustomPartyFinder.setGuiChest(chest); + + event.gui = guiCustomPartyFinder; + } + + @Override + public void onGuiUpdate(WindowUpdateEvent windowUpdateEvent) { + if (guiCustomPartyFinder != null) { + guiCustomPartyFinder.onChestUpdate(windowUpdateEvent); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/GuiCustomPartyFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/GuiCustomPartyFinder.java new file mode 100644 index 00000000..bf297b93 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/GuiCustomPartyFinder.java @@ -0,0 +1,71 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.events.WindowUpdateEvent; +import kr.syeyoung.dungeonsguide.gui.MGui; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiChest; + +import java.awt.*; + +public class GuiCustomPartyFinder extends MGui { + @Getter + private GuiChest guiChest; + + public void setGuiChest(GuiChest guiChest) { + if (this.guiChest != null) this.guiChest.onGuiClosed(); + this.guiChest = guiChest; + panelPartyFinder.onChestUpdate(null); + guiChest.setWorldAndResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); + guiChest.initGui(); + } + + public void onChestUpdate(WindowUpdateEvent windowUpdateEvent) { + panelPartyFinder.onChestUpdate(windowUpdateEvent); + } + + private PanelPartyFinder panelPartyFinder; + public GuiCustomPartyFinder() { + panelPartyFinder = new PanelPartyFinder(this); + getMainPanel().add(panelPartyFinder); + } + + @Override + public void initGui() { + super.initGui(); + panelPartyFinder.setBounds(new Rectangle(Minecraft.getMinecraft().displayWidth/5, Minecraft.getMinecraft().displayHeight/5,3*Minecraft.getMinecraft().displayWidth/5, 3*Minecraft.getMinecraft().displayHeight/5)); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + + } + + @Override + public void onGuiClosed() { + guiChest.onGuiClosed(); + guiChest = null; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinder.java new file mode 100644 index 00000000..8f43399c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinder.java @@ -0,0 +1,286 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.events.WindowUpdateEvent; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.gui.elements.MList; +import kr.syeyoung.dungeonsguide.gui.elements.MScrollablePanel; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +public class PanelPartyFinder extends MPanel { + @Getter + private GuiCustomPartyFinder guiCustomPartyFinder; + + private PanelPartyFinderSettings panelPartyFinderSettings; + + private MScrollablePanel scrollablePanel; + private MList list; + + private MButton goBack; + private MButton previous; + private MButton next; + private int page = 1; + + private Map<Integer, PanelPartyListElement> panelPartyListElementMap = new HashMap<>(); + + public PanelPartyFinder(GuiCustomPartyFinder guiCustomPartyFinder) { + this.guiCustomPartyFinder = guiCustomPartyFinder; + + scrollablePanel = new MScrollablePanel(1); + panelPartyFinderSettings = new PanelPartyFinderSettings(this); + + list = new MList() { + @Override + public void resize(int parentWidth, int parentHeight) { + setSize(new Dimension(parentWidth, 9999)); + realignChildren(); + } + }; + list.setGap(1); + + scrollablePanel.add(list); + + add(scrollablePanel); + add(panelPartyFinderSettings); + + previous = new MButton(); next = new MButton(); + previous.setText("Prev"); next.setText("Next"); + previous.setEnabled(false); next.setEnabled(false); + next.setOnActionPerformed(() -> { + GuiChest chest = getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*2+8, 0, 0, Minecraft.getMinecraft().thePlayer); + }); + previous.setOnActionPerformed(() -> { + GuiChest chest = getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*2, 0, 0, Minecraft.getMinecraft().thePlayer); + }); + goBack = new MButton(); + goBack.setBackground(RenderUtils.blendAlpha(0xFF141414, 0.05f)); + goBack.setText("<"); + goBack.setOnActionPerformed(() -> { + GuiChest chest = getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+3, 0, 0, Minecraft.getMinecraft().thePlayer); + }); + add(previous); add(next); add(goBack); + } + + public String getHighlightNote() { + return panelPartyFinderSettings.getHighlightText(); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + scrollablePanel.setBounds(new Rectangle(0, fr.FONT_HEIGHT*2+41, 2*bounds.width/3, bounds.height - fr.FONT_HEIGHT*2-41)); + panelPartyFinderSettings.setBounds(new Rectangle(2*bounds.width/3+1, fr.FONT_HEIGHT*2+21, bounds.width/3 -1, (bounds.height-fr.FONT_HEIGHT*2-21))); + + previous.setBounds(new Rectangle(0, fr.FONT_HEIGHT*2+21, 50, 20)); + next.setBounds(new Rectangle(2*bounds.width/3-50, fr.FONT_HEIGHT*2+21, 50, 20)); + goBack.setBounds(new Rectangle(0,0, fr.FONT_HEIGHT*2+20, fr.FONT_HEIGHT*2+20)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + // background + Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0xFF141414, 0.0f)); + // top bar + Gui.drawRect(0,0,getBounds().width, fr.FONT_HEIGHT*2+21, RenderUtils.blendAlpha(0xFF141414, 0.05f)); + // lines + Gui.drawRect(0,fr.FONT_HEIGHT*2+20,getBounds().width, fr.FONT_HEIGHT*2+21, -1); + Gui.drawRect(panelPartyFinderSettings.getBounds().x-1,fr.FONT_HEIGHT*2+20,panelPartyFinderSettings.getBounds().x, getBounds().height, -1); + // prev next bar + Gui.drawRect(0,fr.FONT_HEIGHT*2+21,scrollablePanel.getBounds().width, fr.FONT_HEIGHT*2+41, RenderUtils.blendAlpha(0xFF141414, 0.08f)); + + GlStateManager.pushMatrix(); + GlStateManager.translate(fr.FONT_HEIGHT*2+21, 0,0); + GlStateManager.scale(2,2,1); + fr.drawString("Party Finder", 5,5,-1); + GlStateManager.popMatrix(); + fr.drawString("Page "+page, (scrollablePanel.getBounds().width-fr.getStringWidth("Page "+page))/2, (20-fr.FONT_HEIGHT)/2 + fr.FONT_HEIGHT*2+21, -1); + } + + public synchronized void onChestUpdate(WindowUpdateEvent windowUpdateEvent) { + if (windowUpdateEvent == null) { + GuiChest guiChest = guiCustomPartyFinder.getGuiChest(); + if (guiChest == null) { + panelPartyListElementMap.clear(); + } else { + for (int x = 1; x<=7; x++) { + for (int y = 1; y <= 3; y++) { + int i = y * 9 + x; + Slot s = guiChest.inventorySlots.getSlot(i); + PanelPartyListElement prev = panelPartyListElementMap.remove(i); + if (s == null || !s.getHasStack()) { continue; } + if (!filter(s.getStack())) continue; + + if (prev == null) prev = new PanelPartyListElement(this, i); + panelPartyListElementMap.put(i, prev); + } + } + + { + Slot next = guiChest.inventorySlots.getSlot(9 * 2 + 8); + if (next.getStack() != null && next.getStack().getItem() == Items.arrow) { + this.next.setEnabled(true); + extractPage(next.getStack()); + } else { + this.next.setEnabled(false); + } + + Slot prev = guiChest.inventorySlots.getSlot(9 * 2 + 0); + if (prev.getStack() != null && prev.getStack().getItem() == Items.arrow) { + this.previous.setEnabled(true); + extractPage(prev.getStack()); + } else { + this.previous.setEnabled(false); + } + + Slot delist = guiChest.inventorySlots.getSlot(9 * 5 + 7); + panelPartyFinderSettings.setDelistable(delist.getStack() != null && delist.getStack().getItem() == Item.getItemFromBlock(Blocks.bookshelf)); + } + } + } else { + if (windowUpdateEvent.getPacketSetSlot() != null) { + int i = windowUpdateEvent.getPacketSetSlot().func_149173_d(); + + ItemStack stack = windowUpdateEvent.getPacketSetSlot().func_149174_e(); + if (i == 9*2+8) { + if (stack != null && stack.getItem() == Items.arrow) { + this.next.setEnabled(true); + extractPage(stack); + } else { + this.next.setEnabled(false); + } + } else if (i == 9*2) { + if (stack != null && stack.getItem() == Items.arrow) { + this.previous.setEnabled(true); + extractPage(stack); + } else { + this.previous.setEnabled(false); + } + } else if (i == 9*5+7) { + panelPartyFinderSettings.setDelistable(stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.bookshelf)); + } + + if (i%9 == 0 || i%9 == 8 || i/9 == 0 || i/9 >= 4) { + return; + } + + PanelPartyListElement prev = panelPartyListElementMap.remove(i); + if (filter(stack)) { + if (prev == null) prev = new PanelPartyListElement(this, i); + panelPartyListElementMap.put(i, prev); + } + } else if (windowUpdateEvent.getWindowItems() != null) { + for (int x = 1; x<=7; x++) { + for (int y = 1; y <= 3; y++) { + int i = y * 9 + x; + ItemStack item = windowUpdateEvent.getWindowItems().getItemStacks()[i]; + PanelPartyListElement prev = panelPartyListElementMap.remove(i); + if (!filter(item)) continue; + + if (prev == null) prev = new PanelPartyListElement(this, i); + panelPartyListElementMap.put(i, prev); + } + } + + { + ItemStack next = windowUpdateEvent.getWindowItems().getItemStacks()[9 * 2 + 8]; + if (next != null && next.getItem() == Items.arrow) { + this.next.setEnabled(true); + extractPage(next); + } else { + this.next.setEnabled(false); + } + + ItemStack prev = windowUpdateEvent.getWindowItems().getItemStacks()[9 * 2]; + if (prev != null && prev.getItem() == Items.arrow) { + this.previous.setEnabled(true); + extractPage(prev); + } else { + this.previous.setEnabled(false); + } + + ItemStack delist = windowUpdateEvent.getWindowItems().getItemStacks()[9*5+7]; + panelPartyFinderSettings.setDelistable(delist != null && delist.getItem() == Item.getItemFromBlock(Blocks.bookshelf)); + } + } + } + + addItems(); + } + + public boolean filter(ItemStack item) { + return !(item == null || item.getItem() == null || item.getItem() == Item.getItemFromBlock(Blocks.air)) && panelPartyFinderSettings.filter(item); + } + + public void extractPage(ItemStack itemStack) { + NBTTagCompound stackTagCompound = itemStack.getTagCompound(); + if (stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + for (int i = 0; i < nbttaglist1.tagCount(); i++) { + String str = nbttaglist1.getStringTagAt(i); + if (str.startsWith("§ePage ")) { + int pg = Integer.parseInt(str.substring(7)); + if (itemStack.getDisplayName().equals("§aPrevious Page")) page = pg+1; + else page = pg-1; + } + } + } + } + } + + public void addItems() { + for (MPanel childComponent : list.getChildComponents()) { + list.remove(childComponent); + } + for (Map.Entry<Integer, PanelPartyListElement> value : panelPartyListElementMap.entrySet()) { + list.add(value.getValue()); + } + scrollablePanel.evalulateContentArea(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java new file mode 100644 index 00000000..97c8eb40 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java @@ -0,0 +1,223 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MPassiveLabelAndElement; +import kr.syeyoung.dungeonsguide.gui.elements.MTextField; +import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.Items; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; + +import java.awt.*; +import java.util.List; + +public class PanelPartyFinderSettings extends MPanel { + private PanelPartyFinder panelPartyFinder; + + private MButton refresh = new MButton(), createNew = new MButton(), settings = new MButton(); + private MPassiveLabelAndElement filterCantjoin, filterWhitelistNote, filterBlacklistNote, plaeHighlightNote; private MToggleButton filterCantjoinButton; + private MTextField filterWhitelist, filterBlacklist, highlightNote; + + @Getter @Setter + boolean delistable = false; + + public void setDelistable(boolean delistable) { + createNew.setText(delistable ? "De-list" : "Create New"); + this.delistable = delistable; + } + + public PanelPartyFinderSettings(PanelPartyFinder panelPartyFinder) { + this.panelPartyFinder = panelPartyFinder; + + createNew.setText("Create New"); + createNew.setOnActionPerformed(this::createNew); + createNew.setBackground(0xFF00838F); + createNew.setHover(0xFF00ACC1); + createNew.setClicked(0xFF0097A7); + add(createNew); + refresh.setText("Refresh"); + refresh.setOnActionPerformed(this::refresh); + add(refresh); + settings.setText("Search Settings"); + settings.setOnActionPerformed(this::settings); + add(settings); + + { + filterCantjoinButton = new MToggleButton(); + filterCantjoin = new MPassiveLabelAndElement("Filter Unjoinable", filterCantjoinButton); + filterCantjoin.setDivideRatio(0.7); + filterCantjoinButton.setOnToggle(() -> panelPartyFinder.onChestUpdate(null)); + add(filterCantjoin); + } + { + filterWhitelist = new MTextField() { + @Override + public void edit(String str) { + panelPartyFinder.onChestUpdate(null); + } + }; + filterBlacklist = new MTextField() { + @Override + public void edit(String str) { + panelPartyFinder.onChestUpdate(null); + } + }; + highlightNote = new MTextField(); + + filterWhitelistNote = new MPassiveLabelAndElement("Whitelist Note", filterWhitelist); + filterBlacklistNote = new MPassiveLabelAndElement("Blacklist Note", filterBlacklist); + plaeHighlightNote = new MPassiveLabelAndElement("Highlight Note (Regex)", highlightNote); + + filterWhitelistNote.setDivideRatio(0.5); + filterBlacklistNote.setDivideRatio(0.5); + plaeHighlightNote.setDivideRatio(0.5); + add(filterWhitelistNote); + add(filterBlacklistNote); + add(plaeHighlightNote); + } + } + + private void createNew() { + GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); + if (delistable) + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+7, 0, 0, Minecraft.getMinecraft().thePlayer); + else + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+0, 0, 0, Minecraft.getMinecraft().thePlayer); + + } + + public String getHighlightText() { + return highlightNote.getText(); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + + + GuiCustomPartyFinder guiCustomPartyFinder = panelPartyFinder.getGuiCustomPartyFinder(); + if (guiCustomPartyFinder.getGuiChest() == null) return; + Slot s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(9*5+5); + ItemStack itemStack = s.getStack(); + if (itemStack == null) return; + + String dungeon="", floor="", text=""; + { + NBTTagCompound stackTagCompound = itemStack.getTagCompound(); + if (stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + for (int i = 0; i < nbttaglist1.tagCount(); i++) { + String str = nbttaglist1.getStringTagAt(i); + if (str.startsWith("§aDungeon: ")) { + dungeon = str.substring(11); + } else if (str.startsWith("§aFloor: ")) { + floor = str.substring(9); + } else if (str.startsWith("§aSearch text: ")) { + text = str.substring(15); + } + } + } + } + } + fontRenderer.drawString("§aSearching: "+dungeon+" §7- "+floor, 5,155,-1); + fontRenderer.drawString("§aSearch text: "+text, 5,155+fontRenderer.FONT_HEIGHT,-1); + + Gui.drawRect(0,160+fontRenderer.FONT_HEIGHT*2,getBounds().width, 161+fontRenderer.FONT_HEIGHT*2, -1); + GlStateManager.translate(5,165+fontRenderer.FONT_HEIGHT*2,0); + + s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(9*5+8); + itemStack = s.getStack(); + if (itemStack == null || itemStack.getItem() != Items.skull) return; + + List<String> list = itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); + for (int i = 0; i < list.size(); ++i) { + if (i == 0) { + list.set(i, itemStack.getRarity().rarityColor + list.get(i)); + } else { + list.set(i, EnumChatFormatting.GRAY + list.get(i)); + } + } + for (int i = 0; i < list.size(); i++) { + fontRenderer.drawString(list.get(i), 0, (i)*fontRenderer.FONT_HEIGHT, -1); + } + } + + public void refresh() { + GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+1, 0, 0, Minecraft.getMinecraft().thePlayer); + } + public void settings() { + GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+5, 0, 0, Minecraft.getMinecraft().thePlayer); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + refresh.setBounds(new Rectangle(5,5,(bounds.width-10)/2,20)); + createNew.setBounds(new Rectangle(bounds.width/2,5,(bounds.width-10)/2,20)); + filterCantjoin.setBounds(new Rectangle(5,30,bounds.width-10,20)); + filterWhitelistNote.setBounds(new Rectangle(5,55,bounds.width-10,20)); + filterBlacklistNote.setBounds(new Rectangle(5,80,bounds.width-10,20)); + plaeHighlightNote.setBounds(new Rectangle(5,105,bounds.width-10,20)); + settings.setBounds(new Rectangle(5,130,bounds.width-10,20)); + } + + public boolean filter(ItemStack itemStack) { + NBTTagCompound stackTagCompound = itemStack.getTagCompound(); + String note = ""; + if (stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + for (int i = 0; i < nbttaglist1.tagCount(); i++) { + String str = nbttaglist1.getStringTagAt(i); + if (str.startsWith("§cRequires ") && filterCantjoinButton.isEnabled()) return false; + if (str.startsWith("§7§7Note:")) { + note = str.substring(12); + } + } + } + } + + if (!filterBlacklist.getText().isEmpty() && note.toLowerCase().contains(filterBlacklist.getText().toLowerCase())) return false; + if (!filterWhitelist.getText().isEmpty() && !note.toLowerCase().contains(filterWhitelist.getText().toLowerCase())) return false; + + return true; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java new file mode 100644 index 00000000..c0925a1e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java @@ -0,0 +1,197 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.config.guiconfig.MParameter; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; +import kr.syeyoung.dungeonsguide.gui.elements.MTooltipText; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; + +import java.awt.*; +import java.util.Arrays; +import java.util.List; + +public class PanelPartyListElement extends MPanel { + private PanelPartyFinder panelPartyFinder; + private int slot; + + public PanelPartyListElement(PanelPartyFinder panelPartyFinder, int slot) { + this.panelPartyFinder = panelPartyFinder; + this.slot = slot; + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(-1, 32); + } + + private MTooltip mTooltip; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + GuiCustomPartyFinder guiCustomPartyFinder = panelPartyFinder.getGuiCustomPartyFinder(); + if (guiCustomPartyFinder.getGuiChest() == null) return; + Slot s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(slot); + ItemStack itemStack = s.getStack(); + if (itemStack == null) return; + + + int color = RenderUtils.blendAlpha(0x141414, 0.0f); + + String note = ""; + boolean cantjoin = false; + if (itemStack.getItem() == Item.getItemFromBlock(Blocks.bedrock)) cantjoin = true; + int minClass = -1, minDungeon = -1; + { + NBTTagCompound stackTagCompound = itemStack.getTagCompound(); + if (stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + for (int i = 0; i < nbttaglist1.tagCount(); i++) { + String str = nbttaglist1.getStringTagAt(i); + if (str.startsWith("§7§7Note:")) { + note = str.substring(12); + } else if (str.startsWith("§7Class Level Required: §b")) { + minClass = Integer.parseInt(str.substring(26)); + } else if (str.startsWith("§7Dungeon Level Required: §b")) { + minDungeon = Integer.parseInt(str.substring(28)); + } else if (str.startsWith("§cRequires ")) cantjoin = true; + } + } + } + } + + note = note.replaceAll("(?i)(S\\+)", "§6$1§r"); + note = note.replaceAll("(?i)(carry)", "§4$1§r"); + + try { + if (!panelPartyFinder.getHighlightNote().isEmpty()) + note = note.replaceAll("(?i)(" + panelPartyFinder.getHighlightNote() + ")", "§e§l$1§r"); + } catch (Exception e) {} + + if (cantjoin) {} + else if (clicked) { + color = RenderUtils.blendAlpha(0x141414, 0.10f); + } else if (lastAbsClip.contains(absMousex, absMousey)) { + color = RenderUtils.blendAlpha(0x141414, 0.12f); + } + if (cantjoin) {} + else if (note.contains("§e")) { + color = RenderUtils.blendTwoColors(color, 0x44FFFF00); + } else if (note.contains("§6")){ + color = RenderUtils.blendTwoColors(color, 0x44FFAA00); + } + Gui.drawRect(0,0,getBounds().width,getBounds().height,color); + + RenderItem renderItem= Minecraft.getMinecraft().getRenderItem(); + GlStateManager.pushMatrix(); + RenderHelper.disableStandardItemLighting(); + RenderHelper.enableGUIStandardItemLighting(); + GlStateManager.scale(2,2,1); + GlStateManager.enableCull(); + renderItem.renderItemAndEffectIntoGUI(itemStack, 0,0); + GlStateManager.popMatrix(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.pushMatrix(); + GlStateManager.translate(37,(32 - 2*fr.FONT_HEIGHT)/2,0); + GlStateManager.scale(2,2,1); + String name = itemStack.getDisplayName(); + if (name.contains("'")) + name = name.substring(0, name.indexOf("'")); + fr.drawString(name, 0,0,-1); + + fr.drawString(note, fr.getStringWidth("AAAAAAAAAAAAAAAAAA")+5, 0,-1); + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + String sideNote = ""; + if (minClass != -1) sideNote = "§7CLv ≥§b"+minClass+" "; + if (minDungeon != -1) sideNote += "§7DLv ≥§b"+minDungeon+" "; + if (cantjoin) sideNote = "§cCan't join"; + sideNote = sideNote.trim(); + + GlStateManager.translate(getBounds().width,(32 - 2*fr.FONT_HEIGHT)/2,0); + GlStateManager.scale(2,2,0); + GlStateManager.translate(-fr.getStringWidth(sideNote), 0,0); + fr.drawString(sideNote, 0,0,-1); + + GlStateManager.popMatrix(); + if (lastAbsClip.contains(absMousex, absMousey) && (mTooltip == null || !mTooltip.isOpen())) { + if (mTooltip != null) mTooltip.close(); + List<String> list = itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); + for (int i = 0; i < list.size(); ++i) { + if (i == 0) { + list.set(i, itemStack.getRarity().rarityColor + list.get(i)); + } else { + list.set(i, EnumChatFormatting.GRAY + list.get(i)); + } + } + mTooltip = new MTooltipText(list); + mTooltip.open(this); + } else if (!lastAbsClip.contains(absMousex, absMousey)){ + if (mTooltip != null) + mTooltip.close(); + mTooltip = null; + } + } + + @Override + public void setParent(MPanel parent) { + super.setParent(parent); + if (parent == null && mTooltip != null) { + mTooltip.close(); + mTooltip = null; + } + } + + boolean clicked = false; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY)) { + clicked = true; + + GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, slot, 0, 0, Minecraft.getMinecraft().thePlayer); + } + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + clicked = false; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java index 7c35306d..feef2848 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java @@ -78,8 +78,8 @@ public class MGui extends GuiScreen { mainPanel.keyTyped0(typedChar, keyCode); super.keyTyped(typedChar, keyCode); } catch (Throwable e) { - if (!e.getMessage().contains("hack to stop")) - e.printStackTrace(); + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); } } @@ -90,7 +90,7 @@ public class MGui extends GuiScreen { mainPanel.mouseClicked0(mouseX, mouseY ,mouseX, mouseY, mouseButton); } catch (Throwable e) { - if (!e.getMessage().contains("hack to stop")) + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) e.printStackTrace(); } } @@ -106,7 +106,7 @@ public class MGui extends GuiScreen { mainPanel.mouseReleased0(mouseX, mouseY ,mouseX,mouseY , state); } catch (Throwable e) { - if (!e.getMessage().contains("hack to stop")) + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) e.printStackTrace(); } } @@ -117,7 +117,7 @@ public class MGui extends GuiScreen { mainPanel.mouseClickMove0(mouseX, mouseY ,mouseX ,mouseY, clickedMouseButton, timeSinceLastClick); } catch (Throwable e) { - if (!e.getMessage().contains("hack to stop")) + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) e.printStackTrace(); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java index 319a7af8..a91cb6c6 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java @@ -88,7 +88,7 @@ public class MPanel { public void add(MPanel child) { if (child.parent != null) throw new IllegalArgumentException("What have you done"); this.childComponents.add(child); - child.parent = this; + child.setParent(this); } public void openTooltip(MTooltip mPanel) { @@ -99,7 +99,7 @@ public class MPanel { } public void remove(MPanel panel) { - panel.parent = null; + panel.setParent(null); this.childComponents.remove(panel); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java index d30b82c9..da2ff78c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java @@ -37,9 +37,10 @@ public class MButton extends MPanel { private String text; private Color foreground = Color.white; - private Color hover = Color.gray; - private Color clicked = Color.lightGray; - private Color disabled = Color.darkGray; + private int background = RenderUtils.blendAlpha(0xFF141414, 0.08f); + private int hover = RenderUtils.blendAlpha(0xFF141414, 0.14f); + private int clicked = RenderUtils.blendAlpha(0xFF141414, 0.16f); + private int disabled =0xFF141414; private boolean enabled = true; @@ -49,14 +50,15 @@ public class MButton extends MPanel { public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { Dimension bounds = getSize(); - Color bg = backgroundColor; + int bg = background; if (!enabled) { bg = disabled; + } else if (isclicked) { + bg = clicked; } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { bg = hover; } - if (bg != null) - Gui.drawRect(0,0,getBounds().width, getBounds().height, bg.getRGB()); + Gui.drawRect(0,0,getBounds().width, getBounds().height, bg); FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; int width = renderer.getStringWidth(getText()); @@ -69,9 +71,18 @@ public class MButton extends MPanel { renderer.drawString(getText(), x,y, foreground.getRGB()); } + boolean isclicked = false; @Override public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (onActionPerformed != null && lastAbsClip.contains(absMouseX, absMouseY)) - onActionPerformed.run(); + if (lastAbsClip.contains(absMouseX, absMouseY)) { + isclicked = true; + if (onActionPerformed != null) + onActionPerformed.run(); + } + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + isclicked = false; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java index de3e4b40..f6df0e19 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java @@ -51,7 +51,7 @@ public class MList extends MPanel { for (int i = 1; i < getChildComponents().size(); i++) { MPanel panel = getChildComponents().get(i); Rectangle bound = panel.getBounds(); - Gui.drawRect(0,bound.y - (gap/2), getBounds().width, bound.y - (gap/2)+1, gapLineColor); + Gui.drawRect(0, bound.y - gap, getBounds().width, bound.y, gapLineColor); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java index af29f92a..a90e40e5 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java @@ -34,6 +34,9 @@ public class MPassiveLabelAndElement extends MPanel { @Getter @Setter private Runnable onClick; + @Getter @Setter + private double divideRatio = 1/3.0; + public MPassiveLabelAndElement(String label, MPanel element) { this.add(this.label = new MLabel()); this.label.setText(label); @@ -62,7 +65,7 @@ public class MPassiveLabelAndElement extends MPanel { @Override public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width / 3, getBounds().height)); - element.setBounds(new Rectangle(getBounds().width / 3,0,getBounds().width / 3 * 2, getBounds().height)); + label.setBounds(new Rectangle(0,0, (int) (getBounds().width * divideRatio), getBounds().height)); + element.setBounds(new Rectangle((int) (getBounds().width * divideRatio),0, (int) (getBounds().width * (1-divideRatio)), getBounds().height)); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java index ffdab32b..bdbf51d0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java @@ -112,7 +112,7 @@ public class MScrollablePanel extends MPanel { } } - private void evalulateContentArea() { + public void evalulateContentArea() { if (contentArea.getChildComponents().size() == 0) { contentAreaDim= new Rectangle(0,0,0,0); return; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java index c26a1b21..a971cc30 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java @@ -39,7 +39,7 @@ import java.io.IOException; public class MTextField extends MPanel { private final Color foreground = Color.white; - private String text = "asdasdasd"; + private String text = ""; private int cursorBlickTicker = 0; private int selectionStart = 0; |