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') 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)) -