diff options
Diffstat (limited to 'src/main/java/kr/syeyoung')
20 files changed, 816 insertions, 534 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index c5bff650..ee81ee2f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -32,12 +32,11 @@ import kr.syeyoung.dungeonsguide.features.impl.dungeon.*; 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; -import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureMechanicBrowse; +import kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser.FeatureMechanicBrowse; import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureSoulRoomWarning; import lombok.Getter; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java index 396d244d..52278f6b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java @@ -65,7 +65,7 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender @Override public void drawScreen(float partialTicks) { if (!isEnabled()) return; - GlStateManager.pushAttrib(); + GlStateManager.pushMatrix(); Rectangle featureRect = this.featureRect.getRectangleNoScale(); ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); @@ -78,7 +78,7 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender GL11.glDisable(GL11.GL_SCISSOR_TEST); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + GlStateManager.enableBlend(); GlStateManager.color(1,1,1,1); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java index f206c092..e5d41de3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java @@ -189,7 +189,7 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, if (this.<Boolean>getParameter("showtotalsecrets").getValue()) { for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + Point mapPt = mapProcessor.roomPointToMapPoint(dungeonRoom.getUnitPoints().get(0)); GlStateManager.translate(mapPt.x + mapProcessor.getUnitRoomDimension().width / 2, mapPt.y + mapProcessor.getUnitRoomDimension().height / 2, 0); @@ -218,7 +218,7 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); fr.drawString(str, -(fr.getStringWidth(str) / 2), -(fr.FONT_HEIGHT / 2), dungeonRoom.getCurrentState() == DungeonRoom.RoomState.FINISHED ? 0xFF00FF00 : (dungeonRoom.getColor() == 74 ? 0xff000000 : 0xFFFFFFFF)); - GlStateManager.popAttrib(); + GlStateManager.popMatrix(); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java index f74834e7..4d523e1e 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java @@ -348,7 +348,7 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen int ry = relY - startY; - GlStateManager.pushAttrib(); + GlStateManager.disableRescaleNormal(); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.disableLighting(); @@ -364,7 +364,7 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(playerProfile.get().getInventory()[(i+9) % 36], (i%9) * 18+1,(i/9) * 18+1); } - GlStateManager.popAttrib(); + if (toHover != null) { List<String> list = toHover.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); for (int i = 0; i < list.size(); ++i) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java deleted file mode 100644 index 5bd37c62..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java +++ /dev/null @@ -1,466 +0,0 @@ -/* - * 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.secret; - -import com.google.common.collect.Lists; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.features.listener.GuiClickListener; -import kr.syeyoung.dungeonsguide.features.listener.GuiPreRenderListener; -import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.*; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.MathHelper; -import net.minecraftforge.client.event.GuiScreenEvent; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.UUID; - -public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderListener, GuiClickListener, WorldRenderListener { - public FeatureMechanicBrowse() { - super("Dungeon Secret.Secret Pathfind","Secret Browser", "Browse and Pathfind secrets and mechanics in the current room", "secret.mechanicbrowse", false, 100, 300); - parameters.put("linecolor2", new FeatureParameter<AColor>("linecolor2", "Color", "Color of Pathfind line", new AColor(0xFF00FF00, true), "acolor")); - parameters.put("linethickness", new FeatureParameter<Float>("linethickness", "Thickness", "Thickness of Pathfind line", 1.0f, "float")); - parameters.put("refreshrate", new FeatureParameter<Integer>("refreshrate", "Line Refreshrate", "How many ticks per line refresh?", 10, "integer")); - } - - public AColor getColor() { - return this.<AColor>getParameter("linecolor2").getValue(); - } - public float getThickness() { - return this.<Float>getParameter("linethickness").getValue(); - } - public int getRefreshRate() { - return this.<Integer>getParameter("refreshrate").getValue(); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private UUID lastRoomUID = null; - @Override - public void drawHUD(float partialTicks) { - if (Minecraft.getMinecraft().currentScreen != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiGuiLocationConfig - || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonRoomEdit - || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonAddSet - || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonParameterEdit - || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonValueEdit - || Minecraft.getMinecraft().currentScreen instanceof GuiContainer - || Minecraft.getMinecraft().currentScreen instanceof GuiIngameMenu)) return; - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; - DungeonContext context = skyblockStatus.getContext(); - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom == null) return; - if (!dungeonRoom.getDungeonRoomInfo().getUuid().equals(lastRoomUID)) { - selected = -1; - selectedState = -1; - dy = 0; - } - lastRoomUID = dungeonRoom.getDungeonRoomInfo().getUuid(); - - if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; - - GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - - Rectangle feature = getFeatureRect().getRectangle(); - FontRenderer fr = getFontRenderer(); - - Gui.drawRect(0, 0, feature.width, fr.FONT_HEIGHT + 4, 0xFF444444); - Gui.drawRect(1, 1, feature.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Selected: ", 2,2, 0xFFAAAAAA); - if (grp.getPath() == null) - fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000); - else { - ActionRoute route = grp.getPath(); - fr.drawString(route.getMechanic()+" -> "+route.getState(), fr.getStringWidth("Selected: ") + 2,2, 0xFFFFFF00); - } - fr.drawString("Open any gui to browse", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA); - } - - @Override - public void drawDemo(float partialTicks) { - Rectangle feature = getFeatureRect().getRectangle(); - FontRenderer fr = getFontRenderer(); - - Gui.drawRect(0, 0, feature.width, fr.FONT_HEIGHT + 4, 0xFF444444); - Gui.drawRect(1, 1, feature.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Selected: ", 2,2, 0xFFAAAAAA); - fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000); - fr.drawString("Open any gui to browse", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA); - } - - @Override - public void onGuiPreRender(GuiScreenEvent.DrawScreenEvent.Pre rendered) { - if (!isEnabled()) return; - if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) return; - - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; - DungeonContext context = skyblockStatus.getContext(); - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom == null) return; - if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; - int width = Minecraft.getMinecraft().displayWidth; - int height = Minecraft.getMinecraft().displayHeight; - int mouseX = Mouse.getX() ; - int mouseY = height - Mouse.getY() - 1; - GlStateManager.pushMatrix(); - GlStateManager.enableTexture2D(); - GlStateManager.disableLighting(); - GlStateManager.color(1, 1, 1, 1); - - GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - - Rectangle feature = getFeatureRect().getRectangle(); - FontRenderer fr = getFontRenderer(); - GlStateManager.translate(feature.x, feature.y, 0); - Gui.drawRect(0, 0, feature.width, fr.FONT_HEIGHT + 4, 0xFF444444); - Gui.drawRect(1, 1, feature.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Selected: ", 2,2, 0xFFAAAAAA); - if (grp.getPath() == null) - fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000); - else { - ActionRoute route = grp.getPath(); - fr.drawString(route.getMechanic()+" -> "+route.getState(), fr.getStringWidth("Selected: ") + 2,2, 0xFFFFFF00); - } - GlStateManager.translate(0, fr.FONT_HEIGHT + 4, 0); - Gui.drawRect(0, 0, feature.width, feature.height - fr.FONT_HEIGHT - 4, 0xFF444444); - Gui.drawRect(1, 1, feature.width - 1,feature.height - fr.FONT_HEIGHT - 5, 0xFF262626); - clip(new ScaledResolution(Minecraft.getMinecraft()), feature.x, feature.y + fr.FONT_HEIGHT + 5, feature.width , feature.height - fr.FONT_HEIGHT - 6); - GL11.glEnable(GL11.GL_SCISSOR_TEST); - GlStateManager.translate(0, -dy, 0); - - GlStateManager.pushMatrix(); - GlStateManager.translate(2,2, 0); - setupMechanics(); - for (int i = 0; i < sortedMechanics.size(); i++) { - Object obj = sortedMechanics.get(i); - if (selected == i) { - Gui.drawRect(-1, i * fr.FONT_HEIGHT, feature.width - 3, i * fr.FONT_HEIGHT + fr.FONT_HEIGHT - 1, 0xFF444444); - } else if (new Rectangle(feature.x, feature.y + fr.FONT_HEIGHT + 6 - dy + i * fr.FONT_HEIGHT, feature.width, fr.FONT_HEIGHT).contains(mouseX, mouseY)) { - Gui.drawRect(-1, i * fr.FONT_HEIGHT, feature.width - 3, i * fr.FONT_HEIGHT + fr.FONT_HEIGHT - 1, 0xFF555555); - } - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (obj instanceof DungeonMechanic) { - String name = sortedMechanicsName.get(i); - fr.drawString(name, 3, i * fr.FONT_HEIGHT, 0xFFFFFF00); - fr.drawString(" ("+ ((DungeonMechanic) obj).getCurrentState(dungeonRoom) +", "+ - (((DungeonMechanic) obj).getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double(((DungeonMechanic) obj).getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)",fr.getStringWidth(name) + 3, i * fr.FONT_HEIGHT, 0xFFAAAAAA); - } else if ("$SPECIAL-CANCEL".equals(obj)) { - fr.drawString("Cancel Current", 3, i * fr.FONT_HEIGHT, 0xFF00FFFF); - } else { - Gui.drawRect(-1, i * fr.FONT_HEIGHT, feature.width - 3, i * fr.FONT_HEIGHT + fr.FONT_HEIGHT - 1, 0xFF444444); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString((String)obj, 3, i * fr.FONT_HEIGHT, 0xFFEEEEEE); - } - } - GlStateManager.popMatrix(); - - if (selected != -1) { - - boolean overFlows = new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth() < feature.x + 2*feature.width; - - clip(new ScaledResolution(Minecraft.getMinecraft()), overFlows ? feature.x - feature.width : feature.x + feature.width, feature.y + fr.FONT_HEIGHT + 5, feature.width , feature.height - fr.FONT_HEIGHT - 6); - GlStateManager.translate(overFlows ? - feature.width : feature.width, selected * fr.FONT_HEIGHT, 0); - Gui.drawRect(0, 0, feature.width, fr.FONT_HEIGHT * possibleStates.size() + 4, 0xFF444444); - Gui.drawRect(-1, 1, feature.width - 1, fr.FONT_HEIGHT * possibleStates.size() + 3, 0xFF262626); - GlStateManager.translate(2,2, 0); - - Point popupStart = new Point(overFlows ? feature.x - feature.width : feature.x + feature.width, (selected + 1) * fr.FONT_HEIGHT +6 + feature.y - dy + 2); - for (int i = 0; i < possibleStates.size(); i++) { - if (new Rectangle(overFlows ? feature.x - feature.width : feature.x + feature.width, popupStart.y + i * fr.FONT_HEIGHT, feature.width, fr.FONT_HEIGHT).contains(mouseX, mouseY)) { - Gui.drawRect(-2, i * fr.FONT_HEIGHT, feature.width - 3, i * fr.FONT_HEIGHT + fr.FONT_HEIGHT - 1, 0xFF555555); - } - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(possibleStates.get(i), 0, i * fr.FONT_HEIGHT, 0xFFFFFFFF); - } - } - GL11.glDisable(GL11.GL_SCISSOR_TEST); - - GlStateManager.popMatrix(); - GlStateManager.enableTexture2D(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - private void clip(ScaledResolution resolution, int x, int y, int width, int height) { - int scale = resolution.getScaleFactor(); - GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); - } - - private int dy = 0; - private int selected = -1; - private int selectedState = -1; - private List<String> possibleStates = new ArrayList<String>(); - private final List<Object> sortedMechanics = new ArrayList<Object>(); - private final List<String> sortedMechanicsName = new ArrayList<String>(); - private void setupMechanics() { - sortedMechanics.clear(); - sortedMechanicsName.clear(); - - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; - DungeonContext context = skyblockStatus.getContext(); - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom == null) return; - if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; - - sortedMechanics.add("$SPECIAL-CANCEL"); - sortedMechanicsName.add(""); - - boolean found = false; - for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonFairySoul) { - if (!found) { - sortedMechanics.add("Fairy Souls"); - sortedMechanicsName.add(""); - found = true; - } - sortedMechanics.add(value.getValue()); - sortedMechanicsName.add(value.getKey()); - } - } - found = false; - for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonSecret) { - if (!found) { - sortedMechanics.add("Secrets"); - sortedMechanicsName.add(""); - found = true; - } - sortedMechanics.add(value.getValue()); - sortedMechanicsName.add(value.getKey()); - } - } - found = false; - for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonTomb) { - if (!found) { - sortedMechanics.add("Crypts"); - sortedMechanicsName.add(""); - found = true; - } - sortedMechanics.add(value.getValue()); - sortedMechanicsName.add(value.getKey()); - } - } - found = false; - for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonNPC) { - if (!found) { - sortedMechanics.add("NPC"); - sortedMechanicsName.add(""); - found = true; - } - sortedMechanics.add(value.getValue()); - sortedMechanicsName.add(value.getKey()); - } - } - found = false; - for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonJournal) { - if (!found) { - sortedMechanics.add("Journals"); - sortedMechanicsName.add(""); - found = true; - } - sortedMechanics.add(value.getValue()); - sortedMechanicsName.add(value.getKey()); - } - } - found = false; - for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonRoomDoor){ - if (!found) { - sortedMechanics.add("Gates"); - sortedMechanicsName.add(""); - found = true; - } - sortedMechanics.add(value.getValue()); - sortedMechanicsName.add(value.getKey()); - } - } - found = false; - for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonDoor || value.getValue() instanceof DungeonBreakableWall || value.getValue() instanceof DungeonLever - || value.getValue() instanceof DungeonOnewayDoor || value.getValue() instanceof DungeonOnewayLever || value.getValue() instanceof DungeonPressurePlate) { - if (!found) { - sortedMechanics.add("ETC"); - sortedMechanicsName.add(""); - found = true; - } - sortedMechanics.add(value.getValue()); - sortedMechanicsName.add(value.getKey()); - } - } - } - - @Override - public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { - if (!isEnabled()) return; - if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) return; - - - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; - DungeonContext context = skyblockStatus.getContext(); - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom == null) return; - if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; - - int width = Minecraft.getMinecraft().displayWidth; - int height = Minecraft.getMinecraft().displayHeight; - int mouseX = Mouse.getX(); - int mouseY = height - Mouse.getY() - 1; - - Rectangle feature = getFeatureRect().getRectangle(); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - boolean overFlows = new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth() < feature.x + 2*feature.width; - - Point popupStart = new Point(overFlows ? feature.x - feature.width : feature.x + feature.width, (selected + 1) * fr.FONT_HEIGHT +6 + feature.y - dy); - if (feature.contains(mouseX, mouseY)) { - mouseInputEvent.setCanceled(true); - - int wheel = Mouse.getDWheel(); - if (wheel > 0) dy -= fr.FONT_HEIGHT; - else if (wheel < 0) dy += fr.FONT_HEIGHT; - - if (-dy + sortedMechanics.size() * fr.FONT_HEIGHT < feature.height - fr.FONT_HEIGHT - 6) dy = -(feature.height - fr.FONT_HEIGHT - 6) + sortedMechanics.size() * fr.FONT_HEIGHT; - if (dy < 0) dy = 0; - - - if (Mouse.getEventButton() != -1) { - int yDiff = mouseY + dy - feature.y - fr.FONT_HEIGHT - 6; - selected = yDiff / fr.FONT_HEIGHT; - - if (selected < 0) selected = -1; - if (selected >= sortedMechanics.size()) selected = -1; - if (selected == -1) { - possibleStates.clear(); - } else if (sortedMechanics.get(selected) instanceof DungeonMechanic){ - possibleStates = Lists.newArrayList(((DungeonMechanic) sortedMechanics.get(selected)).getPossibleStates(dungeonRoom)); - } else if ("$SPECIAL-CANCEL".equals(sortedMechanics.get(selected))) { - ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).cancel(); - possibleStates.clear(); - selected = -1; - selectedState = -1; - } else { - possibleStates.clear(); - selected = -1; - selectedState = -1; - } - } - } else if (selected != -1 && sortedMechanics.get(selected) instanceof DungeonMechanic && - new Rectangle(popupStart, new Dimension(feature.width, ((DungeonMechanic) sortedMechanics.get(selected)).getPossibleStates(dungeonRoom).size() * fr.FONT_HEIGHT)).contains(mouseX, mouseY)) { - mouseInputEvent.setCanceled(true); - if (Mouse.getEventButton() != -1) { - int yDiff = mouseY - popupStart.y - 2; - int preSelectedState = yDiff / fr.FONT_HEIGHT ; - if (preSelectedState < 0) preSelectedState = -1; - if (preSelectedState >= possibleStates.size()) preSelectedState = - possibleStates.size() - 1; - - if (preSelectedState == selectedState && preSelectedState != -1) { - ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).pathfind(sortedMechanicsName.get(selected), - possibleStates.get(selectedState)); - selected = -1; - selectedState = -1; - possibleStates.clear(); - } - selectedState = preSelectedState; - } - } else if (Mouse.getEventButton() != -1){ - possibleStates.clear(); - selectedState = -1; - selected = -1; - } - } - - @Override - public void drawWorld(float partialTicks) { - if (!isEnabled()) return; - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; - DungeonContext context = skyblockStatus.getContext(); - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom == null) return; - if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; - if (selected != -1) { - if (sortedMechanics.size() <= selected) return; - ((DungeonMechanic)sortedMechanics.get(selected)).highlight(new Color(0,255,255,50), sortedMechanicsName.get(selected) +" ("+(((DungeonMechanic) - sortedMechanics.get(selected)).getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double(((DungeonMechanic) sortedMechanics.get(selected)).getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)", dungeonRoom, partialTicks); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java new file mode 100644 index 00000000..1eaaa15f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java @@ -0,0 +1,188 @@ +/* + * 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.secret.mechanicbrowser; + +import com.google.common.collect.Lists; +import kr.syeyoung.dungeonsguide.DungeonsGuide; +import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.config.types.AColor; +import kr.syeyoung.dungeonsguide.config.types.GUIRectangle; +import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.GuiFeature; +import kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser.MGuiMechanicBrowser; +import kr.syeyoung.dungeonsguide.features.listener.GuiClickListener; +import kr.syeyoung.dungeonsguide.features.listener.GuiPreRenderListener; +import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.features.text.StyledTextRenderer; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; +import kr.syeyoung.dungeonsguide.gui.elements.MPassiveLabelAndElement; +import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit; +import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.utils.GlStateUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.*; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.util.MathHelper; +import net.minecraftforge.client.event.GuiScreenEvent; +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.*; +import java.util.List; + +public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderListener, GuiClickListener, WorldRenderListener { + public FeatureMechanicBrowse() { + super("Dungeon Secret.Secret Pathfind","Secret Browser", "Browse and Pathfind secrets and mechanics in the current room", "secret.mechanicbrowse", false, 100, 300); + parameters.put("linecolor2", new FeatureParameter<AColor>("linecolor2", "Color", "Color of Pathfind line", new AColor(0xFF00FF00, true), "acolor")); + parameters.put("linethickness", new FeatureParameter<Float>("linethickness", "Thickness", "Thickness of Pathfind line", 1.0f, "float")); + parameters.put("refreshrate", new FeatureParameter<Integer>("refreshrate", "Line Refreshrate", "How many ticks per line refresh?", 10, "integer")); + parameters.put("scale", new FeatureParameter<Float>("scale", "Scale", "Scale", 1.0f, "float")); + mGuiMechanicBrowser = new MGuiMechanicBrowser(this); + mGuiMechanicBrowser.setWorldAndResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); + lastWidth = Minecraft.getMinecraft().displayWidth; lastHeight = Minecraft.getMinecraft().displayHeight; + } + + public AColor getColor() { + return this.<AColor>getParameter("linecolor2").getValue(); + } + public float getThickness() { + return this.<Float>getParameter("linethickness").getValue(); + } + public int getRefreshRate() { + return this.<Integer>getParameter("refreshrate").getValue(); + } + public double getScale() { + return this.<Float>getParameter("scale").getValue(); + } + + private MGuiMechanicBrowser mGuiMechanicBrowser; + + + @Override + public void drawDemo(float partialTicks) { + super.drawDemo(partialTicks); + double scale = FeatureMechanicBrowse.this.<Float>getParameter("scale").getValue(); + GlStateManager.scale(scale, scale, 1.0); + + Dimension bigDim = getFeatureRect().getRectangleNoScale().getSize(); + Dimension effectiveDim = new Dimension((int) (bigDim.width / scale),(int)( bigDim.height / scale)); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + Gui.drawRect(0, 0, effectiveDim.width, fr.FONT_HEIGHT + 4, 0xFF444444); + Gui.drawRect(1, 1, effectiveDim.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Selected: ", 2,2, 0xFFAAAAAA); + fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000); + fr.drawString("Open Chat to Select Secrets", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA); + } + + private int lastWidth, lastHeight; + + @Override + public void drawScreen(float partialTicks) { + if (!isEnabled()) return; + int i = Mouse.getEventX(); + int j = Minecraft.getMinecraft().displayHeight - Mouse.getEventY(); + if (Minecraft.getMinecraft().displayWidth != lastWidth || Minecraft.getMinecraft().displayHeight != lastHeight) mGuiMechanicBrowser.initGui(); + lastWidth = Minecraft.getMinecraft().displayWidth; lastHeight = Minecraft.getMinecraft().displayHeight; + mGuiMechanicBrowser.drawScreen(i,j,partialTicks); + } + + @Override + public void setFeatureRect(GUIRectangle featureRect) { + super.setFeatureRect(featureRect); + mGuiMechanicBrowser.initGui(); + } + + @Override + public void drawHUD(float partialTicks) { } + + @Override + public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + try { + mGuiMechanicBrowser.handleMouseInput(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + @Override + public void onGuiPreRender(GuiScreenEvent.DrawScreenEvent.Pre rendered) { + int i = Mouse.getEventX(); + int j = Minecraft.getMinecraft().displayHeight - Mouse.getEventY(); + mGuiMechanicBrowser.drawScreen(i, j, rendered.renderPartialTicks); + } + + @Override + public void drawWorld(float partialTicks) { + if (!isEnabled()) return; + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + if (!skyblockStatus.isOnDungeon()) return; + if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; + DungeonContext context = skyblockStatus.getContext(); + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom == null) return; + if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; + String id = mGuiMechanicBrowser.getPanelMechanicBrowser().getSelectedID(); + if (id != null) { + Optional.ofNullable(dungeonRoom.getMechanics().get(mGuiMechanicBrowser.getPanelMechanicBrowser().getSelectedID())) + .ifPresent(a -> { + a.highlight(new Color(0,255,255,50), id +" ("+( + dungeonRoom.getMechanics().get(id).getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double((dungeonRoom.getMechanics().get(id)).getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", dungeonRoom, partialTicks); + }); + } + } + @Override + public List<MPanel> getTooltipForEditor(GuiGuiLocationConfig guiGuiLocationConfig) { + List<MPanel> mPanels = super.getTooltipForEditor(guiGuiLocationConfig); + + mPanels.add(new MPassiveLabelAndElement("Scale", new MFloatSelectionButton(FeatureMechanicBrowse.this.<Float>getParameter("scale").getValue()) {{ + setOnUpdate(() ->{ + FeatureMechanicBrowse.this.<Float>getParameter("scale").setValue(this.getData()); + }); } + })); + + return mPanels; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java new file mode 100644 index 00000000..6ef99866 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java @@ -0,0 +1,45 @@ +/* + * 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.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.gui.MGui; +import lombok.Getter; + +public class MGuiMechanicBrowser extends MGui { + private FeatureMechanicBrowse featureMechanicBrowse; + @Getter + private PanelMechanicBrowser panelMechanicBrowser; + public MGuiMechanicBrowser(FeatureMechanicBrowse mechanicBrowse) { + this.featureMechanicBrowse = mechanicBrowse; + panelMechanicBrowser = new PanelMechanicBrowser(mechanicBrowse); + getMainPanel().add(panelMechanicBrowser); + } + + @Override + public void initGui() { + super.initGui(); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + panelMechanicBrowser.setBounds(featureMechanicBrowse.getFeatureRect().getRectangle()); + panelMechanicBrowser.setScale(featureMechanicBrowse.getScale()); + super.drawScreen(mouseX, mouseY, partialTicks); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java new file mode 100644 index 00000000..ca803bff --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java @@ -0,0 +1,65 @@ +/* + * 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.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.utils.GlStateUtils; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; +import lombok.AllArgsConstructor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Supplier; + +@AllArgsConstructor +public class MechanicBrowserElement extends MPanel { + private Supplier<String> name; + private boolean isCategory = false; + private BiConsumer<MechanicBrowserElement, Point> onClick; + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (isCategory || isFocused) + Gui.drawRect(0, 0, bounds.width, bounds.height, 0xFF444444); + else if (lastAbsClip.contains(absMousex, absMousey)) + Gui.drawRect(0, 0, bounds.width, bounds.height, 0xFF555555); + Minecraft.getMinecraft().fontRendererObj.drawString((String)name.get(), 4, 1, 0xFFEEEEEE); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(Minecraft.getMinecraft().fontRendererObj.getStringWidth(name.get()) + 8, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY) && onClick != null) + onClick.accept(this, new Point(lastParentPoint.x + bounds.x, lastParentPoint.y + bounds.y)); + } + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY) && onClick != null) + setCursor(EnumCursor.POINTING_HAND); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java new file mode 100644 index 00000000..e2a0d028 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java @@ -0,0 +1,68 @@ +/* + * 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.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.gui.elements.MList; +import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; +import lombok.Getter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +public class MechanicBrowserTooltip extends MTooltip { + @Getter + private MList mList; + public MechanicBrowserTooltip() { + mList = new MList(); + mList.setGap(0); + add(mList); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Dimension effectiveDim = getEffectiveDimension(); + Gui.drawRect(0, 0, effectiveDim.width, effectiveDim.height, 0xFF444444); + Gui.drawRect(1, 1, effectiveDim.width - 1, effectiveDim.height - 1, 0xFF262626); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + mList.setBounds(new Rectangle(1,1, getEffectiveDimension().width-2, getEffectiveDimension().height-2)); + mList.realignChildren(); + } + + @Override + public void setScale(double scale) { + super.setScale(scale); + mList.setBounds(new Rectangle(1,1, getEffectiveDimension().width-2, getEffectiveDimension().height-2)); + mList.realignChildren(); + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = mList.getPreferredSize(); + return new Dimension((int) ((dim.width + 2) * getScale()), (int) ((dim.height + 2) * getScale())); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (!lastAbsClip.contains(absMouseX, absMouseY)) close(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java new file mode 100644 index 00000000..866d5773 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java @@ -0,0 +1,326 @@ +/* + * 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.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.DungeonsGuide; +import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MList; +import kr.syeyoung.dungeonsguide.gui.elements.MPanelScaledGUI; +import kr.syeyoung.dungeonsguide.gui.elements.MScrollablePanel; +import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; +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.GuiChat; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class PanelMechanicBrowser extends MPanelScaledGUI { + private FeatureMechanicBrowse feature; + private MScrollablePanel scrollablePanel; + private MList mList; + private MechanicBrowserTooltip mechanicBrowserTooltip; + + public PanelMechanicBrowser(FeatureMechanicBrowse mechanicBrowse) { + this.feature = mechanicBrowse; + this.scrollablePanel = new MScrollablePanel(1); + add(this.scrollablePanel); + scrollablePanel.getScrollBarY().setWidth(0); + mList = new MList() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0,0,parentWidth,parentHeight)); + Dimension prefSize = getPreferredSize(); + int hei = prefSize.height; + setBounds(new Rectangle(0,0,parentWidth,hei)); + realignChildren(); + } + }; + mList.setDrawLine(false); mList.setGap(0); + scrollablePanel.add(mList); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + toggleTooltip(openGUI()); + + Optional<DungeonRoom> dungeonRoomOpt = Optional.ofNullable(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext()) + .map(DungeonContext::getMapProcessor).map(a->a.worldPointToRoomPoint(Minecraft.getMinecraft().thePlayer.getPosition())) + .map(a -> DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext().getRoomMapper().get(a)); + + DungeonRoom dungeonRoom = dungeonRoomOpt.orElse(null); + renderTick(dungeonRoom); + if (dungeonRoom == null) return; + if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; + + GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + Dimension effectiveDim = getEffectiveDimension(); + + Gui.drawRect(0, 0, effectiveDim.width, fr.FONT_HEIGHT + 4, 0xFF444444); + Gui.drawRect(1, 1, effectiveDim.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Selected: ", 2,2, 0xFFAAAAAA); + if (grp.getPath() == null) + fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000); + else { + ActionRoute route = grp.getPath(); + fr.drawString(route.getMechanic()+" -> "+route.getState(), fr.getStringWidth("Selected: ") + 2,2, 0xFFFFFF00); + } + fr.drawString("Open Chat to Select Secrets", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA); + + if (!openGUI()) return; + + Gui.drawRect(0, fr.FONT_HEIGHT + 4, effectiveDim.width, effectiveDim.height, 0xFF444444); + Gui.drawRect(1, fr.FONT_HEIGHT + 5, effectiveDim.width - 1,effectiveDim.height - 1, 0xFF262626); + } + + private UUID lastRoomUID = null; + public void renderTick(DungeonRoom dungeonRoom) { + if (dungeonRoom == null && lastRoomUID != null) { + lastRoomUID = null; + for (MPanel childComponent : mList.getChildComponents()) { + mList.remove(childComponent); + } + if (mechanicBrowserTooltip != null) { + mechanicBrowserTooltip.close(); + mechanicBrowserTooltip = null; + } + selectedID = null; + } else if (dungeonRoom != null && lastRoomUID != dungeonRoom.getDungeonRoomInfo().getUuid()) { + lastRoomUID = dungeonRoom.getDungeonRoomInfo().getUuid(); + // SETUP THINGS. + for (MPanel childComponent : mList.getChildComponents()) { + mList.remove(childComponent); + } + if (mechanicBrowserTooltip != null) { + mechanicBrowserTooltip.close(); + mechanicBrowserTooltip = null; + } + selectedID = null; + mList.add(new MechanicBrowserElement(() -> "§bCancel Current", false, (pt, me) -> cancel(pt))); + + boolean found = false; + for (Map.Entry<String, DungeonMechanic> value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonFairySoul) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Fairy Soul", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" §7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry<String, DungeonMechanic> value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonSecret) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Secrets", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" §7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry<String, DungeonMechanic> value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonTomb) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Crypts", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" §7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry<String, DungeonMechanic> value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonNPC) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "NPC", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" §7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry<String, DungeonMechanic> value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonJournal) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Journals", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" §7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry<String, DungeonMechanic> value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonRoomDoor){ + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Gates", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" §7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry<String, DungeonMechanic> value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonDoor || value.getValue() instanceof DungeonBreakableWall || value.getValue() instanceof DungeonLever + || value.getValue() instanceof DungeonOnewayDoor || value.getValue() instanceof DungeonOnewayLever || value.getValue() instanceof DungeonPressurePlate) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "ETC", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" §7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + + scrollablePanel.evalulateContentArea(); + + } + } + + private int latestTooltipDY; + @Getter + private String selectedID = null; + public void onElementClick(String id, DungeonMechanic dungeonMechanic, Point pt, MechanicBrowserElement mechanicBrowserElement) { + Optional<DungeonRoom> dungeonRoomOpt = Optional.ofNullable(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext()) + .map(DungeonContext::getMapProcessor).map(a->a.worldPointToRoomPoint(Minecraft.getMinecraft().thePlayer.getPosition())) + .map(a -> DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext().getRoomMapper().get(a)); + selectedID = id; + + DungeonRoom dungeonRoom = dungeonRoomOpt.orElse(null); + if (dungeonRoom == null) return; + DungeonMechanic dungeonMechanic1 = dungeonRoom.getMechanics().get(id); + if (dungeonMechanic1 != dungeonMechanic) return; + Set<String> states = dungeonMechanic1.getPossibleStates(dungeonRoom); + System.out.println(states); + + + if (mechanicBrowserTooltip != null) { + mechanicBrowserTooltip.close(); + } + + latestTooltipDY = (int) (pt.y * getScale() - bounds.y - 1); + + mechanicBrowserTooltip = new MechanicBrowserTooltip(); + for (String state : states) { + mechanicBrowserTooltip.getMList().add(new MechanicBrowserElement(() -> state, false, (m2, pt2) -> { + if (dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor) + ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).pathfind(id, state); + mechanicBrowserTooltip.close(); + mechanicBrowserTooltip = null; + })); + } + mechanicBrowserTooltip.setScale(getScale()); + Dimension prefSize = mechanicBrowserTooltip.getPreferredSize(); + mechanicBrowserTooltip.setBounds(new Rectangle(bounds.x + bounds.width, latestTooltipDY + bounds.y, prefSize.width, prefSize.height)); + mechanicBrowserTooltip.open(this); + } + + public void cancel(MechanicBrowserElement mechanicBrowserElement) { + Optional<DungeonRoom> dungeonRoomOpt = Optional.ofNullable(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext()) + .map(DungeonContext::getMapProcessor).map(a->a.worldPointToRoomPoint(Minecraft.getMinecraft().thePlayer.getPosition())) + .map(a -> DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext().getRoomMapper().get(a)); + mechanicBrowserElement.setFocused(false); + if (!dungeonRoomOpt.isPresent()) return; + DungeonRoom dungeonRoom = dungeonRoomOpt.get(); + if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; + ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).cancel(); + } + + public void toggleTooltip(boolean open) { + if (mechanicBrowserTooltip != null) { + if (open) { + mechanicBrowserTooltip.open(this); + } else { + mechanicBrowserTooltip.close(); + } + } + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + Dimension dimension = getEffectiveDimension(); + int y = Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT + 4; + scrollablePanel.setBounds(new Rectangle(1,y + 1, dimension.width - 2, dimension.height - y - 2)); + scrollablePanel.evalulateContentArea(); + if (mechanicBrowserTooltip != null) { + Dimension prefSize = mechanicBrowserTooltip.getPreferredSize(); + mechanicBrowserTooltip.setScale(getScale()); + mechanicBrowserTooltip.setBounds(new Rectangle(bounds.x + bounds.width, latestTooltipDY + bounds.y, prefSize.width, prefSize.height)); + } + } + + public boolean openGUI() { + return Minecraft.getMinecraft().currentScreen != null + && Minecraft.getMinecraft().currentScreen instanceof GuiChat && lastRoomUID != null; + } + + @Override + public List<MPanel> getChildComponents() { + return openGUI() ? super.getChildComponents() : Collections.emptyList(); + } + + @Override + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + selectedID = null; + if (mechanicBrowserTooltip != null) { + mechanicBrowserTooltip.close(); + mechanicBrowserTooltip = null; + } + + return super.mouseClicked0(absMouseX, absMouseY, relMouseX0, relMouseY0, mouseButton); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java index f086c997..086ecfed 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java @@ -61,21 +61,15 @@ public class MGui extends GuiScreen { int j = this.mc.displayHeight - Mouse.getEventY(); ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); - GlStateManager.disableLighting(); - GlStateManager.disableFog(); GlStateManager.disableDepth(); - GL11.glDisable(GL11.GL_FOG); GlStateManager.enableBlend(); GlStateManager.enableAlpha(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.color(1, 1, 1, 1); GlStateManager.scale(1.0/scaledResolution.getScaleFactor(), 1.0/scaledResolution.getScaleFactor(), 1.0d); mainPanel.render0(1, new Point(0,0), new Rectangle(0,0,Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight), i, j, i, j, partialTicks); - GlStateManager.popAttrib(); GlStateManager.popMatrix(); GlStateManager.enableBlend(); - GlStateManager.enableLighting(); } catch (Throwable e) { 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 86333d36..d7f3223f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java @@ -121,7 +121,7 @@ public class MPanel { int relMousey = relMousey0 - getBounds().y; GlStateManager.translate(getBounds().x, getBounds().y, 5); - GlStateManager.color(1,1,1,0); + GlStateManager.color(1,1,1,1); Rectangle absBound = getBounds().getBounds(); @@ -134,16 +134,13 @@ public class MPanel { this.scale = scale; clip(clip.x, clip.y, clip.width, clip.height); - GlStateManager.pushAttrib(); + GL11.glEnable(GL11.GL_SCISSOR_TEST); - GlStateManager.pushAttrib(); GuiScreen.drawRect(0,0, getBounds().width, getBounds().height, backgroundColor.getRGB()); GlStateManager.enableBlend(); - GlStateManager.popAttrib(); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.enableBlend(); @@ -151,7 +148,6 @@ public class MPanel { GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); - GlStateManager.popAttrib(); GlStateManager.popMatrix(); if (debug && lastAbsClip.contains(absMousex, absMousey)) { GL11.glDisable(GL11.GL_SCISSOR_TEST); @@ -160,15 +156,12 @@ public class MPanel { } GL11.glDisable(GL11.GL_SCISSOR_TEST); - GlStateManager.popAttrib(); Point newPt = new Point(parentPoint.x + getBounds().x, parentPoint.y + getBounds().y); for (MPanel mPanel : getChildComponents()){ GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); mPanel.render0(scale, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); - GlStateManager.popAttrib(); GlStateManager.popMatrix(); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java index 85b86f40..5a0dd4ba 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java @@ -88,7 +88,7 @@ public class MCollapsable extends MPanel { GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.enableBlend(); @@ -105,7 +105,7 @@ public class MCollapsable extends MPanel { fr.drawString(">", 0,0, -1); - GlStateManager.popAttrib(); + GlStateManager.popMatrix(); GL11.glDisable(GL11.GL_SCISSOR_TEST); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java index 169e99b5..a9ce318b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java @@ -65,7 +65,7 @@ public class MPanelScaledGUI extends MPanel { lastParentPoint = parentPoint; GlStateManager.translate(getBounds().x, getBounds().y, 5); - GlStateManager.color(1,1,1,0); + GlStateManager.color(1,1,1,1); Rectangle absBound = getBounds().getBounds(); absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); @@ -92,16 +92,16 @@ public class MPanelScaledGUI extends MPanel { clip(clip.x, clip.y, clip.width, clip.height); - GlStateManager.pushAttrib(); + GL11.glEnable(GL11.GL_SCISSOR_TEST); - GlStateManager.pushAttrib(); + GuiScreen.drawRect(0,0, (int) (getBounds().width / scale), (int) (getBounds().height / scale), backgroundColor.getRGB()); GlStateManager.enableBlend(); - GlStateManager.popAttrib(); + GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.enableBlend(); @@ -109,20 +109,20 @@ public class MPanelScaledGUI extends MPanel { GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); - GlStateManager.popAttrib(); + GlStateManager.popMatrix(); GL11.glDisable(GL11.GL_SCISSOR_TEST); - GlStateManager.popAttrib(); + Point newPt = new Point((int) ((parentPoint.x + getBounds().x) / scale), (int) ((parentPoint.y + getBounds().y) / scale)); for (MPanel mPanel : getChildComponents()){ GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + mPanel.render0(relativeScale, newPt,clip,absMousex, absMousey, relMousex, relMousey, partialTicks); - GlStateManager.popAttrib(); + GlStateManager.popMatrix(); } } @@ -131,7 +131,7 @@ public class MPanelScaledGUI extends MPanel { public void clip(int x, int y, int width, int height) { if (width < 0 || height < 0) return; - GL11.glScissor((int) (x * relativeScale), Minecraft.getMinecraft().displayHeight - (int) ((y + height) * relativeScale), (int)(width* relativeScale), (int) (height * relativeScale)); + GL11.glScissor((int) (x * relativeScale), Minecraft.getMinecraft().displayHeight - (int) ((y + height+1) * relativeScale), (int)((width+1)* relativeScale), (int) ((height+1) * relativeScale)); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java index 89967f5b..62ff1e2f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java @@ -33,6 +33,7 @@ public class MTooltip extends MPanelScaledGUI { private MRootPanel root; public void open(MPanel component) { + if (root == null) component.openTooltip(this); } public void close() { @@ -55,7 +56,7 @@ public class MTooltip extends MPanelScaledGUI { lastParentPoint = parentPoint; GlStateManager.translate(getBounds().x, getBounds().y, 300); - GlStateManager.color(1,1,1,0); + GlStateManager.color(1,1,1,1); Rectangle absBound = getBounds().getBounds(); absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); @@ -74,33 +75,33 @@ public class MTooltip extends MPanelScaledGUI { GlStateManager.scale(this.scale, this.scale, 1); clip = new Rectangle((int) (clip.x / scale), (int) (clip.y / scale), (int) (clip.width / scale), (int) (clip.height / scale)); lastAbsClip = clip; - GlStateManager.pushAttrib(); + GL11.glEnable(GL11.GL_SCISSOR_TEST); this.relativeScale = parentScale * this.scale; clip(clip.x, clip.y, clip.width, clip.height); - GlStateManager.pushAttrib(); + GuiScreen.drawRect(0,0, (int) (getBounds().width / scale), (int) (getBounds().height / scale), backgroundColor.getRGB()); GlStateManager.enableBlend(); - GlStateManager.popAttrib(); + GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); - GlStateManager.popAttrib(); + GlStateManager.popMatrix(); GL11.glDisable(GL11.GL_SCISSOR_TEST); - GlStateManager.popAttrib(); + Point newPt = new Point((int) ((parentPoint.x + getBounds().x) / scale), (int) ((parentPoint.y + getBounds().y) / scale)); for (MPanel mPanel : getChildComponents()){ GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + mPanel.render0(relativeScale, newPt,clip,absMousex, absMousey, relMousex, relMousey, partialTicks); - GlStateManager.popAttrib(); + GlStateManager.popMatrix(); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/party/PartyInviteViewer.java b/src/main/java/kr/syeyoung/dungeonsguide/party/PartyInviteViewer.java index db1ebde0..2e8c8702 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/party/PartyInviteViewer.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/party/PartyInviteViewer.java @@ -209,7 +209,7 @@ public class PartyInviteViewer { if (loadedImage.getResourceLocation() == null) loadedImage.buildGLThings(); TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); textureManager.bindTexture(loadedImage.getResourceLocation()); - GlStateManager.pushAttrib(); + GlStateManager.disableLighting(); GlStateManager.color(1, 1, 1, 1.0F); @@ -222,7 +222,7 @@ public class PartyInviteViewer { GlStateManager.enableLighting(); GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); - GlStateManager.popAttrib(); + } else { Gui.drawRect(7, 7, height - 7, height-7, 0xFF4E4E4E); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java index 7ea8cf51..dd8331a7 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java @@ -77,7 +77,7 @@ public class ActionTreeDisplayPane extends MPanel { Point pt = drawmPoints.get(actionTree); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.enableBlend(); GlStateManager.disableDepth(); GlStateManager.disableTexture2D(); @@ -94,14 +94,14 @@ public class ActionTreeDisplayPane extends MPanel { GlStateManager.enableDepth(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + return 0; } Dimension dim = renderAction(actionTree.getCurrent(), x, y, fr); if (drawLineFrom != null) { GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.enableBlend(); GlStateManager.disableDepth(); @@ -119,7 +119,7 @@ public class ActionTreeDisplayPane extends MPanel { GlStateManager.enableDepth(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + } Point pt = new Point(x + dim.width / 2, y + dim.height); @@ -139,7 +139,7 @@ public class ActionTreeDisplayPane extends MPanel { Dimension dim = renderAction(action, x, y2, fr); if (lastPt != null) { GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.enableBlend(); GlStateManager.disableDepth(); @@ -157,7 +157,7 @@ public class ActionTreeDisplayPane extends MPanel { GlStateManager.enableDepth(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + } lastPt = new Point(x + dim.width / 2, y2 + dim.height); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java index 0265b4b5..73fa957e 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java @@ -144,7 +144,7 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.colorMask(false, false, false, false); @@ -152,7 +152,7 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { GlStateManager.colorMask(true, true, true, true); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); @@ -172,7 +172,7 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { GL11.glStencilFunc(GL11.GL_NOTEQUAL, 3, 0x01); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.translate(x, y + 0.7, z); GlStateManager.scale(1.1f, 1.1f, 1.1f); @@ -182,7 +182,7 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { GlStateManager.colorMask(true, true, true, true); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + GL11.glStencilFunc(GL11.GL_EQUAL, 3, 0xFF); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java new file mode 100644 index 00000000..2737be9d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java @@ -0,0 +1,69 @@ +/* + * 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.utils; + +import com.sun.org.apache.xpath.internal.operations.Bool; +import net.minecraft.client.renderer.GlStateManager; + +import java.lang.reflect.Field; +import java.util.*; + +public class GlStateUtils { + public static Map<String, Object> dumpStates() { + Map<String, Object> primitiveDump = new LinkedHashMap<>(); + try { + recursivelyDump(primitiveDump, "GlStateManager", null, GlStateManager.class); + } catch (IllegalAccessException e) { + e.printStackTrace(); + primitiveDump.put("$ERROR", true); + } + return primitiveDump; + } + + public static void printDump(Map<String, Object> dump) { + for (Map.Entry<String, Object> stringObjectEntry : dump.entrySet()) { + System.out.println(stringObjectEntry+": "+stringObjectEntry.getValue()); + } + } + + public static void compareDump(Map<String, Object> dump1, Map<String,Object> dump2) { + Set<String> set = new HashSet<>(); + set.addAll(dump1.keySet()); + set.addAll(dump2.keySet()); + + for (String s : set) { + Object obj1 = dump1.get(s); + Object obj2 = dump2.get(s); + if (!Objects.equals(obj1, obj2)) System.out.println(s+": Prev {"+obj1+"} New {"+obj2+"}"); + } + } + + public static void recursivelyDump(Map<String, Object> primitiveDump, String objPath, Object obj, Class clazz) throws IllegalAccessException { + primitiveDump.put(objPath+".$class", clazz.getName()); + for (Field declaredField : clazz.getDeclaredFields()) { + declaredField.setAccessible(true); + Object fieldData = declaredField.get(obj); + if (fieldData.getClass().getName().startsWith("java.lang")) { + primitiveDump.put(objPath+"."+declaredField.getName(), fieldData); + } else { + recursivelyDump(primitiveDump, objPath+"."+declaredField.getName(), fieldData, fieldData.getClass()); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index 685b8489..736d8ef2 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -373,7 +373,7 @@ public class RenderUtils { double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; //because of the way 3D rendering is done, all coordinates are relative to the camera. This "resets" the "0,0,0" position to the location that is (0,0,0) in the world. - GlStateManager.pushAttrib(); + GlStateManager.pushMatrix(); GlStateManager.translate(-playerX, -playerY, -playerZ); GlStateManager.disableTexture2D(); @@ -436,7 +436,7 @@ public class RenderUtils { GlStateManager.enableTexture2D(); GlStateManager.enableCull(); - GlStateManager.popAttrib(); + GlStateManager.popMatrix(); } @@ -578,7 +578,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -638,7 +638,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + //... @@ -653,7 +653,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -731,7 +731,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + } public static void highlightBox(Entity entity, AxisAlignedBB axisAlignedBB, Color c, float partialTicks, boolean depth) { @@ -742,7 +742,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -819,7 +819,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + } public static void highlightBox(Entity entity, Color c, float partialTicks, boolean depth) { Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); @@ -829,7 +829,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -905,7 +905,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + //... @@ -920,7 +920,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -999,7 +999,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + //... |