From a6b8e47c879ce5a1c69d0552cdb26a3b3e95e4b6 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sun, 25 Jul 2021 20:37:22 +0900 Subject: new config. --- .../commands/CommandDungeonsGuide.java | 10 +- .../config/guiconfig/ConfigPanelCreator.java | 40 --- .../config/guiconfig/FeatureEditPane.java | 123 ------- .../dungeonsguide/config/guiconfig/GuiConfig.java | 95 ------ .../config/guiconfig/GuiGuiLocationConfig.java | 151 --------- .../config/guiconfig/GuiParameterValueEdit.java | 123 ------- .../dungeonsguide/config/guiconfig/MFeature.java | 146 -------- .../dungeonsguide/config/guiconfig/MParameter.java | 143 -------- .../dungeonsguide/config/guiconfig/Marker.java | 46 --- .../guiconfig/PanelDefaultParameterConfig.java | 113 ------- .../config/guiconfig/PanelDelegate.java | 372 --------------------- .../guiconfig/location/GuiGuiLocationConfig.java | 147 ++++++++ .../config/guiconfig/location/Marker.java | 45 +++ .../config/guiconfig/nyu/GuiConfigV2.java | 46 +++ .../config/guiconfig/nyu/MCategoryElement.java | 75 +++++ .../config/guiconfig/nyu/MNotFound.java | 40 +++ .../config/guiconfig/nyu/RootConfigPanel.java | 160 +++++++++ .../config/guiconfig/old/ConfigPanelCreator.java | 40 +++ .../config/guiconfig/old/FeatureEditPane.java | 108 ++++++ .../config/guiconfig/old/GuiConfig.java | 92 +++++ .../guiconfig/old/GuiParameterValueEdit.java | 117 +++++++ .../config/guiconfig/old/MFeature.java | 143 ++++++++ .../config/guiconfig/old/MParameter.java | 142 ++++++++ .../guiconfig/old/PanelDefaultParameterConfig.java | 105 ++++++ .../config/guiconfig/old/PanelDelegate.java | 371 ++++++++++++++++++++ .../eventlistener/FeatureListener.java | 3 +- .../dungeonsguide/features/AbstractFeature.java | 7 +- .../dungeonsguide/features/FeatureRegistry.java | 14 +- .../dungeonsguide/features/GuiFeature.java | 8 +- .../features/impl/boss/FeatureWarningOnPortal.java | 6 +- .../impl/cosmetics/FeatureNicknameColor.java | 5 +- .../impl/cosmetics/FeatureNicknamePrefix.java | 12 +- .../features/impl/cosmetics/PrefixSelectorGUI.java | 3 +- .../party/customgui/PanelPartyListElement.java | 3 - .../playerpreview/DataRenderDungeonFloorStat.java | 2 - .../DataRenderDungeonHighestFloorStat.java | 2 - .../party/playerpreview/DataRendererClassLv.java | 1 - .../party/playerpreview/DataRendererDungeonLv.java | 1 - .../party/playerpreview/DataRendererEditor.java | 24 +- .../playerpreview/DataRendererFairySouls.java | 8 - .../playerpreview/DataRendererSelectedClassLv.java | 2 - .../party/playerpreview/DataRendererSetUrOwn.java | 6 - .../party/playerpreview/DataRendererSkillLv.java | 3 - .../playerpreview/FeatureViewPlayerOnJoin.java | 18 +- .../features/impl/secret/FeatureActions.java | 2 +- .../impl/secret/FeatureFreezePathfind.java | 2 +- .../impl/secret/FeatureMechanicBrowse.java | 7 +- .../features/text/PanelTextParameterConfig.java | 20 +- .../features/text/TextHUDFeature.java | 16 +- .../java/kr/syeyoung/dungeonsguide/gui/MGui.java | 2 +- .../java/kr/syeyoung/dungeonsguide/gui/MPanel.java | 25 +- .../dungeonsguide/gui/elements/MCollapsable.java | 131 ++++++++ .../syeyoung/dungeonsguide/gui/elements/MList.java | 24 +- .../gui/elements/MPanelScaledGUI.java | 199 +++++++++++ .../gui/elements/MPortableColorEdit.java | 8 +- .../dungeonsguide/gui/elements/MScrollBar.java | 6 +- .../gui/elements/MScrollablePanel.java | 19 +- .../dungeonsguide/gui/elements/MSpacer.java | 36 ++ .../dungeonsguide/gui/elements/MTextField.java | 2 +- .../dungeonsguide/gui/elements/MTooltip.java | 7 +- .../roomedit/panes/RoomDataDisplayPane.java | 6 +- .../roomedit/panes/RoomMatchDisplayPane.java | 8 +- .../syeyoung/dungeonsguide/utils/RenderUtils.java | 47 +++ 63 files changed, 2168 insertions(+), 1520 deletions(-) delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/Marker.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/GuiGuiLocationConfig.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/Marker.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MNotFound.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/ConfigPanelCreator.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/FeatureEditPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/GuiConfig.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/GuiParameterValueEdit.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MFeature.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MParameter.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDefaultParameterConfig.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDelegate.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MSpacer.java (limited to 'src/main/java/kr/syeyoung') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java index aa9a9ef8..a5991e0f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java @@ -20,9 +20,9 @@ package kr.syeyoung.dungeonsguide.commands; import com.google.gson.JsonObject; import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.nyu.GuiConfigV2; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.cosmetics.chatreplacers.*; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; @@ -34,7 +34,6 @@ import kr.syeyoung.dungeonsguide.events.DungeonLeftEvent; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin; import kr.syeyoung.dungeonsguide.features.impl.party.api.ApiFetchur; -import kr.syeyoung.dungeonsguide.party.PartyInviteViewer; import kr.syeyoung.dungeonsguide.party.PartyManager; import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; import kr.syeyoung.dungeonsguide.stomp.*; @@ -43,7 +42,6 @@ import kr.syeyoung.dungeonsguide.utils.MapUtils; import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentText; @@ -399,7 +397,7 @@ public class CommandDungeonsGuide extends CommandBase { StaticResourceCache.INSTANCE.getResource(uid).thenAccept(a -> { sender.addChatMessage(new ChatComponentText(a.getResourceID()+": "+a.getValue()+": "+a.isExists())); }); - } else{ + } else { sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg §7-§fOpens configuration gui")); sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg gui §7-§fOpens configuration gui")); sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg help §7-§fShows command help")); @@ -425,7 +423,7 @@ public class CommandDungeonsGuide extends CommandBase { try { if (openConfig && e.phase == TickEvent.Phase.START ) { openConfig = false; - Minecraft.getMinecraft().displayGuiScreen(new GuiConfig()); + Minecraft.getMinecraft().displayGuiScreen(new GuiConfigV2()); } } catch (Throwable t) { t.printStackTrace(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java deleted file mode 100644 index 61edf38d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java +++ /dev/null @@ -1,40 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Map; - -public class ConfigPanelCreator implements Function { - public static final ConfigPanelCreator INSTANCE = new ConfigPanelCreator(); - - public static final Map> map = new HashMap>(); - - @Nullable - @Override - public MPanel apply(@Nullable String input) { - if (!map.containsKey(input)) return null; - return map.get(input).get(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java deleted file mode 100755 index 7f6d5a4f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java +++ /dev/null @@ -1,123 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; - -import java.awt.*; -import java.io.IOException; -import java.util.*; -import java.util.List; - -public class FeatureEditPane extends MPanel { - private final List features; - - private final List le = new ArrayList(); - - private final GuiConfig config; - - private MTextField textField; - private String search = ""; - - public FeatureEditPane(List features, GuiConfig config) { - this.features = features; - this.config = config; - buildElements(); - - } - - - public void buildElements() { - for (AbstractFeature feature : features) { - MFeature mFeature = new MFeature(feature, config); - mFeature.setHover(new Color(94, 94, 94, 255)); - le.add(mFeature); - add(mFeature); - } - - textField = new MTextField() { - @Override - public void edit(String str) { - offsetY = 0; - search = str; - } - }; - textField.setText(""); - textField.setBounds(new Rectangle(getBounds().width - 200, 0, 200, 20)); - add(textField); - } - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, panel.getPreferredSize().height)); - } - textField.setBounds(new Rectangle(getBounds().width - 200, 0, 200, 20)); - } - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,1,parentWidth-10,parentHeight-2)); - } - - @Override - public List getChildComponents() { - List comp = new ArrayList(); - comp.add(textField); - for (MFeature feature:le) { - if (feature.getFeature().getName().toLowerCase().contains(search.toLowerCase())) - comp.add(feature); - } - return comp; - } - - private int offsetY = 0; - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - int heights = 0; - for (MPanel panel:getChildComponents()) { - panel.setPosition(new Point(panel.getBounds().x, -offsetY + heights)); - heights += panel.getBounds().height + 5; - } - } - - @Override - public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { - super.render0(resolution, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); - } - - - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (scrollAmount > 0) offsetY -= 20; - else if (scrollAmount < 0) offsetY += 20; - if (offsetY < 0) offsetY = 0; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java deleted file mode 100755 index 24b98e00..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java +++ /dev/null @@ -1,95 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.gui.MGui; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MNavigatingPane; -import kr.syeyoung.dungeonsguide.gui.elements.MTabbedPane; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.BufferUtils; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.io.IOException; -import java.nio.FloatBuffer; -import java.util.List; -import java.util.Map; -import java.util.Stack; -import java.util.stream.Collectors; - -public class GuiConfig extends MGui { - - - @Getter - private final MNavigatingPane tabbedPane; - - private final Stack history = new Stack(); - - public GuiConfig() { - MNavigatingPane tabbedPane = new MNavigatingPane(); - getMainPanel().add(tabbedPane); - tabbedPane.setBackground2(new Color(38, 38, 38, 255)); - - tabbedPane.setPageGenerator(ConfigPanelCreator.INSTANCE); - - tabbedPane.addBookmarkRunnable("GUI Relocate", new Runnable() { - @Override - public void run() { - Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(GuiConfig.this, null)); - } - }); - - for (final Map.Entry> cate: FeatureRegistry.getFeaturesByCategory().entrySet()) - if (!cate.getKey().equals("hidden")) { - tabbedPane.addBookmark(cate.getKey(), "base." + cate.getKey()); - - ConfigPanelCreator.map.put("base." + cate.getKey(), new Supplier() { - @Override - public MPanel get() { - return new FeatureEditPane(cate.getValue(), GuiConfig.this); - } - }); - } - tabbedPane.addBookmark("All", "base.all"); - - ConfigPanelCreator.map.put("base.all", new Supplier() { - @Override - public MPanel get() { - return new FeatureEditPane(FeatureRegistry.getFeatureList().stream().filter( a-> !a.getCategory().equals("hidden")).collect(Collectors.toList()), GuiConfig.this); - } - }); - this.tabbedPane = tabbedPane; - } - - @Override - public void initGui() { - super.initGui(); - getMainPanel().setBounds(new Rectangle(Math.min((Minecraft.getMinecraft().displayWidth - 500) / 2, Minecraft.getMinecraft().displayWidth), Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),500,300)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java deleted file mode 100755 index b68c0b0c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java +++ /dev/null @@ -1,151 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.gui.MGui; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.Vec3; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; -import java.util.*; -import java.util.List; - -public class GuiGuiLocationConfig extends MGui { - - @Getter - private final GuiScreen before; - - @Getter - private TreeMap> markerTreeMapByX = new TreeMap<>(); - @Getter - private TreeMap> markerTreeMapByY = new TreeMap<>(); - @Getter - private Set markerSet = new HashSet<>(); - - - Marker[] markers = new Marker[4]; - - - public GuiGuiLocationConfig(final GuiScreen before, AbstractFeature featureWhitelist) { - this.before = before; - for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { - if (feature instanceof GuiFeature && feature.isEnabled()) { - getMainPanel().add(new PanelDelegate((GuiFeature) feature, featureWhitelist == null || feature == featureWhitelist, this)); - } - } - - getMainPanel().setBackgroundColor(new Color(0,0,0, 100)); - } - - public static final Vec3[] facing = new Vec3[] { - new Vec3(0, 0.5, 2), - new Vec3(0.5, 0, 1), - new Vec3(0.5, 1, 3), - new Vec3(1, 0.5, 4), - }; - - public void removeAndAddMarker(Marker prev, Marker newM) { - if (prev != null) { - markerTreeMapByX.computeIfPresent(prev.getX(),(k,v) -> { - v.remove(prev); - if (v.isEmpty()) return null; - else return v; - }); - markerTreeMapByY.computeIfPresent(prev.getY(),(k,v) -> { - v.remove(prev); - if (v.isEmpty()) return null; - else return v; - }); - markerSet.remove(prev); - } - if (newM != null) { - markerTreeMapByX.compute(newM.getX(), (k,v) -> { - if (v == null) { - return new ArrayList<>(Arrays.asList(newM)); - } else { - v.add(newM); - return v; - } - }); - markerTreeMapByY.compute(newM.getY(), (k,v) -> { - if (v == null) { - return new ArrayList<>(Arrays.asList(newM)); - } else { - v.add(newM); - return v; - } - }); - markerSet.add(newM); - } - } - - public void setupMarkers() { - for (int i1 = 0; i1 < markers.length; i1++) { - Marker orig = markers[i1]; - Vec3 pt = facing[i1]; - markers[i1] = new Marker((int) (pt.xCoord * getMainPanel().getBounds().width), (int) (pt.yCoord * getMainPanel().getBounds().height), (int) pt.zCoord, this); - - removeAndAddMarker(orig, markers[i1]); - } - } - - - @Override - public void keyTyped(char typedChar, int keyCode) throws IOException { - try { - getMainPanel().keyTyped0(typedChar, keyCode); - - if (keyCode == 1) { - Minecraft.getMinecraft().displayGuiScreen(before); - } - } catch (Throwable e) { - if (!e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - - @Override - public void initGui() { - super.initGui(); - getMainPanel().setBounds(new Rectangle(0,0,Minecraft.getMinecraft().displayWidth,Minecraft.getMinecraft().displayHeight)); - markerTreeMapByX.clear(); - markerTreeMapByY.clear(); - markerSet.clear(); - setupMarkers(); - for (MPanel childComponent : getMainPanel().getChildComponents()) { - if (childComponent instanceof PanelDelegate) { - ((PanelDelegate) childComponent).rebuildMarker(); - } - } - - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java deleted file mode 100755 index 0d7b819c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java +++ /dev/null @@ -1,123 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.gui.MGui; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; - -public class GuiParameterValueEdit extends MGui { - - - private MPanel currentValueEdit; - - private MButton save; - - @Getter - private ValueEdit valueEdit; - - private Object editingObj; - - @Getter - @Setter - private Runnable onUpdate; - @Getter - private Parameter parameter; - - public GuiParameterValueEdit(final Object object, final GuiConfig prev) { - try { - this.editingObj = object; - getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179)); - { - currentValueEdit = new MPanel() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(5, 5, parentWidth-10, parentHeight - 25)); - } - }; - getMainPanel().add(currentValueEdit); - } - { - save = new MButton() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, parentHeight - 20, parentWidth, 20)); - } - }; - save.setText("Go back"); - save.setBackgroundColor(Color.green); - save.setOnActionPerformed(new Runnable() { - @Override - public void run() { - onUpdate.run(); - Minecraft.getMinecraft().displayGuiScreen(prev); - } - }); - getMainPanel().add(save); - } - updateClassSelection(); - } catch (Exception e){} - } - - public void updateClassSelection() { - currentValueEdit.getChildComponents().clear(); - - ValueEditCreator valueEditCreator = ValueEditRegistry.getValueEditMap(editingObj == null ?"null":editingObj.getClass().getName()); - MPanel valueEdit = (MPanel) valueEditCreator.createValueEdit(parameter= new Parameter("", editingObj, editingObj)); - if (valueEdit == null) { - MLabel valueEdit2 = new MLabel() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, 0, parentWidth,20)); - } - }; - valueEdit2.setText("No Value Edit"); - valueEdit2.setBounds(new Rectangle(0,0,150,20)); - valueEdit = valueEdit2; - this.valueEdit = null; - } else{ - this.valueEdit = (ValueEdit) valueEdit; - } - valueEdit.resize0(currentValueEdit.getBounds().width, currentValueEdit.getBounds().height); - currentValueEdit.add(valueEdit); - } - @Override - public void initGui() { - super.initGui(); - // update bounds - getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300)); - save.setBounds(new Rectangle(0 ,getMainPanel().getBounds().height - 20, getMainPanel().getBounds().width, 20)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java deleted file mode 100755 index 4e29eae4..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java +++ /dev/null @@ -1,146 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -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.MStringSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -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.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.Arrays; -import java.util.List; -import java.util.ArrayList; - -public class MFeature extends MPanel { - - @Getter - private final AbstractFeature feature; - - private final List addons = new ArrayList(); - - @Getter @Setter - private Color hover; - - private final GuiConfig config; - - public MFeature(final AbstractFeature abstractFeature, final GuiConfig config) { - this.config = config; - this.feature = abstractFeature; - - if (abstractFeature.isDisyllable()) { - final MToggleButton mStringSelectionButton = new MToggleButton(); - mStringSelectionButton.setOnToggle(new Runnable() { - @Override - public void run() { - boolean selected = mStringSelectionButton.isEnabled(); - feature.setEnabled(selected); - } - }); - addons.add(mStringSelectionButton); - mStringSelectionButton.setEnabled(feature.isEnabled()); - mStringSelectionButton.setSize(new Dimension(30, 15)); - add(mStringSelectionButton); - } - if (abstractFeature.getParameters().size() != 0) { - MButton button = new MButton(); - button.setText("Edit"); - button.setOnActionPerformed(new Runnable() { - @Override - public void run() { - config.getTabbedPane().setCurrentPage(abstractFeature.getEditRoute(config)); - } - }); - addons.add(button); - button.setSize(new Dimension(50, 15)); - add(button); - } - if (abstractFeature instanceof GuiFeature) { - MButton button = new MButton(); - button.setText("GUI"); - button.setOnActionPerformed(new Runnable() { - @Override - public void run() { - Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(config, abstractFeature)); - } - }); - addons.add(button); - button.setSize(new Dimension(50, 15)); - add(button); - } - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Gui.drawRect(0,0,getBounds().width, getBounds().height,0xFF444444); - if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { - Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, hover.getRGB()); - } else { - Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, 0xFF545454); - } - Gui.drawRect(0,17,getBounds().width, 18,0xFF444444); - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.pushMatrix(); - GlStateManager.translate(5,5,0); - GlStateManager.scale(1.0,1.0,0); - 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(feature.getName(), 0,0, 0xFFFFFFFF); - GlStateManager.popMatrix(); - - fr.drawSplitString(feature.getDescription(), 5, 23, getBounds().width -10, 0xFFBFBFBF); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setSize(new Dimension(parentWidth, getBounds().height)); - } - - @Override - public Dimension getPreferredSize() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int descriptionHeight = fr.listFormattedStringToWidth(feature.getDescription(), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT; - - return new Dimension(100, descriptionHeight + 28); - } - - @Override - public void onBoundsUpdate() { - int x = getBounds().width - 5; - for (MPanel panel : addons) { - panel.setBounds(new Rectangle(x - panel.getPreferredSize().width, 3, panel.getPreferredSize().width, 12)); - x -= panel.getPreferredSize().width + 5; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java deleted file mode 100755 index 2bfabe3e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java +++ /dev/null @@ -1,143 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MEditableAColor; -import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - -public class MParameter extends MPanel { - private final MLabel label; - - @Getter - private final AbstractFeature feature; - @Getter - private final FeatureParameter parameter; - - private final List addons = new ArrayList(); - - @Getter @Setter - private Color hover; - - private PanelDefaultParameterConfig config; - - private final MLabel label2; - public MParameter(AbstractFeature abstractFeature, final FeatureParameter parameter, final GuiConfig config2) { - this.config = config; - this.parameter = parameter; - this.feature = abstractFeature; - - this.add(this.label = new MLabel()); - this.label.setText(parameter.getName()); - - { - if (parameter.getValue_type().equalsIgnoreCase("boolean")) { - final MToggleButton button = new MToggleButton(); - button.setOnToggle(new Runnable() { - @Override - public void run() { - parameter.setValue(button.isEnabled()); - label2.setText(parameter.getValue().toString()); - } - }); - button.setEnabled((Boolean) parameter.getValue()); - addons.add(button); - add(button); - } else if (parameter.getValue_type().equalsIgnoreCase("acolor")) { - final MEditableAColor button = new MEditableAColor(); - button.setEnableEdit(true); - button.setOnUpdate(new Runnable() { - @Override - public void run() { - parameter.setValue(button.getColor()); - label2.setText(parameter.getValue().toString()); - } - }); - button.setColor((AColor) parameter.getValue()); - addons.add(button); - add(button); - } else { - MButton button = new MButton(); - button.setText("Edit"); - button.setOnActionPerformed(new Runnable() { - @Override - public void run() { - final GuiParameterValueEdit guiParameterValueEdit = new GuiParameterValueEdit(parameter.getValue(), config2); - guiParameterValueEdit.setOnUpdate(new Runnable() { - @Override - public void run() { - Parameter parameter1 = guiParameterValueEdit.getParameter(); - parameter.setValue(parameter1.getNewData()); - label2.setText(parameter.getValue().toString()); - } - }); - Minecraft.getMinecraft().displayGuiScreen(guiParameterValueEdit); - } - }); - addons.add(button); - add(button); - } - } - { - MLabel button = new MLabel(); - button.setText(parameter.getValue().toString()); - addons.add(button); - add(button); - label2 = button; - } - setSize(new Dimension(100,20)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { - Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setSize(new Dimension(parentWidth, getBounds().height)); - } - - @Override - public void onBoundsUpdate() { - int x = getBounds().width - 50; - for (MPanel panel : addons) { - panel.setBounds(new Rectangle(x, 3, 50, getBounds().height - 6)); - } - label2.setBounds(new Rectangle(x/2,0,x/2,getBounds().height)); - label.setBounds(new Rectangle(0,0,x/2, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/Marker.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/Marker.java deleted file mode 100644 index 27ced7ee..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/Marker.java +++ /dev/null @@ -1,46 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; -import lombok.ToString; - -@Getter -@ToString -@AllArgsConstructor -public class Marker { - private final int x; - private final int y; - /** - * 0xABCDEFGH - * A: ? - * B: ? - * C: ? - * D: ? - * EF: 0~3 (TC 0x00 CL 0x01 BC 0x10 CR 0x11) - */ - private final int type; - private final Object parent; - - public int distanceSQ(Marker m2) { - return (m2.x - x)*(m2.x - x) + (m2.y - y)*(m2.y - y); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java deleted file mode 100755 index a38f1a06..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java +++ /dev/null @@ -1,113 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -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.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.util.List; -import java.awt.*; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Set; - -public class PanelDefaultParameterConfig extends MPanel { - - private AbstractFeature feature; - - @Override - public void onBoundsUpdate() { - for (MPanel childComponent : getChildComponents()) { - childComponent.setSize(new Dimension(getBounds().width - 10, childComponent.getSize().height)); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - private final GuiConfig config; - public PanelDefaultParameterConfig(final GuiConfig config, AbstractFeature feature, List pre, Set ignore) { - this.config = config; - for (MPanel mPanel : pre) { - add(mPanel); - } - for (FeatureParameter parameter: feature.getParameters()) { - if (ignore.contains(parameter.getKey())) continue; - add(new MParameter(feature, parameter, config)); - } - setBackgroundColor(new Color(38, 38, 38, 255)); - } - - - MPanel within; - MTooltip mTooltip; - MParameter lastWithin; - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - int heights = 0; - within = null; - for (MPanel panel:getChildComponents()) { - panel.setPosition(new Point(5, -offsetY + heights + 5)); - heights += panel.getBounds().height; - - if (panel.getBounds().contains(relMousex0,relMousey0)) within = panel; - } - if (within instanceof MParameter) { - FeatureParameter feature = ((MParameter) within).getParameter(); - if (lastWithin != within) { - if (mTooltip != null) mTooltip.close(); - mTooltip = new MTooltipText(Arrays.asList(feature.getDescription().split("\n"))); - mTooltip.open(this); - } - } else { - if (mTooltip != null) { - mTooltip.close(); - mTooltip = null; - } - } - } - - - public int offsetY = 0; - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - for (MPanel childComponent : getChildComponents()) { - if (!(childComponent instanceof MParameter) && childComponent.getBounds().contains(relMouseX0, relMouseY0)) return; - } - if (scrollAmount > 0) offsetY -= 20; - else if (scrollAmount < 0) offsetY += 20; - if (offsetY < 0) offsetY = 0; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java deleted file mode 100644 index bfd92cef..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java +++ /dev/null @@ -1,372 +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 . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.config.types.GUIRectangle; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MPopupMenu; -import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; -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.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Tuple; -import net.minecraft.util.Vec3; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.*; -import java.util.List; -import java.util.stream.Stream; - -public class PanelDelegate extends MPanel { - private final GuiFeature guiFeature; - private boolean draggable = false; - private GuiGuiLocationConfig guiGuiLocationConfig; - - private Set markerSet = new HashSet<>(); - public PanelDelegate(GuiFeature guiFeature, boolean draggable, GuiGuiLocationConfig guiGuiLocationConfig) { - this.guiFeature = guiFeature; - this.draggable = draggable; - this.guiGuiLocationConfig = guiGuiLocationConfig; - } - - public void rebuildMarker() { - internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale(); - applyConstraint(); - } - - @Override - public Rectangle getBounds() { - Rectangle rectangle = guiFeature.getFeatureRect().getRectangle(); - return new Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height); - } - - @Override - public void render(int absMousex, int absMousey, int relMouseX, int relMouseY, float partialTicks, Rectangle scissor) { - if (!guiFeature.isEnabled()) return; - - GlStateManager.pushMatrix(); - guiFeature.drawDemo(partialTicks); - GlStateManager.popMatrix(); - if (!draggable) return; - Gui.drawRect(0,0, 4, 4, 0xFFBBBBBB); - Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0xFFBBBBBB); - Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0xFFBBBBBB); - Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0xFFBBBBBB); - if (lastAbsClip.contains(absMousex, absMousey)) { - if (relMouseX < 4 && relMouseY < 4) { - Gui.drawRect(0,0, 4, 4, 0x55FFFFFF); - } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { - Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0x55FFFFFF); - } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { - Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0x55FFFFFF); - } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { - Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0x55FFFFFF); - } else if (selectedPart == -2){ - Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55FFFFFF); - } - } - GlStateManager.enableBlend(); - } - - @Override - public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { - GlStateManager.pushMatrix(); - super.render0(resolution, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); - GlStateManager.popMatrix(); - - if (snapped != null && selectedPart != -2) { - Tessellator tessellator = Tessellator.getInstance(); - GlStateManager.disableTexture2D(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); - GL11.glLineWidth(1); - for (Tuple markerAxisTuple : snapped) { - if (markerAxisTuple.getSecond() == EnumFacing.Axis.X) { - worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), 0, 0).color(0,255,0,255).endVertex(); - worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), Minecraft.getMinecraft().displayHeight, 0).color(0,255,0,255).endVertex(); - } else { - worldRenderer.pos(0, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex(); - worldRenderer.pos(Minecraft.getMinecraft().displayWidth, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex(); - } - } - tessellator.draw(); - for (Marker marker : guiGuiLocationConfig.getMarkerSet()) { - Gui.drawRect(marker.getX(),marker.getY(), marker.getX()+1, marker.getY()+1, 0xFFFF0000); - } - } - } - - private int selectedPart = -2; - - private int lastX = 0; - private int lastY = 0; - - private Rectangle internallyThinking; - private Rectangle constraintApplied; - - private Set> snapped = new HashSet<>(); - - public void applyConstraint() { - constraintApplied = internallyThinking.getBounds(); - - // SNAP Moving Point. - snapped.clear(); - int scailingThreshold = 5; - if (selectedPart == 0){ - Point snapPt = new Point(constraintApplied.x +constraintApplied.width, constraintApplied.y + constraintApplied.height); - Optional snapX, snapY; - SortedMap> markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(snapPt.x-scailingThreshold, snapPt.x +scailingThreshold); - snapX = markerSortedMap.values().stream() - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(a -> a.getParent() != this) - .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY()))); - markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(snapPt.y-scailingThreshold, snapPt.y +scailingThreshold); - snapY = markerSortedMap.values().stream() - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(a -> a.getParent() != this) - .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY()))); - snapX.ifPresent(a -> { - snapPt.x = a.getX(); - }); - snapY.ifPresent(a -> { - snapPt.y = a.getY(); - }); - - constraintApplied = new Rectangle(constraintApplied.x, constraintApplied.y, snapPt.x - constraintApplied.x, snapPt.y - constraintApplied.y); - - - - int minWidth; - int minHeight; - if (guiFeature.isKeepRatio()) { - if (guiFeature.getDefaultRatio() >= 1) { - minHeight = constraintApplied.height < 0 ? -8 : 8; - minWidth = (int) (guiFeature.getDefaultRatio() * minHeight); - } else { - minWidth = constraintApplied.width < 0 ? -8 : 8; - minHeight = (int) (minWidth / guiFeature.getDefaultRatio()); - } - } else { - minWidth = constraintApplied.width < 0 ? -8 : 8; - minHeight = constraintApplied.height < 0 ? -8 : 8; - } - - - constraintApplied.width = Math.abs(constraintApplied.width) > Math.abs(minWidth) ? constraintApplied.width : - Math.abs(internallyThinking.width) > Math.abs(minWidth) ? internallyThinking.width : minWidth; - constraintApplied.height = Math.abs(constraintApplied.height) > Math.abs(minHeight) ? constraintApplied.height : - Math.abs(internallyThinking.height) > Math.abs(minHeight) ? internallyThinking.height : minHeight; - - if (guiFeature.isKeepRatio()) { - double ratio = guiFeature.getDefaultRatio(); - - int heightWhenWidthFix = (int) Math.abs(constraintApplied.width / ratio); - int widthWhenHeightFix = (int) Math.abs(ratio * constraintApplied.height); - if (Math.abs(heightWhenWidthFix) <= Math.abs(constraintApplied.height)) { - constraintApplied.height = constraintApplied.height < 0 ? -heightWhenWidthFix : heightWhenWidthFix; - } else if (Math.abs(widthWhenHeightFix) <= Math.abs(constraintApplied.width)) { - constraintApplied.width =constraintApplied.width < 0 ? - widthWhenHeightFix : widthWhenHeightFix; - } - } - - - snapX.ifPresent(a -> { - if (snapPt.x - constraintApplied.x == constraintApplied.width) { - Marker m = new Marker((int) (GuiGuiLocationConfig.facing[3].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[3].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[3].zCoord, this); - snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.X)); - } - }); - snapY.ifPresent(a -> { - if (snapPt.y - constraintApplied.y == constraintApplied.height) { - Marker m = new Marker((int) (GuiGuiLocationConfig.facing[2].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[2].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[2].zCoord, this); - snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.Y)); - } - }); - - if (constraintApplied.height < 0) { - constraintApplied.height = -constraintApplied.height; - constraintApplied.y -= constraintApplied.height; - } - - if (constraintApplied.width < 0) { - constraintApplied.width = -constraintApplied.width; - constraintApplied.x -= constraintApplied.width; - } - } else if (selectedPart == -1) { - for (int i : Arrays.asList(0,3,1,2)) { - Vec3 pt = GuiGuiLocationConfig.facing[i]; - Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); - Optional result = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(m.getX()-scailingThreshold, m.getX() +scailingThreshold).values().stream() - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(a -> a.getParent() != this) - .filter(a -> Math.abs(a.getX() - m.getX()) < scailingThreshold) - .filter(a -> ((a.getX() - pt.xCoord * constraintApplied.width) >= 0 - && (a.getX() - pt.xCoord * constraintApplied.width + constraintApplied.width) <= Minecraft.getMinecraft().displayWidth)) - .min(Comparator.comparingInt(a -> a.distanceSQ(m))); - if (result.isPresent()) { - int x = result.get().getX(); - constraintApplied.x = (int) (x - pt.xCoord * constraintApplied.width); - - snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.X)); - break; - } - } - for (int i : Arrays.asList(1,2,0,3)) { - Vec3 pt = GuiGuiLocationConfig.facing[i]; - Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); - Optional result = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(m.getY()-scailingThreshold, m.getY() +scailingThreshold).values().stream() - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(a -> a.getParent() != this) - .filter(a -> Math.abs(a.getY() - m.getY()) < scailingThreshold) - .filter(a -> ((a.getY() - pt.yCoord * constraintApplied.height) >= 0 - && (a.getY() - pt.yCoord * constraintApplied.height+ constraintApplied.height) <= Minecraft.getMinecraft().displayHeight)) - .min(Comparator.comparingInt(a -> a.distanceSQ(m))); - if (result.isPresent()) { - int y = result.get().getY(); - constraintApplied.y = (int) (y - pt.yCoord * constraintApplied.height); - snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.Y)); - break; - } - } - } - - if (constraintApplied.x < 0) constraintApplied.x = 0; - if (constraintApplied.y < 0) constraintApplied.y = 0; - if (constraintApplied.x + constraintApplied.width + 1 >=Minecraft.getMinecraft().displayWidth) constraintApplied.x = Minecraft.getMinecraft().displayWidth - constraintApplied.width - 1; - if (constraintApplied.y + constraintApplied.height + 1>= Minecraft.getMinecraft().displayHeight) constraintApplied.y = Minecraft.getMinecraft().displayHeight - constraintApplied.height - 1; - - - setupMarkers(); - } - - Marker[] markers = new Marker[4]; - public void setupMarkers() { - for (int i1 = 0; i1 < markers.length; i1++) { - Marker orig = markers[i1]; - - Vec3 pt = GuiGuiLocationConfig.facing[i1]; - markers[i1] = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); - - guiGuiLocationConfig.removeAndAddMarker(orig, markers[i1]); - } - } - - MTooltip mTooltip; - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (!draggable) return; - if (!guiFeature.isEnabled()) return; - if (getTooltipsOpen() > 0) return; - if (!lastAbsClip.contains(absMouseX, absMouseY)) return; - if (mouseButton == 0) { - internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale(); - if (relMouseX < 4 && relMouseY < 4) { // TL - selectedPart = 0; - internallyThinking.y += internallyThinking.height; - internallyThinking.height = -internallyThinking.height; - internallyThinking.x += internallyThinking.width; - internallyThinking.width = -internallyThinking.width; - } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { // BL - selectedPart = 0; - internallyThinking.x += internallyThinking.width; - internallyThinking.width = -internallyThinking.width; - } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { // BR - selectedPart = 0; - } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { // TR - selectedPart = 0; - internallyThinking.y += internallyThinking.height; - internallyThinking.height = -internallyThinking.height; - } else { - selectedPart = -1; - } - lastX = absMouseX; - lastY = absMouseY; - applyConstraint(); - - } else if (getTooltipsOpen() == 0){ - if (mTooltip != null) mTooltip.close(); - mTooltip = new MPopupMenu(absMouseX, absMouseY, guiFeature.getTooltipForEditor(guiGuiLocationConfig)); - mTooltip.open(this); - } - throw new IllegalArgumentException("bruh, a hack to stop event progress"); - } - - @Override - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { - if (!draggable) return; - if (!guiFeature.isEnabled()) return; - if (selectedPart >= -1) { - guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); - } - - selectedPart = -2; - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - if (!draggable) return; - if (!guiFeature.isEnabled()) return; - int dx = (absMouseX - lastX); - int dy = (absMouseY - lastY); - if (selectedPart >= 0) { - Rectangle rectangle = internallyThinking; - - int prevWidth = rectangle.width; - int prevHeight= rectangle.height; - - rectangle.width = prevWidth + dx; - rectangle.height = prevHeight + dy; - - if (rectangle.height * prevHeight <= 0 && prevHeight != rectangle.height) { - rectangle.height += prevHeight < 0 ? 4 : -4; - } - if (rectangle.width * prevWidth <= 0 && prevWidth != rectangle.width) { - rectangle.width += prevWidth < 0 ? 4 : -4; - } - - - applyConstraint(); - guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); - lastX = absMouseX; - lastY = absMouseY; - throw new IllegalArgumentException("bruh, a hack to stop event progress"); - } else if (selectedPart == -1){ - Rectangle rectangle = internallyThinking; - rectangle.translate(dx, dy); - applyConstraint(); - guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); - lastX = absMouseX; - lastY = absMouseY; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/GuiGuiLocationConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/GuiGuiLocationConfig.java new file mode 100755 index 00000000..645ba3a9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/GuiGuiLocationConfig.java @@ -0,0 +1,147 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.location; + +import kr.syeyoung.dungeonsguide.config.guiconfig.old.PanelDelegate; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.GuiFeature; +import kr.syeyoung.dungeonsguide.gui.MGui; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.Vec3; + +import java.awt.*; +import java.io.IOException; +import java.util.*; +import java.util.List; + +public class GuiGuiLocationConfig extends MGui { + + @Getter + private final GuiScreen before; + + @Getter + private TreeMap> markerTreeMapByX = new TreeMap<>(); + @Getter + private TreeMap> markerTreeMapByY = new TreeMap<>(); + @Getter + private Set markerSet = new HashSet<>(); + + + Marker[] markers = new Marker[4]; + + + public GuiGuiLocationConfig(final GuiScreen before, AbstractFeature featureWhitelist) { + this.before = before; + for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { + if (feature instanceof GuiFeature && feature.isEnabled()) { + getMainPanel().add(new PanelDelegate((GuiFeature) feature, featureWhitelist == null || feature == featureWhitelist, this)); + } + } + + getMainPanel().setBackgroundColor(new Color(0,0,0, 100)); + } + + public static final Vec3[] facing = new Vec3[] { + new Vec3(0, 0.5, 2), + new Vec3(0.5, 0, 1), + new Vec3(0.5, 1, 3), + new Vec3(1, 0.5, 4), + }; + + public void removeAndAddMarker(Marker prev, Marker newM) { + if (prev != null) { + markerTreeMapByX.computeIfPresent(prev.getX(),(k,v) -> { + v.remove(prev); + if (v.isEmpty()) return null; + else return v; + }); + markerTreeMapByY.computeIfPresent(prev.getY(),(k,v) -> { + v.remove(prev); + if (v.isEmpty()) return null; + else return v; + }); + markerSet.remove(prev); + } + if (newM != null) { + markerTreeMapByX.compute(newM.getX(), (k,v) -> { + if (v == null) { + return new ArrayList<>(Arrays.asList(newM)); + } else { + v.add(newM); + return v; + } + }); + markerTreeMapByY.compute(newM.getY(), (k,v) -> { + if (v == null) { + return new ArrayList<>(Arrays.asList(newM)); + } else { + v.add(newM); + return v; + } + }); + markerSet.add(newM); + } + } + + public void setupMarkers() { + for (int i1 = 0; i1 < markers.length; i1++) { + Marker orig = markers[i1]; + Vec3 pt = facing[i1]; + markers[i1] = new Marker((int) (pt.xCoord * getMainPanel().getBounds().width), (int) (pt.yCoord * getMainPanel().getBounds().height), (int) pt.zCoord, this); + + removeAndAddMarker(orig, markers[i1]); + } + } + + + @Override + public void keyTyped(char typedChar, int keyCode) throws IOException { + try { + getMainPanel().keyTyped0(typedChar, keyCode); + + if (keyCode == 1) { + Minecraft.getMinecraft().displayGuiScreen(before); + } + } catch (Throwable e) { + if (!e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + @Override + public void initGui() { + super.initGui(); + getMainPanel().setBounds(new Rectangle(0,0,Minecraft.getMinecraft().displayWidth,Minecraft.getMinecraft().displayHeight)); + markerTreeMapByX.clear(); + markerTreeMapByY.clear(); + markerSet.clear(); + setupMarkers(); + for (MPanel childComponent : getMainPanel().getChildComponents()) { + if (childComponent instanceof PanelDelegate) { + ((PanelDelegate) childComponent).rebuildMarker(); + } + } + + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/Marker.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/Marker.java new file mode 100644 index 00000000..7a0b9c58 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/Marker.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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.location; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.ToString; + +@Getter +@ToString +@AllArgsConstructor +public class Marker { + private final int x; + private final int y; + /** + * 0xABCDEFGH + * A: ? + * B: ? + * C: ? + * D: ? + * EF: 0~3 (TC 0x00 CL 0x01 BC 0x10 CR 0x11) + */ + private final int type; + private final Object parent; + + public int distanceSQ(Marker m2) { + return (m2.x - x)*(m2.x - x) + (m2.y - y)*(m2.y - y); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java new file mode 100644 index 00000000..b22175a4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java @@ -0,0 +1,46 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.nyu; + +import kr.syeyoung.dungeonsguide.config.guiconfig.old.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.gui.MGui; +import net.minecraft.client.Minecraft; + +import java.awt.*; + +public class GuiConfigV2 extends MGui { + + private RootConfigPanel rootConfigPanel; + + public GuiConfigV2() { + rootConfigPanel = new RootConfigPanel(); + rootConfigPanel.setPageGenerator(ConfigPanelCreator.INSTANCE); + getMainPanel().add(rootConfigPanel); + } + + + @Override + public void initGui() { + super.initGui(); + int dw = Minecraft.getMinecraft().displayWidth; + int dh = Minecraft.getMinecraft().displayHeight; + rootConfigPanel.setBounds(new Rectangle((dw-1000)/2, (dh-800)/2, 1000,800)); + rootConfigPanel.setScale(2.0f); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java new file mode 100644 index 00000000..5d00d15a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java @@ -0,0 +1,75 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.nyu; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.function.Consumer; + +public class MCategoryElement extends MPanel { + private String category; + private Consumer onClick; + private int leftPad = 0; + private int offsetX; + private RootConfigPanel rootConfigPanel; + public MCategoryElement(String category, Consumer onClick, int leftPad, int offsetX, RootConfigPanel rooot) { + this.category = category; + this.onClick = onClick; + this.leftPad = leftPad; + this.offsetX = offsetX; + this.rootConfigPanel = rooot; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (rootConfigPanel.getCurrentPage().equals(category)) { + GL11.glDisable(GL11.GL_SCISSOR_TEST); + Gui.drawRect(leftPad - offsetX, 0, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.13f)); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + } else if (lastAbsClip.contains(absMousex, absMousey)) { + GL11.glDisable(GL11.GL_SCISSOR_TEST); + Gui.drawRect(leftPad - offsetX, 0, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.09f)); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + } + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String name = category.substring(category.lastIndexOf(".")+1); + fr.drawString(name, leftPad,2,-1); + + } + + @Override + public Dimension getPreferredSize() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + return new Dimension(fr.getStringWidth(category.substring(category.lastIndexOf(".")+1)) + leftPad+10, fr.FONT_HEIGHT+4); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (!lastAbsClip.contains(absMouseX, absMouseY)) { return; } + if (onClick != null) onClick.accept(category); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MNotFound.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MNotFound.java new file mode 100644 index 00000000..0d58be44 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MNotFound.java @@ -0,0 +1,40 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.nyu; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class MNotFound extends MPanel { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0,0,parentWidth,parentHeight)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("404 Not Found", (getBounds().width - fr.getStringWidth("404 Not Found")) / 2, (getBounds().height - fr.FONT_HEIGHT) / 2, -1); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java new file mode 100644 index 00000000..b81d96a2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java @@ -0,0 +1,160 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.nyu; + +import com.google.common.base.Function; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.*; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; +import net.minecraft.client.gui.Gui; + +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +public class RootConfigPanel extends MPanelScaledGUI { + + private MScrollablePanel navigationScroll; + + private MList navigation = new MList(); + + private MScrollablePanel contentScroll; + + + private final Map pages = new HashMap(); + @Getter + @Setter + private Function pageGenerator; + @Getter + private String currentPage = ""; + + public RootConfigPanel() { + navigationScroll = new MScrollablePanel(1); + navigationScroll.setHideScrollBarWhenNotNecessary(false); + add(navigationScroll); + navigationScroll.add(navigation); + navigationScroll.add(new MSpacer(0,0,1,1)); + + contentScroll = new MScrollablePanel(3); + contentScroll.setHideScrollBarWhenNotNecessary(true); + add(contentScroll); + + setupNavigation(); + navigation.setGap(0); + navigation.setDrawLine(false); + + rePlaceElements(); + } + + @Data + @Accessors(chain = true, fluent = true) + private static class NestedCategory { + private final String categoryFull; + private String categoryName; + public NestedCategory(String categoryFull) { + this.categoryFull =categoryFull; + this.categoryName = categoryFull.substring(categoryFull.lastIndexOf(".")+1); + } + + private Map children = new HashMap<>(); + public NestedCategory child(NestedCategory child) { + this.children.put(child.categoryName, child); + return this; + } + } + + private void setupNavigation() { + NestedCategory root = new NestedCategory("ROOT"); + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + String category = abstractFeature.getCategory(); + + NestedCategory currentRoot = root; + for (String s : category.split("\\.")) { + NestedCategory finalCurrentRoot = currentRoot; + currentRoot = currentRoot.children().computeIfAbsent(s, k -> new NestedCategory(finalCurrentRoot.categoryFull+"."+k)); + } + } + for (NestedCategory value : root.children().values()) { + setupNavigationRecursive(value, navigation, 0, 17); + } + } + private void setupNavigationRecursive(NestedCategory nestedCategory, MPanel parent, int depth, int offset) { + if (nestedCategory.children().size() == 0) { + MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull, this::setCurrentPage, 13 * depth + 17, offset, this); + parent.add(current); + } else { + MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull, this::setCurrentPage, 3,offset, this); + MCollapsable mCollapsable = new MCollapsable(current, this::rePlaceElements); + mCollapsable.setLeftPad(offset-13); + mCollapsable.getLowerElements().setDrawLine(false); + mCollapsable.getLowerElements().setGap(0); + mCollapsable.setLeftPadElements(0); + parent.add(mCollapsable); + + for (NestedCategory value : nestedCategory.children().values()) { + setupNavigationRecursive(value, mCollapsable, depth+1, offset+13); + } + } + } + + + public void setCurrentPage(String currentPage) { + this.currentPage = currentPage; + + contentScroll.getContentArea().getChildComponents().forEach(contentScroll.getContentArea()::remove); + if (!pages.containsKey(currentPage)) { + MPanel page = pageGenerator.apply(currentPage); + if (page == null) page = new MNotFound(); + pages.put(currentPage, page); + } + contentScroll.getContentArea().add(pages.get(currentPage)); + rePlaceElements(); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Dimension effectiveDim = getEffectiveDimension(); + Gui.drawRect(0,0, (int) (effectiveDim.width), (int) (effectiveDim.height), RenderUtils.blendAlpha(0, 0.0f)); + Gui.drawRect(1,1, (int) (effectiveDim.width)-1, (int) (effectiveDim.height) - 1, RenderUtils.blendAlpha(0x141414, 0.00f)); + Gui.drawRect(1,1, (int) (effectiveDim.width)-1, 25, RenderUtils.blendAlpha(0x0, 0.20f)); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + rePlaceElements(); + } + + private void rePlaceElements() { + Dimension effectiveDim = getEffectiveDimension(); + navigation.setBounds(new Rectangle(new Point(0,1), new Dimension(Math.max(100, Math.max(navigation.getPreferredSize().width, navigationScroll.getBounds().width-10)), navigation.getPreferredSize().height))); + navigation.realignChildren(); + navigationScroll.evalulateContentArea(); + Rectangle navBound; + navigationScroll.setBounds(navBound = new Rectangle(1,25, navigation.getBounds().width+10, effectiveDim.height-24)); + + contentScroll.setBounds(new Rectangle(navBound.x + navBound.width + 1, 25, effectiveDim.width - navBound.x - navBound.width - 2, effectiveDim.height -26)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/ConfigPanelCreator.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/ConfigPanelCreator.java new file mode 100644 index 00000000..57db9864 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/ConfigPanelCreator.java @@ -0,0 +1,40 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.old; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +public class ConfigPanelCreator implements Function { + public static final ConfigPanelCreator INSTANCE = new ConfigPanelCreator(); + + public static final Map> map = new HashMap>(); + + @Nullable + @Override + public MPanel apply(@Nullable String input) { + if (!map.containsKey(input)) return null; + return map.get(input).get(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/FeatureEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/FeatureEditPane.java new file mode 100755 index 00000000..2109c1a7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/FeatureEditPane.java @@ -0,0 +1,108 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.old; + +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.*; +import net.minecraft.client.gui.ScaledResolution; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class FeatureEditPane extends MPanel { + private final List features; + + private final List le = new ArrayList(); + + private final GuiConfig config; + + private MTextField textField; + private String search = ""; + + public FeatureEditPane(List features, GuiConfig config) { + this.features = features; + this.config = config; + buildElements(); + + } + + + public void buildElements() { + for (AbstractFeature feature : features) { + MFeature mFeature = new MFeature(feature, config); + mFeature.setHover(new Color(94, 94, 94, 255)); + le.add(mFeature); + add(mFeature); + } + + textField = new MTextField() { + @Override + public void edit(String str) { + offsetY = 0; + search = str; + } + }; + textField.setText(""); + textField.setBounds(new Rectangle(getBounds().width - 200, 0, 200, 20)); + add(textField); + } + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, panel.getPreferredSize().height)); + } + textField.setBounds(new Rectangle(getBounds().width - 200, 0, 200, 20)); + } + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,1,parentWidth-10,parentHeight-2)); + } + + @Override + public List getChildComponents() { + List comp = new ArrayList(); + comp.add(textField); + for (MFeature feature:le) { + if (feature.getFeature().getName().toLowerCase().contains(search.toLowerCase())) + comp.add(feature); + } + return comp; + } + + private int offsetY = 0; + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + int heights = 0; + for (MPanel panel:getChildComponents()) { + panel.setPosition(new Point(panel.getBounds().x, -offsetY + heights)); + heights += panel.getBounds().height + 5; + } + } + + + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (scrollAmount > 0) offsetY -= 20; + else if (scrollAmount < 0) offsetY += 20; + if (offsetY < 0) offsetY = 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/GuiConfig.java new file mode 100755 index 00000000..822c5e2f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/GuiConfig.java @@ -0,0 +1,92 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.old; + +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.gui.MGui; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MNavigatingPane; +import kr.syeyoung.dungeonsguide.gui.elements.MPanelScaledGUI; +import lombok.Getter; +import net.minecraft.client.Minecraft; + +import java.awt.*; +import java.util.List; +import java.util.Map; +import java.util.Stack; +import java.util.stream.Collectors; + +public class GuiConfig extends MGui { + + + @Getter + private final MNavigatingPane tabbedPane; + + private final Stack history = new Stack(); + + private MPanelScaledGUI panelScaledGUI; + public GuiConfig() { + + panelScaledGUI = new MPanelScaledGUI(); + getMainPanel().add(panelScaledGUI); + MNavigatingPane tabbedPane = new MNavigatingPane(); + panelScaledGUI.add(tabbedPane); + tabbedPane.setBackground2(new Color(38, 38, 38, 255)); + + tabbedPane.setPageGenerator(ConfigPanelCreator.INSTANCE); + + tabbedPane.addBookmarkRunnable("GUI Relocate", new Runnable() { + @Override + public void run() { + Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(GuiConfig.this, null)); + } + }); + + for (final Map.Entry> cate: FeatureRegistry.getFeaturesByCategory().entrySet()) + if (!cate.getKey().equals("hidden")) { + tabbedPane.addBookmark(cate.getKey(), "base." + cate.getKey()); + + ConfigPanelCreator.map.put("base." + cate.getKey(), new Supplier() { + @Override + public MPanel get() { + return new FeatureEditPane(cate.getValue(), GuiConfig.this); + } + }); + } + tabbedPane.addBookmark("All", "base.all"); + + ConfigPanelCreator.map.put("base.all", new Supplier() { + @Override + public MPanel get() { + return new FeatureEditPane(FeatureRegistry.getFeatureList().stream().filter( a-> !a.getCategory().equals("hidden")).collect(Collectors.toList()), GuiConfig.this); + } + }); + this.tabbedPane = tabbedPane; + } + + @Override + public void initGui() { + super.initGui(); + panelScaledGUI.setBounds(new Rectangle(Math.min((Minecraft.getMinecraft().displayWidth - 1000) / 2, Minecraft.getMinecraft().displayWidth), Math.min((Minecraft.getMinecraft().displayHeight - 700) / 2, Minecraft.getMinecraft().displayHeight),1000,700)); + panelScaledGUI.setScale(1.0); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/GuiParameterValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/GuiParameterValueEdit.java new file mode 100755 index 00000000..b759ead9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/GuiParameterValueEdit.java @@ -0,0 +1,117 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.old; + +import kr.syeyoung.dungeonsguide.gui.MGui; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; + +import java.awt.*; + +public class GuiParameterValueEdit extends MGui { + + + private MPanel currentValueEdit; + + private MButton save; + + @Getter + private ValueEdit valueEdit; + + private Object editingObj; + + @Getter + @Setter + private Runnable onUpdate; + @Getter + private Parameter parameter; + + public GuiParameterValueEdit(final Object object, final GuiConfig prev) { + try { + this.editingObj = object; + getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179)); + { + currentValueEdit = new MPanel() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(5, 5, parentWidth-10, parentHeight - 25)); + } + }; + getMainPanel().add(currentValueEdit); + } + { + save = new MButton() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, parentHeight - 20, parentWidth, 20)); + } + }; + save.setText("Go back"); + save.setBackgroundColor(Color.green); + save.setOnActionPerformed(new Runnable() { + @Override + public void run() { + onUpdate.run(); + Minecraft.getMinecraft().displayGuiScreen(prev); + } + }); + getMainPanel().add(save); + } + updateClassSelection(); + } catch (Exception e){} + } + + public void updateClassSelection() { + currentValueEdit.getChildComponents().clear(); + + ValueEditCreator valueEditCreator = ValueEditRegistry.getValueEditMap(editingObj == null ?"null":editingObj.getClass().getName()); + MPanel valueEdit = (MPanel) valueEditCreator.createValueEdit(parameter= new Parameter("", editingObj, editingObj)); + if (valueEdit == null) { + MLabel valueEdit2 = new MLabel() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, 0, parentWidth,20)); + } + }; + valueEdit2.setText("No Value Edit"); + valueEdit2.setBounds(new Rectangle(0,0,150,20)); + valueEdit = valueEdit2; + this.valueEdit = null; + } else{ + this.valueEdit = (ValueEdit) valueEdit; + } + valueEdit.resize0(currentValueEdit.getBounds().width, currentValueEdit.getBounds().height); + currentValueEdit.add(valueEdit); + } + @Override + public void initGui() { + super.initGui(); + // update bounds + getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300)); + save.setBounds(new Rectangle(0 ,getMainPanel().getBounds().height - 20, getMainPanel().getBounds().width, 20)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MFeature.java new file mode 100755 index 00000000..4b3b8237 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MFeature.java @@ -0,0 +1,143 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.old; + +import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.GuiFeature; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +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.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.List; +import java.util.ArrayList; + +public class MFeature extends MPanel { + + @Getter + private final AbstractFeature feature; + + private final List addons = new ArrayList(); + + @Getter @Setter + private Color hover; + + private final GuiConfig config; + + public MFeature(final AbstractFeature abstractFeature, final GuiConfig config) { + this.config = config; + this.feature = abstractFeature; + + if (abstractFeature.isDisyllable()) { + final MToggleButton mStringSelectionButton = new MToggleButton(); + mStringSelectionButton.setOnToggle(new Runnable() { + @Override + public void run() { + boolean selected = mStringSelectionButton.isEnabled(); + feature.setEnabled(selected); + } + }); + addons.add(mStringSelectionButton); + mStringSelectionButton.setEnabled(feature.isEnabled()); + mStringSelectionButton.setSize(new Dimension(30, 15)); + add(mStringSelectionButton); + } + if (abstractFeature.getParameters().size() != 0) { + MButton button = new MButton(); + button.setText("Edit"); + button.setOnActionPerformed(new Runnable() { + @Override + public void run() { + config.getTabbedPane().setCurrentPage(abstractFeature.getEditRoute(config)); + } + }); + addons.add(button); + button.setSize(new Dimension(50, 15)); + add(button); + } + if (abstractFeature instanceof GuiFeature) { + MButton button = new MButton(); + button.setText("GUI"); + button.setOnActionPerformed(new Runnable() { + @Override + public void run() { + Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(config, abstractFeature)); + } + }); + addons.add(button); + button.setSize(new Dimension(50, 15)); + add(button); + } + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Gui.drawRect(0,0,getBounds().width, getBounds().height,0xFF444444); + if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, hover.getRGB()); + } else { + Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, 0xFF545454); + } + Gui.drawRect(0,17,getBounds().width, 18,0xFF444444); + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.pushMatrix(); + GlStateManager.translate(5,5,0); + GlStateManager.scale(1.0,1.0,0); + 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(feature.getName(), 0,0, 0xFFFFFFFF); + GlStateManager.popMatrix(); + + fr.drawSplitString(feature.getDescription(), 5, 23, getBounds().width -10, 0xFFBFBFBF); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + } + + @Override + public Dimension getPreferredSize() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int descriptionHeight = fr.listFormattedStringToWidth(feature.getDescription(), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT; + + return new Dimension(100, descriptionHeight + 28); + } + + @Override + public void onBoundsUpdate() { + int x = getBounds().width - 5; + for (MPanel panel : addons) { + panel.setBounds(new Rectangle(x - panel.getPreferredSize().width, 3, panel.getPreferredSize().width, 12)); + x -= panel.getPreferredSize().width + 5; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MParameter.java new file mode 100755 index 00000000..49db94a8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MParameter.java @@ -0,0 +1,142 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.old; + +import kr.syeyoung.dungeonsguide.config.types.AColor; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MEditableAColor; +import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +public class MParameter extends MPanel { + private final MLabel label; + + @Getter + private final AbstractFeature feature; + @Getter + private final FeatureParameter parameter; + + private final List addons = new ArrayList(); + + @Getter @Setter + private Color hover; + + private PanelDefaultParameterConfig config; + + private final MLabel label2; + public MParameter(AbstractFeature abstractFeature, final FeatureParameter parameter, final GuiConfig config2) { + this.config = config; + this.parameter = parameter; + this.feature = abstractFeature; + + this.add(this.label = new MLabel()); + this.label.setText(parameter.getName()); + + { + if (parameter.getValue_type().equalsIgnoreCase("boolean")) { + final MToggleButton button = new MToggleButton(); + button.setOnToggle(new Runnable() { + @Override + public void run() { + parameter.setValue(button.isEnabled()); + label2.setText(parameter.getValue().toString()); + } + }); + button.setEnabled((Boolean) parameter.getValue()); + addons.add(button); + add(button); + } else if (parameter.getValue_type().equalsIgnoreCase("acolor")) { + final MEditableAColor button = new MEditableAColor(); + button.setEnableEdit(true); + button.setOnUpdate(new Runnable() { + @Override + public void run() { + parameter.setValue(button.getColor()); + label2.setText(parameter.getValue().toString()); + } + }); + button.setColor((AColor) parameter.getValue()); + addons.add(button); + add(button); + } else { + MButton button = new MButton(); + button.setText("Edit"); + button.setOnActionPerformed(new Runnable() { + @Override + public void run() { + final GuiParameterValueEdit guiParameterValueEdit = new GuiParameterValueEdit(parameter.getValue(), config2); + guiParameterValueEdit.setOnUpdate(new Runnable() { + @Override + public void run() { + Parameter parameter1 = guiParameterValueEdit.getParameter(); + parameter.setValue(parameter1.getNewData()); + label2.setText(parameter.getValue().toString()); + } + }); + Minecraft.getMinecraft().displayGuiScreen(guiParameterValueEdit); + } + }); + addons.add(button); + add(button); + } + } + { + MLabel button = new MLabel(); + button.setText(parameter.getValue().toString()); + addons.add(button); + add(button); + label2 = button; + } + setSize(new Dimension(100,20)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + } + + @Override + public void onBoundsUpdate() { + int x = getBounds().width - 50; + for (MPanel panel : addons) { + panel.setBounds(new Rectangle(x, 3, 50, getBounds().height - 6)); + } + label2.setBounds(new Rectangle(x/2,0,x/2,getBounds().height)); + label.setBounds(new Rectangle(0,0,x/2, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDefaultParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDefaultParameterConfig.java new file mode 100755 index 00000000..9f8dafc4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDefaultParameterConfig.java @@ -0,0 +1,105 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.old; + +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.MParameter; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +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 java.util.List; +import java.awt.*; +import java.util.Arrays; +import java.util.Set; + +public class PanelDefaultParameterConfig extends MPanel { + + private AbstractFeature feature; + + @Override + public void onBoundsUpdate() { + for (MPanel childComponent : getChildComponents()) { + childComponent.setSize(new Dimension(getBounds().width - 10, childComponent.getSize().height)); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + private final GuiConfig config; + public PanelDefaultParameterConfig(final GuiConfig config, AbstractFeature feature, List pre, Set ignore) { + this.config = config; + for (MPanel mPanel : pre) { + add(mPanel); + } + for (FeatureParameter parameter: feature.getParameters()) { + if (ignore.contains(parameter.getKey())) continue; + add(new MParameter(feature, parameter, config)); + } + setBackgroundColor(new Color(38, 38, 38, 255)); + } + + + MPanel within; + MTooltip mTooltip; + MParameter lastWithin; + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + int heights = 0; + within = null; + for (MPanel panel:getChildComponents()) { + panel.setPosition(new Point(5, -offsetY + heights + 5)); + heights += panel.getBounds().height; + + if (panel.getBounds().contains(relMousex0,relMousey0)) within = panel; + } + if (within instanceof MParameter) { + FeatureParameter feature = ((MParameter) within).getParameter(); + if (lastWithin != within) { + if (mTooltip != null) mTooltip.close(); + mTooltip = new MTooltipText(Arrays.asList(feature.getDescription().split("\n"))); + mTooltip.open(this); + } + } else { + if (mTooltip != null) { + mTooltip.close(); + mTooltip = null; + } + } + } + + + public int offsetY = 0; + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + for (MPanel childComponent : getChildComponents()) { + if (!(childComponent instanceof MParameter) && childComponent.getBounds().contains(relMouseX0, relMouseY0)) return; + } + if (scrollAmount > 0) offsetY -= 20; + else if (scrollAmount < 0) offsetY += 20; + if (offsetY < 0) offsetY = 0; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDelegate.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDelegate.java new file mode 100644 index 00000000..720ae30a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDelegate.java @@ -0,0 +1,371 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.config.guiconfig.old; + +import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.location.Marker; +import kr.syeyoung.dungeonsguide.config.types.GUIRectangle; +import kr.syeyoung.dungeonsguide.features.GuiFeature; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MPopupMenu; +import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Tuple; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class PanelDelegate extends MPanel { + private final GuiFeature guiFeature; + private boolean draggable = false; + private GuiGuiLocationConfig guiGuiLocationConfig; + + private Set markerSet = new HashSet<>(); + public PanelDelegate(GuiFeature guiFeature, boolean draggable, GuiGuiLocationConfig guiGuiLocationConfig) { + this.guiFeature = guiFeature; + this.draggable = draggable; + this.guiGuiLocationConfig = guiGuiLocationConfig; + } + + public void rebuildMarker() { + internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale(); + applyConstraint(); + } + + @Override + public Rectangle getBounds() { + Rectangle rectangle = guiFeature.getFeatureRect().getRectangle(); + return new Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height); + } + + @Override + public void render(int absMousex, int absMousey, int relMouseX, int relMouseY, float partialTicks, Rectangle scissor) { + if (!guiFeature.isEnabled()) return; + + GlStateManager.pushMatrix(); + guiFeature.drawDemo(partialTicks); + GlStateManager.popMatrix(); + if (!draggable) return; + Gui.drawRect(0,0, 4, 4, 0xFFBBBBBB); + Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0xFFBBBBBB); + Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0xFFBBBBBB); + Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0xFFBBBBBB); + if (lastAbsClip.contains(absMousex, absMousey)) { + if (relMouseX < 4 && relMouseY < 4) { + Gui.drawRect(0,0, 4, 4, 0x55FFFFFF); + } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { + Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0x55FFFFFF); + } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { + Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0x55FFFFFF); + } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { + Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0x55FFFFFF); + } else if (selectedPart == -2){ + Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55FFFFFF); + } + } + GlStateManager.enableBlend(); + } + + @Override + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { + GlStateManager.pushMatrix(); + super.render0(scale, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); + GlStateManager.popMatrix(); + + if (snapped != null && selectedPart != -2) { + Tessellator tessellator = Tessellator.getInstance(); + GlStateManager.disableTexture2D(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); + GL11.glLineWidth(1); + for (Tuple markerAxisTuple : snapped) { + if (markerAxisTuple.getSecond() == EnumFacing.Axis.X) { + worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), 0, 0).color(0,255,0,255).endVertex(); + worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), Minecraft.getMinecraft().displayHeight, 0).color(0,255,0,255).endVertex(); + } else { + worldRenderer.pos(0, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex(); + worldRenderer.pos(Minecraft.getMinecraft().displayWidth, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex(); + } + } + tessellator.draw(); + for (Marker marker : guiGuiLocationConfig.getMarkerSet()) { + Gui.drawRect(marker.getX(),marker.getY(), marker.getX()+1, marker.getY()+1, 0xFFFF0000); + } + } + } + + private int selectedPart = -2; + + private int lastX = 0; + private int lastY = 0; + + private Rectangle internallyThinking; + private Rectangle constraintApplied; + + private Set> snapped = new HashSet<>(); + + public void applyConstraint() { + constraintApplied = internallyThinking.getBounds(); + + // SNAP Moving Point. + snapped.clear(); + int scailingThreshold = 5; + if (selectedPart == 0){ + Point snapPt = new Point(constraintApplied.x +constraintApplied.width, constraintApplied.y + constraintApplied.height); + Optional snapX, snapY; + SortedMap> markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(snapPt.x-scailingThreshold, snapPt.x +scailingThreshold); + snapX = markerSortedMap.values().stream() + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(a -> a.getParent() != this) + .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY()))); + markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(snapPt.y-scailingThreshold, snapPt.y +scailingThreshold); + snapY = markerSortedMap.values().stream() + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(a -> a.getParent() != this) + .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY()))); + snapX.ifPresent(a -> { + snapPt.x = a.getX(); + }); + snapY.ifPresent(a -> { + snapPt.y = a.getY(); + }); + + constraintApplied = new Rectangle(constraintApplied.x, constraintApplied.y, snapPt.x - constraintApplied.x, snapPt.y - constraintApplied.y); + + + + int minWidth; + int minHeight; + if (guiFeature.isKeepRatio()) { + if (guiFeature.getDefaultRatio() >= 1) { + minHeight = constraintApplied.height < 0 ? -8 : 8; + minWidth = (int) (guiFeature.getDefaultRatio() * minHeight); + } else { + minWidth = constraintApplied.width < 0 ? -8 : 8; + minHeight = (int) (minWidth / guiFeature.getDefaultRatio()); + } + } else { + minWidth = constraintApplied.width < 0 ? -8 : 8; + minHeight = constraintApplied.height < 0 ? -8 : 8; + } + + + constraintApplied.width = Math.abs(constraintApplied.width) > Math.abs(minWidth) ? constraintApplied.width : + Math.abs(internallyThinking.width) > Math.abs(minWidth) ? internallyThinking.width : minWidth; + constraintApplied.height = Math.abs(constraintApplied.height) > Math.abs(minHeight) ? constraintApplied.height : + Math.abs(internallyThinking.height) > Math.abs(minHeight) ? internallyThinking.height : minHeight; + + if (guiFeature.isKeepRatio()) { + double ratio = guiFeature.getDefaultRatio(); + + int heightWhenWidthFix = (int) Math.abs(constraintApplied.width / ratio); + int widthWhenHeightFix = (int) Math.abs(ratio * constraintApplied.height); + if (Math.abs(heightWhenWidthFix) <= Math.abs(constraintApplied.height)) { + constraintApplied.height = constraintApplied.height < 0 ? -heightWhenWidthFix : heightWhenWidthFix; + } else if (Math.abs(widthWhenHeightFix) <= Math.abs(constraintApplied.width)) { + constraintApplied.width =constraintApplied.width < 0 ? - widthWhenHeightFix : widthWhenHeightFix; + } + } + + + snapX.ifPresent(a -> { + if (snapPt.x - constraintApplied.x == constraintApplied.width) { + Marker m = new Marker((int) (GuiGuiLocationConfig.facing[3].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[3].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[3].zCoord, this); + snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.X)); + } + }); + snapY.ifPresent(a -> { + if (snapPt.y - constraintApplied.y == constraintApplied.height) { + Marker m = new Marker((int) (GuiGuiLocationConfig.facing[2].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[2].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[2].zCoord, this); + snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.Y)); + } + }); + + if (constraintApplied.height < 0) { + constraintApplied.height = -constraintApplied.height; + constraintApplied.y -= constraintApplied.height; + } + + if (constraintApplied.width < 0) { + constraintApplied.width = -constraintApplied.width; + constraintApplied.x -= constraintApplied.width; + } + } else if (selectedPart == -1) { + for (int i : Arrays.asList(0,3,1,2)) { + Vec3 pt = GuiGuiLocationConfig.facing[i]; + Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); + Optional result = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(m.getX()-scailingThreshold, m.getX() +scailingThreshold).values().stream() + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(a -> a.getParent() != this) + .filter(a -> Math.abs(a.getX() - m.getX()) < scailingThreshold) + .filter(a -> ((a.getX() - pt.xCoord * constraintApplied.width) >= 0 + && (a.getX() - pt.xCoord * constraintApplied.width + constraintApplied.width) <= Minecraft.getMinecraft().displayWidth)) + .min(Comparator.comparingInt(a -> a.distanceSQ(m))); + if (result.isPresent()) { + int x = result.get().getX(); + constraintApplied.x = (int) (x - pt.xCoord * constraintApplied.width); + + snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.X)); + break; + } + } + for (int i : Arrays.asList(1,2,0,3)) { + Vec3 pt = GuiGuiLocationConfig.facing[i]; + Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); + Optional result = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(m.getY()-scailingThreshold, m.getY() +scailingThreshold).values().stream() + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(a -> a.getParent() != this) + .filter(a -> Math.abs(a.getY() - m.getY()) < scailingThreshold) + .filter(a -> ((a.getY() - pt.yCoord * constraintApplied.height) >= 0 + && (a.getY() - pt.yCoord * constraintApplied.height+ constraintApplied.height) <= Minecraft.getMinecraft().displayHeight)) + .min(Comparator.comparingInt(a -> a.distanceSQ(m))); + if (result.isPresent()) { + int y = result.get().getY(); + constraintApplied.y = (int) (y - pt.yCoord * constraintApplied.height); + snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.Y)); + break; + } + } + } + + if (constraintApplied.x < 0) constraintApplied.x = 0; + if (constraintApplied.y < 0) constraintApplied.y = 0; + if (constraintApplied.x + constraintApplied.width + 1 >=Minecraft.getMinecraft().displayWidth) constraintApplied.x = Minecraft.getMinecraft().displayWidth - constraintApplied.width - 1; + if (constraintApplied.y + constraintApplied.height + 1>= Minecraft.getMinecraft().displayHeight) constraintApplied.y = Minecraft.getMinecraft().displayHeight - constraintApplied.height - 1; + + + setupMarkers(); + } + + Marker[] markers = new Marker[4]; + public void setupMarkers() { + for (int i1 = 0; i1 < markers.length; i1++) { + Marker orig = markers[i1]; + + Vec3 pt = GuiGuiLocationConfig.facing[i1]; + markers[i1] = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); + + guiGuiLocationConfig.removeAndAddMarker(orig, markers[i1]); + } + } + + MTooltip mTooltip; + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (!draggable) return; + if (!guiFeature.isEnabled()) return; + if (getTooltipsOpen() > 0) return; + if (!lastAbsClip.contains(absMouseX, absMouseY)) return; + if (mouseButton == 0) { + internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale(); + if (relMouseX < 4 && relMouseY < 4) { // TL + selectedPart = 0; + internallyThinking.y += internallyThinking.height; + internallyThinking.height = -internallyThinking.height; + internallyThinking.x += internallyThinking.width; + internallyThinking.width = -internallyThinking.width; + } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { // BL + selectedPart = 0; + internallyThinking.x += internallyThinking.width; + internallyThinking.width = -internallyThinking.width; + } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { // BR + selectedPart = 0; + } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { // TR + selectedPart = 0; + internallyThinking.y += internallyThinking.height; + internallyThinking.height = -internallyThinking.height; + } else { + selectedPart = -1; + } + lastX = absMouseX; + lastY = absMouseY; + applyConstraint(); + + } else if (getTooltipsOpen() == 0){ + if (mTooltip != null) mTooltip.close(); + mTooltip = new MPopupMenu(absMouseX, absMouseY, guiFeature.getTooltipForEditor(guiGuiLocationConfig)); + mTooltip.open(this); + } + throw new IllegalArgumentException("bruh, a hack to stop event progress"); + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + if (!draggable) return; + if (!guiFeature.isEnabled()) return; + if (selectedPart >= -1) { + guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); + } + + selectedPart = -2; + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + if (!draggable) return; + if (!guiFeature.isEnabled()) return; + int dx = (absMouseX - lastX); + int dy = (absMouseY - lastY); + if (selectedPart >= 0) { + Rectangle rectangle = internallyThinking; + + int prevWidth = rectangle.width; + int prevHeight= rectangle.height; + + rectangle.width = prevWidth + dx; + rectangle.height = prevHeight + dy; + + if (rectangle.height * prevHeight <= 0 && prevHeight != rectangle.height) { + rectangle.height += prevHeight < 0 ? 4 : -4; + } + if (rectangle.width * prevWidth <= 0 && prevWidth != rectangle.width) { + rectangle.width += prevWidth < 0 ? 4 : -4; + } + + + applyConstraint(); + guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); + lastX = absMouseX; + lastY = absMouseY; + throw new IllegalArgumentException("bruh, a hack to stop event progress"); + } else if (selectedPart == -1){ + Rectangle rectangle = internallyThinking; + rectangle.translate(dx, dy); + applyConstraint(); + guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); + lastX = absMouseX; + lastY = absMouseY; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java index 904ff043..96683f5b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java @@ -20,7 +20,7 @@ package kr.syeyoung.dungeonsguide.eventlistener; import kr.syeyoung.dungeonsguide.DungeonsGuide; import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; import kr.syeyoung.dungeonsguide.events.*; import kr.syeyoung.dungeonsguide.features.*; import kr.syeyoung.dungeonsguide.features.AbstractFeature; @@ -31,7 +31,6 @@ import net.minecraftforge.client.event.*; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java index 3429a4df..7b2d5ba0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java @@ -21,15 +21,14 @@ package kr.syeyoung.dungeonsguide.features; import com.google.common.base.Supplier; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.PanelDefaultParameterConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.PanelDefaultParameterConfig; import kr.syeyoung.dungeonsguide.config.types.TypeConverter; import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry; import kr.syeyoung.dungeonsguide.gui.MPanel; import lombok.Getter; import lombok.Setter; -import net.minecraft.client.Minecraft; import java.util.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index 860cd86a..b1db6d2d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -152,12 +152,18 @@ public class FeatureRegistry { public static final FeatureMechanicBrowse SECRET_BROWSE = register(new FeatureMechanicBrowse()); public static final FeatureActions SECRET_ACTIONS = register(new FeatureActions()); public static final FeatureSoulRoomWarning SECRET_FAIRYSOUL = register(new FeatureSoulRoomWarning()); - public static final SimpleFeature SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Secret", "Auto browse next secret.", "Auto browse best next secret after current one completes.\nthe first pathfinding of first secret needs to be triggered first in order for this option to work", "secret.autobrowse", false)); - public static final SimpleFeature SECRET_AUTO_START = register(new SimpleFeature("Secret", "Auto browse secret upon entering room", "Auto browse best secret upon entering the room.", "secret.autouponenter", false)); - public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Secret", "Auto browse next secret upon pressing a key", "Auto browse the best next secret when you press key.\nChange key at your key settings (Settings -> Controls)", "secret.keyfornext", false)); - public static final SimpleFeature SECRET_TOGGLE_KEY = register(new SimpleFeature("Secret", "Press a key to toggle pathfind lines", "A key for toggling pathfound line visibility.\nChange key at your key settings (Settings -> Controls)", "secret.togglePathfind")); + public static final SimpleFeature SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Dungeon Secret.Secret Pathfind", "Auto browse next secret.", "Auto browse best next secret after current one completes.\nthe first pathfinding of first secret needs to be triggered first in order for this option to work", "secret.autobrowse", false)); + public static final SimpleFeature SECRET_AUTO_START = register(new SimpleFeature("Dungeon Secret.Secret Pathfind", "Auto browse secret upon entering room", "Auto browse best secret upon entering the room.", "secret.autouponenter", false)); + public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Dungeon Secret.Secret Pathfind", "Auto browse next secret upon pressing a key", "Auto browse the best next secret when you press key.\nChange key at your key settings (Settings -> Controls)", "secret.keyfornext", false)); + public static final SimpleFeature SECRET_TOGGLE_KEY = register(new SimpleFeature("Dungeon Secret.Pathfind Display", "Press a key to toggle pathfind lines", "A key for toggling pathfound line visibility.\nChange key at your key settings (Settings -> Controls)", "secret.togglePathfind")); public static final SimpleFeature SECRET_FREEZE_LINES = register(new FeatureFreezePathfind()); public static final FeatureNicknamePrefix COSMETIC_PREFIX = register(new FeatureNicknamePrefix()); public static final FeatureNicknameColor COSMETIC_NICKNAMECOLOR = register(new FeatureNicknameColor()); + + public static final SimpleFeature TEST_1 = register(new SimpleFeature("Test", "t", "t", "emp")); + public static final SimpleFeature TEST_1_1 = register(new SimpleFeature("Test.Test1", "t", "t", "emp")); + public static final SimpleFeature TEST_1_2 = register(new SimpleFeature("Test.Test2", "t", "t", "emp")); + public static final SimpleFeature TEST_1_2_1 = register(new SimpleFeature("Test.Test2.Test1", "t", "t", "emp")); + } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java index ceb7ec69..4c60c090 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java @@ -19,12 +19,11 @@ package kr.syeyoung.dungeonsguide.features; import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; import kr.syeyoung.dungeonsguide.config.types.GUIRectangle; import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry; import kr.syeyoung.dungeonsguide.features.listener.ScreenRenderListener; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.gui.elements.*; import lombok.AccessLevel; @@ -32,7 +31,6 @@ 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.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; @@ -40,9 +38,7 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import java.awt.*; -import java.lang.reflect.Array; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; @Getter diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java index 0242cfc6..1711f955 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java @@ -21,9 +21,9 @@ package kr.syeyoung.dungeonsguide.features.impl.boss; import com.google.common.base.Supplier; import kr.syeyoung.dungeonsguide.DungeonsGuide; import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.PanelDefaultParameterConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.PanelDefaultParameterConfig; import kr.syeyoung.dungeonsguide.config.types.AColor; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.features.FeatureParameter; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknameColor.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknameColor.java index ebfa2456..c81539a0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknameColor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknameColor.java @@ -18,11 +18,10 @@ package kr.syeyoung.dungeonsguide.features.impl.cosmetics; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import net.minecraft.util.EnumChatFormatting; public class FeatureNicknameColor extends SimpleFeature { public FeatureNicknameColor() { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknamePrefix.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknamePrefix.java index e3d5a28f..4796eaa1 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknamePrefix.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknamePrefix.java @@ -18,18 +18,10 @@ package kr.syeyoung.dungeonsguide.features.impl.cosmetics; -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.PanelDefaultParameterConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.DataRendererEditor; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin; -import kr.syeyoung.dungeonsguide.gui.MPanel; - -import java.util.Arrays; -import java.util.Collections; public class FeatureNicknamePrefix extends SimpleFeature { public FeatureNicknamePrefix() { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/PrefixSelectorGUI.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/PrefixSelectorGUI.java index 7f358f29..e888edcf 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/PrefixSelectorGUI.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/PrefixSelectorGUI.java @@ -19,7 +19,7 @@ package kr.syeyoung.dungeonsguide.features.impl.cosmetics; import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; @@ -35,7 +35,6 @@ import java.awt.*; import java.util.*; import java.util.List; import java.util.function.Function; -import java.util.stream.Collectors; public class PrefixSelectorGUI extends MPanel { private GuiConfig config; 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 index c0925a1e..50dad040 100644 --- 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 @@ -18,8 +18,6 @@ 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; @@ -40,7 +38,6 @@ 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 { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java index 8f10f146..1e844e13 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java @@ -18,9 +18,7 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; import kr.syeyoung.dungeonsguide.features.impl.party.api.*; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java index 58327fcf..dd14bee4 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java @@ -18,9 +18,7 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; import kr.syeyoung.dungeonsguide.features.impl.party.api.*; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java index cc6589de..13d256ff 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java @@ -18,7 +18,6 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; import kr.syeyoung.dungeonsguide.features.impl.party.api.*; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java index b9c16e13..80a918ef 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java @@ -18,7 +18,6 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonSpecificData; import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonStat; import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonType; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java index c93b05d3..09e89928 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java @@ -18,7 +18,7 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; import kr.syeyoung.dungeonsguide.gui.MPanel; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -78,7 +78,7 @@ public class DataRendererEditor extends MPanel { Gui.drawRect(155 + hamburgerWidth,4 + fr.FONT_HEIGHT + 3,156 + hamburgerWidth, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); GlStateManager.pushMatrix(); - clip(sr, scissor.x + 6+hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + clip(scissor.x + 6+hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); GlStateManager.translate(6+hamburgerWidth, 5+fr.FONT_HEIGHT+3, 0); int culmutativeY = 0; int relSelectedY = selectedY - (5+ fr.FONT_HEIGHT + 3); @@ -92,7 +92,7 @@ public class DataRendererEditor extends MPanel { else dim = dataRenderer.getDimension(); if (culmutativeY + dim.height > relSelectedY && relSelectedY >= culmutativeY && !drewit) { - clip(sr, scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + clip(scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); 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); @@ -105,7 +105,7 @@ public class DataRendererEditor extends MPanel { dim = dataRenderer.renderDummy(); GlStateManager.popMatrix(); } - clip(sr, scissor.x, scissor.y, scissor.width, scissor.height); + clip(scissor.x, scissor.y, scissor.width, scissor.height); GlStateManager.translate(-hamburgerWidth-1, 0, 0); Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFF777777); GlStateManager.enableBlend(); @@ -118,7 +118,7 @@ public class DataRendererEditor extends MPanel { } DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); - clip(sr, scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + clip(scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); Dimension dim; GlStateManager.enableBlend(); @@ -133,7 +133,7 @@ public class DataRendererEditor extends MPanel { dim = dataRenderer.renderDummy(); GlStateManager.popMatrix(); } - clip(sr, scissor.x, scissor.y, scissor.width, scissor.height); + clip(scissor.x, scissor.y, scissor.width, scissor.height); GlStateManager.translate(-hamburgerWidth-1, 0, 0); Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); GlStateManager.enableBlend(); @@ -148,7 +148,7 @@ public class DataRendererEditor extends MPanel { if (currentlySelected != null && new Rectangle(0,5+fr.FONT_HEIGHT + 3, hamburgerWidth+11, 232).contains(selectedX, selectedY) && !drewit) { DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); Dimension dim; - clip(sr, scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + clip(scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); 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); @@ -161,7 +161,7 @@ public class DataRendererEditor extends MPanel { dim = dataRenderer.renderDummy(); GlStateManager.popMatrix(); } - clip(sr, scissor.x, scissor.y, scissor.width, scissor.height); + clip(scissor.x, scissor.y, scissor.width, scissor.height); GlStateManager.translate(-hamburgerWidth-1, 0, 0); Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFF777777); GlStateManager.enableBlend(); @@ -181,7 +181,7 @@ public class DataRendererEditor extends MPanel { rest.remove(currentlySelected); for (String datarenderers : rest) { DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); - clip(sr, scissor.x + 156 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + clip(scissor.x + 156 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); Dimension dim; GlStateManager.enableBlend(); GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -195,7 +195,7 @@ public class DataRendererEditor extends MPanel { dim = dataRenderer.renderDummy(); GlStateManager.popMatrix(); } - clip(sr, scissor.x + 155, scissor.y + 5+fr.FONT_HEIGHT+3, hamburgerWidth, 230); + clip(scissor.x + 155, scissor.y + 5+fr.FONT_HEIGHT+3, hamburgerWidth, 230); GlStateManager.translate(-hamburgerWidth-1, 0, 0); Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); GlStateManager.enableBlend(); @@ -205,7 +205,7 @@ public class DataRendererEditor extends MPanel { GlStateManager.translate(hamburgerWidth+1,dim.height,0); } GlStateManager.popMatrix(); - clip(sr, 0,0,sr.getScaledWidth(), sr.getScaledHeight()); + clip(0,0,sr.getScaledWidth(), sr.getScaledHeight()); { if (currentlySelected != null) { GlStateManager.pushMatrix(); @@ -233,7 +233,7 @@ public class DataRendererEditor extends MPanel { GlStateManager.popMatrix(); } } - clip(sr, scissor.x, scissor.y, scissor.width, scissor.height); + clip(scissor.x, scissor.y, scissor.width, scissor.height); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererFairySouls.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererFairySouls.java index 7fe2e148..e2895967 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererFairySouls.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererFairySouls.java @@ -18,19 +18,11 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; -import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonSpecificData; -import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonStat; -import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonType; import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.XPUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import java.awt.*; -import java.util.Arrays; public class DataRendererFairySouls implements DataRenderer { @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java index 8f2724aa..db09d941 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java @@ -18,9 +18,7 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; import kr.syeyoung.dungeonsguide.features.impl.party.api.ClassSpecificData; -import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonClass; import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSetUrOwn.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSetUrOwn.java index 0bc62e9f..eff18d13 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSetUrOwn.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSetUrOwn.java @@ -18,17 +18,11 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; -import kr.syeyoung.dungeonsguide.features.impl.party.api.ClassSpecificData; import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.XPUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import java.awt.*; -import java.util.Arrays; public class DataRendererSetUrOwn implements DataRenderer { @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java index 067226e5..12867cd6 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java @@ -18,9 +18,6 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; -import kr.syeyoung.dungeonsguide.features.impl.party.api.ClassSpecificData; -import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonClass; import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; import kr.syeyoung.dungeonsguide.features.impl.party.api.Skill; import kr.syeyoung.dungeonsguide.utils.RenderUtils; 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 9ffe0217..c1730ed7 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 @@ -20,15 +20,13 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; import com.google.common.base.Supplier; import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; import io.github.moulberry.hychat.HyChat; import io.github.moulberry.hychat.chat.ChatManager; import io.github.moulberry.hychat.gui.GuiChatBox; import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.PanelDefaultParameterConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.PanelDefaultParameterConfig; import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; import kr.syeyoung.dungeonsguide.features.FeatureParameter; @@ -38,35 +36,25 @@ import kr.syeyoung.dungeonsguide.features.impl.party.api.*; import kr.syeyoung.dungeonsguide.features.listener.ChatListener; import kr.syeyoung.dungeonsguide.features.listener.GuiClickListener; import kr.syeyoung.dungeonsguide.features.listener.GuiPostRenderListener; -import kr.syeyoung.dungeonsguide.features.text.PanelTextParameterConfig; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.party.PartyManager; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.XPUtils; import lombok.Getter; import lombok.Setter; import lombok.SneakyThrows; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.client.gui.*; import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.client.resources.SkinManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.HoverEvent; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.scoreboard.Scoreboard; import net.minecraft.scoreboard.Team; import net.minecraft.util.*; import net.minecraft.world.World; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java index 35606731..b62a168f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java @@ -39,7 +39,7 @@ import java.util.List; public class FeatureActions extends TextHUDFeature { public FeatureActions() { - super("Secret", "Action Viewer", "View List of actions that needs to be taken", "secret.actionview", false, 200, getFontRenderer().FONT_HEIGHT * 10); + super("Dungeon Secret.Pathfind Display", "Action Viewer", "View List of actions that needs to be taken", "secret.actionview", false, 200, getFontRenderer().FONT_HEIGHT * 10); getStyles().add(new TextStyle("pathfinding", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); getStyles().add(new TextStyle("mechanic", new AColor(0x55, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java index f9016b15..67f0be5f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java @@ -24,7 +24,7 @@ import kr.syeyoung.dungeonsguide.features.SimpleFeature; public class FeatureFreezePathfind extends SimpleFeature { public FeatureFreezePathfind() { - super("Secret", "Freeze Pathfind", "Freeze Pathfind, meaning the pathfind lines won't change when you move", "secret.freezepathfind", false); + super("Dungeon Secret.Pathfind Display", "Freeze Pathfind", "Freeze Pathfind, meaning the pathfind lines won't change when you move", "secret.freezepathfind", false); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); 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 index f2cac046..224ace06 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java @@ -21,8 +21,8 @@ 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.GuiConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; +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; @@ -56,9 +56,8 @@ import java.util.Map; import java.util.UUID; public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderListener, GuiClickListener, WorldRenderListener { - public FeatureMechanicBrowse() { - super("Secret","Mechanic(Secret) Browser", "Browse and Pathfind secrets and mechanics in the current room", "secret.mechanicbrowse", false, 100, 300); + super("Dungeon Secret.Secret Pathfind","Mechanic(Secret) Browser", "Browse and Pathfind secrets and mechanics in the current room", "secret.mechanicbrowse", false, 100, 300); parameters.put("linecolor2", new FeatureParameter("linecolor2", "Color", "Color of Pathfind line", new AColor(0xFF00FF00, true), "acolor")); parameters.put("linethickness", new FeatureParameter("linethickness", "Thickness", "Thickness of Pathfind line", 1.0f, "float")); parameters.put("refreshrate", new FeatureParameter("refreshrate", "Line Refreshrate", "How many ticks per line refresh?", 10, "integer")); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java index 6559bd61..70c0b2be 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java @@ -18,35 +18,21 @@ package kr.syeyoung.dungeonsguide.features.text; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameter; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MColor; import kr.syeyoung.dungeonsguide.gui.elements.MEditableAColor; import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; -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.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; -import org.w3c.dom.css.Rect; import java.awt.*; -import java.io.IOException; import java.util.*; import java.util.List; @@ -126,7 +112,7 @@ public class PanelTextParameterConfig extends MPanel { Gui.drawRect(4,4,width+6, height+6, 0xFF222222); Gui.drawRect(5,5,width+5, height+5, 0xFF555555); Rectangle clip = new Rectangle(scissor.x + 5, scissor.y + 5, width, height); - clip(new ScaledResolution(Minecraft.getMinecraft()), clip.x, clip.y, clip.width, clip.height); + clip(clip.x, clip.y, clip.width, clip.height); GlStateManager.pushMatrix(); GlStateManager.translate(offsetX + 5, offsetY + 5, 0); @@ -147,7 +133,7 @@ public class PanelTextParameterConfig extends MPanel { } } } - clip(new ScaledResolution(Minecraft.getMinecraft()), scissor.x, scissor.y, scissor.width, scissor.height); + clip(scissor.x, scissor.y, scissor.width, scissor.height); GlStateManager.popMatrix(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java index 9ee1814c..b3488bdd 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java @@ -19,28 +19,20 @@ package kr.syeyoung.dungeonsguide.features.text; import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.PanelDefaultParameterConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.old.PanelDefaultParameterConfig; import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.GuiFeature; import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; import kr.syeyoung.dungeonsguide.gui.elements.MPassiveLabelAndElement; import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; -import java.awt.*; import java.util.*; import java.util.List; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java index feef2848..c5428c14 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java @@ -61,7 +61,7 @@ public class MGui extends GuiScreen { 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(scaledResolution, new Point(0,0), new Rectangle(0,0,Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight), i, j, i, j, partialTicks); + 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(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java index a91cb6c6..0f842b34 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java @@ -23,8 +23,8 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import org.lwjgl.opengl.GL11; @@ -49,6 +49,8 @@ public class MPanel { @Setter protected MPanel parent; + private boolean debug = false; + public void setBackgroundColor(Color c) { if (c == null) return; this.backgroundColor = c; @@ -109,7 +111,7 @@ public class MPanel { @Setter private boolean ignoreBoundOnClip; - public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a lastParentPoint = parentPoint; int relMousex = relMousex0 - getBounds().x; @@ -127,7 +129,8 @@ public class MPanel { lastAbsClip = clip; if (clip.getSize().height * clip.getSize().width == 0) return; - clip(resolution, clip.x, clip.y, clip.width, clip.height); + this.scale = scale; + clip(clip.x, clip.y, clip.width, clip.height); GlStateManager.pushAttrib(); GL11.glEnable(GL11.GL_SCISSOR_TEST); @@ -147,28 +150,30 @@ public class MPanel { render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); GlStateManager.popAttrib(); GlStateManager.popMatrix(); + if (debug && lastAbsClip.contains(absMousex, absMousey)) { + Gui.drawRect(0, 0, getBounds().width, getBounds().height, 0x2200FF00); + GL11.glDisable(GL11.GL_SCISSOR_TEST); +// Gui.drawRect(0, 0, getPreferredSize().width, getPreferredSize().height, 0x220000FF); + } 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(resolution, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); + mPanel.render0(scale, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); GlStateManager.popAttrib(); GlStateManager.popMatrix(); } } - - public static void clip(ScaledResolution resolution, int x, int y, int width, int height) { + protected double scale; + public void clip(int x, int y, int width, int height) { if (width < 0 || height < 0) return; -// int scale = resolution.getScaleFactor(); - int scale = 1; - GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); + GL11.glScissor((int) (x * scale), Minecraft.getMinecraft().displayHeight - (int) ((y + height) * scale), (int)(width* scale), (int) (height * scale)); } protected Rectangle determineClip(Rectangle rect1, Rectangle rect2) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java new file mode 100644 index 00000000..ef10377e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java @@ -0,0 +1,131 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +/** + * Note it is passive. + */ +public class MCollapsable extends MPanel { + @Getter + @Setter + private boolean collapsed = true; + + private MPanel representing; + @Getter + private MList lowerElements; + + @Getter @Setter + private int leftPad = 0, leftPadElements = 13; + + private Runnable onPreferedSizeChange; + + public MCollapsable(MPanel representing, Runnable onPreferedSizeChange) { + this.representing = representing; + super.add(representing); + lowerElements = new MList(); + lowerElements.setGap(0); + super.add(lowerElements); + + this.onPreferedSizeChange = onPreferedSizeChange; + } + + @Override + public Dimension getPreferredSize() { + Dimension rep = representing.getPreferredSize(); + if (collapsed) { + return new Dimension(rep.width+leftPad+10, rep.height); + } else { + Dimension lowerElem = lowerElements.getPreferredSize(); + return new Dimension(Math.max(rep.width+leftPad+10, leftPadElements + lowerElem.width), rep.height+lowerElem.height+lowerElements.getGap()); + } + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + Dimension representingSize =this.representing.getPreferredSize(); + Dimension lowerSize = lowerElements.getPreferredSize(); + + representing.setBounds(new Rectangle(new Point(leftPad+10, 0), new Dimension(bounds.width - (leftPad+10), representingSize.height))); + lowerElements.setBounds(new Rectangle(new Point(leftPadElements, representingSize.height+lowerElements.getGap()), new Dimension(bounds.width - (leftPadElements), lowerSize.height))); + lowerElements.realignChildren(); + } + + @Override + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { + super.render0(scale, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); + + clip(lastAbsClip.x, lastAbsClip.y, lastAbsClip.width, lastAbsClip.height); +// GL11.glEnable(GL11.GL_SCISSOR_TEST); + + + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + if (collapsed) { + GlStateManager.translate(leftPad + 10 - fr.getStringWidth(">"),(bounds.height - fr.FONT_HEIGHT)/2,0); + } else { + GlStateManager.translate(leftPad + fr.FONT_HEIGHT,(representing.getPreferredSize().height - fr.getStringWidth(">"))/2,0); + GlStateManager.rotate(90, 0,0,1); + } + + fr.drawString(">", 0,0, -1); + + GlStateManager.popAttrib(); + GlStateManager.popMatrix(); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + } + + @Override + public void add(MPanel child) { + lowerElements.add(child); + if (onPreferedSizeChange != null) onPreferedSizeChange.run(); + } + + @Override + public void remove(MPanel panel) { + lowerElements.remove(panel); + if (onPreferedSizeChange != null) onPreferedSizeChange.run(); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (relMouseX >= leftPad && relMouseY >= 0 && relMouseX <= leftPad + 10 && relMouseY <= representing.getPreferredSize().height) { + collapsed = !collapsed; + if (onPreferedSizeChange != null) onPreferedSizeChange.run(); + } + } +} 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 f6df0e19..9719f63f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java @@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.gui.elements; import kr.syeyoung.dungeonsguide.gui.MPanel; import lombok.Getter; +import lombok.Setter; import net.minecraft.client.gui.Gui; import java.awt.*; @@ -28,6 +29,9 @@ public class MList extends MPanel { @Getter private int gap = 5; + @Getter @Setter + private boolean drawLine = true; + public void setGap(int gap) { this.gap = gap; realignChildren(); @@ -35,19 +39,35 @@ public class MList extends MPanel { private final int gapLineColor = 0xFFFFFFFF; - protected void realignChildren() { + public void realignChildren() { int y = 0; for (MPanel childComponent : getChildComponents()) { Dimension preferedSize = childComponent.getPreferredSize(); childComponent.setBounds(new Rectangle(0, y, bounds.width, Math.max(10, preferedSize.height))); y += preferedSize.height; - y += gap; + if (gap > 0) + y += gap; } setSize(new Dimension(getSize().width, Math.max(0, y-gap))); } + @Override + public Dimension getPreferredSize() { + int maxW = 0; + int h = 0; + for (MPanel childComponent : getChildComponents()) { + Dimension preferedSize = childComponent.getPreferredSize(); + if (preferedSize.width > maxW) maxW = preferedSize.width; + h += preferedSize.height; + if (gap > 0) h += gap; + } + return new Dimension(maxW, Math.max(0, h-gap)); + } + @Override public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (gap <= 0) return; + if (!drawLine) return; for (int i = 1; i < getChildComponents().size(); i++) { MPanel panel = getChildComponents().get(i); Rectangle bound = panel.getBounds(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java new file mode 100644 index 00000000..64599058 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java @@ -0,0 +1,199 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class MPanelScaledGUI extends MPanel { + @Getter + private double scale = 1.0; + + private double relativeScale; + + public void setScale(double scale) { + this.scale = scale; + for (MPanel childComponent : childComponents) { + childComponent.resize0((int) (getBounds().width/scale), (int) (getBounds().height/scale)); + } + } + + @Override + public void setBounds(Rectangle bounds) { + if (bounds == null) return; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; + + for (MPanel childComponent : childComponents) { + childComponent.resize0((int) (getBounds().width/scale), (int) (getBounds().height/scale)); + } + onBoundsUpdate(); + } + + public Dimension getEffectiveDimension() { + return new Dimension((int)(getBounds().width / scale), (int)(getBounds().height / scale)); + } + + @Override + public void render0(double parentScale, Point parentPoint, Rectangle parentClip, int absMousex0, int absMousey0, int relMousex0, int relMousey0, float partialTicks) { + lastParentPoint = parentPoint; + + GlStateManager.translate(getBounds().x, getBounds().y, 5); + GlStateManager.color(1,1,1,0); + + Rectangle absBound = getBounds().getBounds(); + absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); + + Rectangle clip; + if (isIgnoreBoundOnClip()) clip = parentClip; + else clip = determineClip(parentClip, absBound); + lastAbsClip = clip; + + if (clip.getSize().height * clip.getSize().width == 0) return; + + int absMousex = (int) (absMousex0 / scale), absMousey = (int) (absMousey0 / scale); + int relMousex = (int) ((relMousex0 - getBounds().x) / scale); + int relMousey = (int) ((relMousey0 - getBounds().y) /scale); + + // FROM HERE, IT IS SCALED + + 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)); + + + this.relativeScale = parentScale * this.scale; + 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(); + GlStateManager.enableAlpha(); + 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(scale, newPt,clip,absMousex, absMousey, relMousex, relMousey, partialTicks); + GlStateManager.popAttrib(); + GlStateManager.popMatrix(); + } + } + + @Override + 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)); + } + + @Override + public void resize0(int parentWidth, int parentHeight) { + super.resize0(parentWidth, parentHeight); + } + + + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + boolean noClip = true; + boolean focusedOverall = false; + for (MPanel childComponent : getChildComponents()) { + if (childComponent.mouseClicked0(absMouseX, absMouseY,relMousex, relMousey, mouseButton)) { + noClip = false; + focusedOverall = true; + } + } + + if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { + isFocused = true; + focusedOverall = true; + } else { + isFocused = false; + } + mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); + + return focusedOverall; + } + public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseReleased0(absMouseX, absMouseY, relMousex, relMousey, state); + } + mouseReleased(absMouseX, absMouseY, relMousex, relMousey, state); + } + public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseClickMove0(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); + } + mouseClickMove(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); + } + public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseScrolled0(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); + } + mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPortableColorEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPortableColorEdit.java index 3ee4e516..9bd3b130 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPortableColorEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPortableColorEdit.java @@ -201,7 +201,7 @@ public class MPortableColorEdit extends MPanel { } @Override - public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { int relMousex = relMousex0 - getBounds().x; int relMousey = relMousey0 - getBounds().y; @@ -213,8 +213,8 @@ public class MPortableColorEdit extends MPanel { absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); Rectangle clip = determineClip(parentClip, absBound); lastAbsClip = clip; - - clip(resolution, clip.x, clip.y, clip.width, clip.height); +this.scale =scale; + clip(clip.x, clip.y, clip.width, clip.height); GlStateManager.pushAttrib(); GL11.glDisable(GL11.GL_SCISSOR_TEST); @@ -237,7 +237,7 @@ public class MPortableColorEdit extends MPanel { for (MPanel mPanel : getChildComponents()){ GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); - mPanel.render0(resolution, newPt, new Rectangle(newPt, new Dimension(getBounds().getSize())), absMousex, absMousey, relMousex, relMousey, partialTicks); + mPanel.render0(scale, newPt, new Rectangle(newPt, new Dimension(getBounds().getSize())), absMousex, absMousey, relMousex, relMousey, partialTicks); GlStateManager.popAttrib(); GlStateManager.popMatrix(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java index ecd94b07..215c7c6d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java @@ -37,6 +37,10 @@ public class MScrollBar extends MPanel { @Getter private int current; + @Getter + @Setter + private int width = 10; + public void addToCurrent(int dv) { int current2 = current + dv; @@ -48,7 +52,7 @@ public class MScrollBar extends MPanel { @Override public Dimension getPreferredSize() { - return new Dimension(axis == Axis.X ? -1 : 20, axis == Axis.Y ? -1 : 20); + return new Dimension(axis == Axis.X ? -1 : width, axis == Axis.Y ? -1 : width); } @Getter 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 bdbf51d0..42a3cb91 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java @@ -40,8 +40,6 @@ public class MScrollablePanel extends MPanel { private final int axis; // 1: Y 2: X 3: both. - private Dimension totalContentArea = new Dimension(); - private MPanel viewPort; @Getter private MPanel contentArea; @@ -135,23 +133,28 @@ public class MScrollablePanel extends MPanel { @Override public void setBounds(Rectangle bounds) { super.setBounds(bounds); - boolean hideX = false, hideY = false; - if (bounds.width > contentAreaDim.width && hideScrollBarWhenNotNecessary) hideX = true; - if (bounds.height > contentAreaDim.height && hideScrollBarWhenNotNecessary) hideY = true; + boolean hideX = (axis & 2) == 0, hideY = (axis & 1) == 0; + viewPort.setBounds(new Rectangle(0,0,bounds.width, bounds.height)); + evalulateContentArea(); + if (bounds.width >= contentAreaDim.width && hideScrollBarWhenNotNecessary) hideX = true; + if (bounds.height >= contentAreaDim.height && hideScrollBarWhenNotNecessary) hideY = true; - if (axis == 3 && !(hideX || hideY)) { + if (!(hideX || hideY)) { Dimension preferedX = scrollBarX.getPreferredSize(); Dimension preferedY = scrollBarY.getPreferredSize(); scrollBarY.setBounds(new Rectangle(bounds.width - preferedY.width, 0, preferedY.width, bounds.height - preferedX.height)); scrollBarX.setBounds(new Rectangle(0, bounds.height - preferedX.height, bounds.width - preferedY.width, preferedX.height)); - } else if (axis == 2 || (axis == 3 && hideY)) { + } else if ((hideY && !hideX)) { Dimension preferedX = scrollBarX.getPreferredSize(); scrollBarY.setBounds(new Rectangle(0,0,0,0)); scrollBarX.setBounds(new Rectangle(0, bounds.height - preferedX.height, bounds.width, preferedX.height)); - } else if (axis == 1 || (axis == 3 && hideX)) { + } else if ((hideX && !hideY)) { Dimension preferedY = scrollBarY.getPreferredSize(); scrollBarX.setBounds(new Rectangle(0,0,0,0)); scrollBarY.setBounds(new Rectangle(bounds.width - preferedY.width, 0, preferedY.width, bounds.height)); + } else if (hideX && hideY){ + scrollBarY.setBounds(new Rectangle(0,0,0,0)); + scrollBarX.setBounds(new Rectangle(0,0,0,0)); } viewPort.setBounds(new Rectangle(0,0,bounds.width-scrollBarY.getBounds().width, bounds.height - scrollBarX.getBounds().height)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MSpacer.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MSpacer.java new file mode 100644 index 00000000..11336a7c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MSpacer.java @@ -0,0 +1,36 @@ +/* + * 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 . + */ + +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; + +import java.awt.*; + +public class MSpacer extends MPanel { + + int width, height; + public MSpacer(int x, int y, int width, int height) { + setBounds(new Rectangle(x,y,width,height)); + this.width = width; this.height = height; + } + @Override + public Dimension getPreferredSize() { + return new Dimension(width, height); + } +} 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 a971cc30..6d8b3f51 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java @@ -68,7 +68,7 @@ public class MTextField extends MPanel { Gui.drawRect(1,1,getBounds().width - 1, getBounds().height - 1, Color.black.getRGB()); Minecraft mc = Minecraft.getMinecraft(); - clip(new ScaledResolution(mc), clip.x + 1, clip.y + 1, clip.width - 2, clip.height - 2); + clip(clip.x + 1, clip.y + 1, clip.width - 2, clip.height - 2); FontRenderer fr = mc.fontRendererObj; int y = (getBounds().height - fr.FONT_HEIGHT) / 2; GlStateManager.enableBlend(); 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 561ecb0c..7492f17d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java @@ -50,7 +50,7 @@ public class MTooltip extends MPanel { return super.getTooltipsOpen() - 1; } - public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a int relMousex = relMousex0 - getBounds().x; int relMousey = relMousey0 - getBounds().y; @@ -61,7 +61,8 @@ public class MTooltip extends MPanel { Rectangle clip = getBounds().getBounds(); GlStateManager.pushAttrib(); GL11.glEnable(GL11.GL_SCISSOR_TEST); - clip(resolution, clip.x, clip.y, clip.width, clip.height); + this.scale = scale; + clip(clip.x, clip.y, clip.width, clip.height); GlStateManager.pushAttrib(); GuiScreen.drawRect(0,0, getBounds().width, getBounds().height, backgroundColor.getRGB()); @@ -83,7 +84,7 @@ public class MTooltip extends MPanel { for (MPanel mPanel : getChildComponents()){ GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); - mPanel.render0(resolution, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); + mPanel.render0(scale, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); GlStateManager.popAttrib(); GlStateManager.popMatrix(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java index 24f42fdc..6c866ec9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java @@ -53,12 +53,12 @@ public class RoomDataDisplayPane extends MPanel { int[][] blocks = dungeonRoom.getDungeonRoomInfo().getBlocks(); // draw Axis; Gui.drawRect(0,0,10,10,0x77777777); - clip(sr, clip.x + 10, clip.y, clip.width - 10, 10); + clip(clip.x + 10, clip.y, clip.width - 10, 10); Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); for (int x = 0; x < blocks[0].length; x++) { fr.drawString(x+"", x * 16 +10 + offsetX, 0, 0xFFFFFFFF); } - clip(sr, clip.x, clip.y +10, 10, clip.height-10); + clip(clip.x, clip.y +10, 10, clip.height-10); Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); for (int z = 0; z < blocks.length; z++) { fr.drawString(z+"", 2, z * 16 + 10 + offsetY, 0xFFFFFFFF); @@ -67,7 +67,7 @@ public class RoomDataDisplayPane extends MPanel { int hoverX = (relMousex0 - offsetX - 10) / 16; int hoverY = (relMousey0 - offsetY - 10) / 16; // draw Content - clip(sr, clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10); + clip(clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10); for (int z = 0; z < blocks.length; z++) { for (int x = 0; x < blocks[z].length; x++) { int data = blocks[z][x]; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java index 5290291f..3379098b 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java @@ -18,14 +18,12 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; -import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; 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.ArrayUtils; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -70,12 +68,12 @@ public class RoomMatchDisplayPane extends MPanel { // draw Axis; Gui.drawRect(0,0,10,10,0x77777777); - clip(sr, clip.x + 10, clip.y, clip.width - 10, 10); + clip(clip.x + 10, clip.y, clip.width - 10, 10); Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); for (int x = 0; x < width; x++) { fr.drawString(x+"", x * 16 +10 + offsetX, 0, 0xFFFFFFFF); } - clip(sr, clip.x, clip.y +10, 10, clip.height-10); + clip(clip.x, clip.y +10, 10, clip.height-10); Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); for (int z = 0; z < height; z++) { fr.drawString(z+"", 2, z * 16 + 10 + offsetY, 0xFFFFFFFF); @@ -84,7 +82,7 @@ public class RoomMatchDisplayPane extends MPanel { int hoverX = (relMousex0 - offsetX - 10) / 16; int hoverY = (relMousey0 - offsetY - 10) / 16; // draw Content - clip(sr, clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10); + clip(clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10); boolean tooltiped=false; for (int z = 0; z < height; z++) { for (int x = 0; x < width; x++) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index b6c5c22d..e9518d64 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -55,6 +55,53 @@ public class RenderUtils { public static boolean allowScrolling; public static int scrollX = 0; + public static void drawRect(int left, int top, int right, int bottom, AColor color) + { + if (left < right) + { + int i = left; + left = right; + right = i; + } + + if (top < bottom) + { + int j = top; + top = bottom; + bottom = j; + } + + float f3 = (float)(color.getRGB() >> 24 & 255) / 255.0F; + float f = (float)(color.getRGB() >> 16 & 255) / 255.0F; + float f1 = (float)(color.getRGB() >> 8 & 255) / 255.0F; + float f2 = (float)(color.getRGB() & 255) / 255.0F; + if (!color.isChroma() && f3 == 0) return; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + if (!color.isChroma()) { + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + worldrenderer.pos(left, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, top, 0.0D).endVertex(); + worldrenderer.pos(left, top, 0.0D).endVertex(); + } else { + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + GlStateManager.shadeModel(GL11.GL_SMOOTH); + color(worldrenderer.pos(left, bottom, 0.0D), getColorAt(left, bottom, color)).endVertex(); + color(worldrenderer.pos(right, bottom, 0.0D), getColorAt(right, bottom, color)).endVertex(); + color(worldrenderer.pos(right, top, 0.0D), getColorAt(right, top, color)).endVertex(); + color(worldrenderer.pos(left, top, 0.0D), getColorAt(left, top, color)).endVertex(); + } + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawRoundedRectangle(int x, int y, int width, int height, int radius, double delta, int color) { GlStateManager.pushMatrix(); GlStateManager.translate(width/2.0+x, height/2.0+y, 0); -- cgit