From 9252b51706e057b9b767c57e6d0f5ff8c8b983e3 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Wed, 18 Jan 2023 17:09:39 +0900 Subject: - pacakage move Signed-off-by: syeyoung --- .../mechanicbrowser/FeatureMechanicBrowse.java | 5 - .../secret/mechanicbrowser/WidgetCategory.java | 61 +++++++++++ .../mechanicbrowser/WidgetMechanicBrowser.java | 115 ++++++++++++++++++++ .../impl/secret/mechanicbrowser/WidgetSecret.java | 84 +++++++++++++++ .../impl/secret/mechanicbrowser/WidgetState.java | 53 ++++++++++ .../secret/mechanicbrowser/WidgetStateTooltip.java | 54 ++++++++++ .../secret/mechanicbrowser/v2/WidgetCategory.java | 61 ----------- .../mechanicbrowser/v2/WidgetMechanicBrowser.java | 116 --------------------- .../secret/mechanicbrowser/v2/WidgetSecret.java | 87 ---------------- .../secret/mechanicbrowser/v2/WidgetState.java | 53 ---------- .../mechanicbrowser/v2/WidgetStateTooltip.java | 54 ---------- 11 files changed, 367 insertions(+), 376 deletions(-) create mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetCategory.java create mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetMechanicBrowser.java create mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetSecret.java create mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetState.java create mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetStateTooltip.java delete mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetCategory.java delete mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetMechanicBrowser.java delete mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetSecret.java delete mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetState.java delete mode 100644 mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetStateTooltip.java (limited to 'mod/src/main/java/kr/syeyoung/dungeonsguide') diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java index 91b87969..6874c388 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java @@ -22,7 +22,6 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.mod.config.types.GUIRectangle; import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; @@ -31,7 +30,6 @@ import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DGTickEvent; import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; -import kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser.v2.WidgetMechanicBrowser; import kr.syeyoung.dungeonsguide.mod.gui.MPanel; import kr.syeyoung.dungeonsguide.mod.gui.elements.MFloatSelectionButton; import kr.syeyoung.dungeonsguide.mod.gui.elements.MPassiveLabelAndElement; @@ -48,14 +46,11 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.MathHelper; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; -import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import java.awt.*; -import java.io.IOException; import java.util.List; import java.util.Objects; import java.util.Optional; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetCategory.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetCategory.java new file mode 100644 index 00000000..c1d8d33d --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetCategory.java @@ -0,0 +1,61 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * 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.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; +import net.minecraft.util.ResourceLocation; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; + +public class WidgetCategory extends AnnotatedWidget { + @Bind(variableName = "categoryName") + public final BindableAttribute categoryName = new BindableAttribute<>(String.class); + @Bind(variableName = "visible") + public final BindableAttribute visible = new BindableAttribute<>(String.class, "open"); + @Bind(variableName = "children") + public final BindableAttribute children = new BindableAttribute<>(WidgetList.class); + public WidgetCategory(String s, DungeonRoom dungeonRoom, Map dungeonMechanics, Consumer onSelect) { + super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/category.gui")); + categoryName.setValue(s); + + List widgets = new ArrayList<>(); + for (Map.Entry dungeonMechanic : dungeonMechanics.entrySet()) { + widgets.add(new WidgetSecret(dungeonMechanic.getKey(), dungeonRoom, dungeonMechanic.getValue(), onSelect)); + } + children.setValue(widgets); + } + + @On(functionName = "toggle") + public void toggle() { + if (visible.getValue().equals("open")) + visible.setValue("collapsed"); + else + visible.setValue("open"); + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetMechanicBrowser.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetMechanicBrowser.java new file mode 100644 index 00000000..aafc9402 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetMechanicBrowser.java @@ -0,0 +1,115 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * 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.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRoute; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.util.ResourceLocation; + +import java.util.*; + +public class WidgetMechanicBrowser extends AnnotatedWidget { + @Bind(variableName = "current") + public final BindableAttribute current = new BindableAttribute<>(String.class); + @Bind(variableName = "children") + public final BindableAttribute children = new BindableAttribute<>(WidgetList.class); + @Bind(variableName = "scale") + public final BindableAttribute scale = new BindableAttribute<>(Double.class); + @Bind(variableName = "color") + public final BindableAttribute color = new BindableAttribute<>(Integer.class); + + + @Setter @Getter + private String selectedId; + + private static final List order = Arrays.asList( + "Fairy Soul", "Secrets", "Crypts", "NPC", "Journals", "Gates", "ETC", "Dummy" + ); + private String map(Class t) { + if (t == DungeonFairySoul.class) return "Fairy Soul"; + if (t == DungeonSecret.class) return "Secrets"; + if (t == DungeonTomb.class) return "Crypts"; + if (t == DungeonNPC.class) return "NPC"; + if (t == DungeonJournal.class) return "Journals"; + if (t == DungeonRoomDoor.class) return "Gates"; + if (t == DungeonDummy.class) return "Dummy"; + return "ETC"; + } + + private DungeonRoom dungeonRoom; + public WidgetMechanicBrowser(DungeonRoom dungeonRoom) { + super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/browser.gui")); + scale.setValue(FeatureRegistry.SECRET_BROWSE.getScale()); + GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); + this.dungeonRoom =dungeonRoom; + if (grp.getPath("MECH-BROWSER") == null) { + current.setValue("Nothing"); + color.setValue(0xFFAA0000); + } else { + ActionRoute route = grp.getPath("MECH-BROWSER"); + current.setValue(route.getMechanic()+" -> "+route.getState()); + color.setValue(0xFFFFFF00); + } + Map> map = new HashMap<>(); + for (Map.Entry stringDungeonMechanicEntry : dungeonRoom.getMechanics().entrySet()) { + String name = map(stringDungeonMechanicEntry.getValue().getClass()); + if (!map.containsKey(name)) + map.put(name, new HashMap<>()); + map.get(name).put(stringDungeonMechanicEntry.getKey(), stringDungeonMechanicEntry.getValue()); + } + + List widgets = new ArrayList<>(); + for (String s : order) { + if (!FeatureRegistry.DEBUG.isEnabled() && s.equals("Dummy")) continue; + if (map.containsKey(s)) + widgets.add(new WidgetCategory(s, dungeonRoom, map.get(s), this::setSelectedId)); + } + children.setValue(widgets); + } + + public void update() { + GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); + if (grp.getPath("MECH-BROWSER") == null) { + current.setValue("Nothing"); + color.setValue(0xFFAA0000); + } else { + ActionRoute route = grp.getPath("MECH-BROWSER"); + current.setValue(route.getMechanic()+" -> "+route.getState()); + color.setValue(0xFFFFFF00); + } + } + + @On(functionName = "cancel") + public void cancel() { + GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); + grp.cancel("MECH-BROWSER"); + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetSecret.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetSecret.java new file mode 100644 index 00000000..6e742703 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetSecret.java @@ -0,0 +1,84 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * 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.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.LocationedPopup; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr; +import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; +import net.minecraft.client.Minecraft; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; + +import java.util.function.Consumer; + +public class WidgetSecret extends AnnotatedWidget { + + @Bind(variableName = "secretName") + public final BindableAttribute secretName = new BindableAttribute<>(String.class); + + private String id; + private DungeonRoom room; + private DungeonMechanic mechanic; + private Consumer onSelect; + public WidgetSecret(String name, DungeonRoom room, DungeonMechanic dungeonMechanic, Consumer selectedId) { + super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/secret.gui")); + secretName.setValue(name+" §7("+ dungeonMechanic.getCurrentState(room) +", "+ + (dungeonMechanic.getRepresentingPoint(room) != null ? + String.format("%.1f", MathHelper.sqrt_double(dungeonMechanic.getRepresentingPoint(room).getBlockPos(room).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)"); + this.id = name; + this.mechanic = dungeonMechanic; + this.room = room; + this.onSelect = selectedId; + } + + private LocationedPopup popup; + @On(functionName = "toggleStates") + public void openStates() { + Rect abs = getDomElement().getAbsBounds(); + double x = abs.getX() + abs.getWidth(); + double y = abs.getY(); + + if (x + 120 > Minecraft.getMinecraft().displayWidth) + x = abs.getX() - 120; + + + onSelect.accept(id); + + PopupMgr popupMgr = PopupMgr.getPopupMgr(getDomElement()); + popupMgr.openPopup(popup = new LocationedPopup(x, y, new WidgetStateTooltip(room, mechanic, id)), (val) -> { + if (val == null) + onSelect.accept(null); + popup = null; + }); + } + + @Override + public void onUnmount() { + PopupMgr popupMgr = PopupMgr.getPopupMgr(getDomElement()); + if (popup != null) + popupMgr.closePopup(popup, "a"); + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetState.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetState.java new file mode 100644 index 00000000..299d673a --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetState.java @@ -0,0 +1,53 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * 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.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; +import net.minecraft.util.ResourceLocation; + +public class WidgetState extends AnnotatedWidget { + + @Bind(variableName = "state") + public final BindableAttribute state = new BindableAttribute<>(String.class); + + private DungeonRoom dungeonRoom; + private String mechanic; + private String s; + + public WidgetState(DungeonRoom dungeonRoom, String mechanic, String s) { + super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/state.gui")); + state.setValue(s); + this.dungeonRoom = dungeonRoom; + this.mechanic = mechanic; + this.s = s; + } + + @On(functionName = "navigate") + public void navigate() { + if (dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor) + ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).pathfind("MECH-BROWSER", mechanic, s, FeatureRegistry.SECRET_LINE_PROPERTIES_SECRET_BROWSER.getRouteProperties()); + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetStateTooltip.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetStateTooltip.java new file mode 100644 index 00000000..3c39c09f --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetStateTooltip.java @@ -0,0 +1,54 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * 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.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; +import net.minecraft.util.ResourceLocation; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class WidgetStateTooltip extends AnnotatedWidget { + + @Bind(variableName = "children") + public final BindableAttribute children = new BindableAttribute(WidgetList.class); + @Bind(variableName = "scale") + public final BindableAttribute scale = new BindableAttribute<>(Double.class); + private DungeonMechanic mechanic; + public WidgetStateTooltip(DungeonRoom dungeonRoom, DungeonMechanic mechanic, String mechanicId) { + super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/tooltip.gui")); + scale.setValue(FeatureRegistry.SECRET_BROWSE.getScale()); + this.mechanic = mechanic; + + Set state = mechanic.getPossibleStates(dungeonRoom); + List widgetList = new ArrayList<>(); + for (String s : state) { + widgetList.add(new WidgetState(dungeonRoom, mechanicId, s)); + } + children.setValue(widgetList); + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetCategory.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetCategory.java deleted file mode 100644 index f87a774d..00000000 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetCategory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2023 cyoung06 (syeyoung) - * - * 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.mod.features.impl.secret.mechanicbrowser.v2; - -import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; -import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; -import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; -import net.minecraft.util.ResourceLocation; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -public class WidgetCategory extends AnnotatedWidget { - @Bind(variableName = "categoryName") - public final BindableAttribute categoryName = new BindableAttribute<>(String.class); - @Bind(variableName = "visible") - public final BindableAttribute visible = new BindableAttribute<>(String.class, "open"); - @Bind(variableName = "children") - public final BindableAttribute children = new BindableAttribute<>(WidgetList.class); - public WidgetCategory(String s, DungeonRoom dungeonRoom, Map dungeonMechanics, Consumer onSelect) { - super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/category.gui")); - categoryName.setValue(s); - - List widgets = new ArrayList<>(); - for (Map.Entry dungeonMechanic : dungeonMechanics.entrySet()) { - widgets.add(new WidgetSecret(dungeonMechanic.getKey(), dungeonRoom, dungeonMechanic.getValue(), onSelect)); - } - children.setValue(widgets); - } - - @On(functionName = "toggle") - public void toggle() { - if (visible.getValue().equals("open")) - visible.setValue("collapsed"); - else - visible.setValue("open"); - } -} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetMechanicBrowser.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetMechanicBrowser.java deleted file mode 100644 index 06990fad..00000000 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetMechanicBrowser.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2023 cyoung06 (syeyoung) - * - * 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.mod.features.impl.secret.mechanicbrowser.v2; - -import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; -import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; -import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; -import kr.syeyoung.dungeonsguide.mod.guiv2.elements.Column; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.util.ResourceLocation; - -import java.util.*; - -public class WidgetMechanicBrowser extends AnnotatedWidget { - @Bind(variableName = "current") - public final BindableAttribute current = new BindableAttribute<>(String.class); - @Bind(variableName = "children") - public final BindableAttribute children = new BindableAttribute<>(WidgetList.class); - @Bind(variableName = "scale") - public final BindableAttribute scale = new BindableAttribute<>(Double.class); - @Bind(variableName = "color") - public final BindableAttribute color = new BindableAttribute<>(Integer.class); - - - @Setter @Getter - private String selectedId; - - private static final List order = Arrays.asList( - "Fairy Soul", "Secrets", "Crypts", "NPC", "Journals", "Gates", "ETC", "Dummy" - ); - private String map(Class t) { - if (t == DungeonFairySoul.class) return "Fairy Soul"; - if (t == DungeonSecret.class) return "Secrets"; - if (t == DungeonTomb.class) return "Crypts"; - if (t == DungeonNPC.class) return "NPC"; - if (t == DungeonJournal.class) return "Journals"; - if (t == DungeonRoomDoor.class) return "Gates"; - if (t == DungeonDummy.class) return "Dummy"; - return "ETC"; - } - - private DungeonRoom dungeonRoom; - public WidgetMechanicBrowser(DungeonRoom dungeonRoom) { - super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/browser.gui")); - scale.setValue(FeatureRegistry.SECRET_BROWSE.getScale()); - GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - this.dungeonRoom =dungeonRoom; - if (grp.getPath("MECH-BROWSER") == null) { - current.setValue("Nothing"); - color.setValue(0xFFAA0000); - } else { - ActionRoute route = grp.getPath("MECH-BROWSER"); - current.setValue(route.getMechanic()+" -> "+route.getState()); - color.setValue(0xFFFFFF00); - } - Map> map = new HashMap<>(); - for (Map.Entry stringDungeonMechanicEntry : dungeonRoom.getMechanics().entrySet()) { - String name = map(stringDungeonMechanicEntry.getValue().getClass()); - if (!map.containsKey(name)) - map.put(name, new HashMap<>()); - map.get(name).put(stringDungeonMechanicEntry.getKey(), stringDungeonMechanicEntry.getValue()); - } - - List widgets = new ArrayList<>(); - for (String s : order) { - if (!FeatureRegistry.DEBUG.isEnabled() && s.equals("Dummy")) continue; - if (map.containsKey(s)) - widgets.add(new WidgetCategory(s, dungeonRoom, map.get(s), this::setSelectedId)); - } - children.setValue(widgets); - } - - public void update() { - GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - if (grp.getPath("MECH-BROWSER") == null) { - current.setValue("Nothing"); - color.setValue(0xFFAA0000); - } else { - ActionRoute route = grp.getPath("MECH-BROWSER"); - current.setValue(route.getMechanic()+" -> "+route.getState()); - color.setValue(0xFFFFFF00); - } - } - - @On(functionName = "cancel") - public void cancel() { - GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - grp.cancel("MECH-BROWSER"); - } -} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetSecret.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetSecret.java deleted file mode 100644 index e0334b4c..00000000 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetSecret.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2023 cyoung06 (syeyoung) - * - * 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.mod.features.impl.secret.mechanicbrowser.v2; - -import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; -import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; -import kr.syeyoung.dungeonsguide.mod.guiv2.elements.LocationedPopup; -import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr; -import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; -import kr.syeyoung.dungeonsguide.mod.overlay.OverlayManager; -import kr.syeyoung.dungeonsguide.mod.overlay.OverlayType; -import kr.syeyoung.dungeonsguide.mod.overlay.OverlayWidget; -import net.minecraft.client.Minecraft; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; - -import java.util.function.Consumer; - -public class WidgetSecret extends AnnotatedWidget { - - @Bind(variableName = "secretName") - public final BindableAttribute secretName = new BindableAttribute<>(String.class); - - private String id; - private DungeonRoom room; - private DungeonMechanic mechanic; - private Consumer onSelect; - public WidgetSecret(String name, DungeonRoom room, DungeonMechanic dungeonMechanic, Consumer selectedId) { - super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/secret.gui")); - secretName.setValue(name+" §7("+ dungeonMechanic.getCurrentState(room) +", "+ - (dungeonMechanic.getRepresentingPoint(room) != null ? - String.format("%.1f", MathHelper.sqrt_double(dungeonMechanic.getRepresentingPoint(room).getBlockPos(room).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)"); - this.id = name; - this.mechanic = dungeonMechanic; - this.room = room; - this.onSelect = selectedId; - } - - private LocationedPopup popup; - @On(functionName = "toggleStates") - public void openStates() { - Rect abs = getDomElement().getAbsBounds(); - double x = abs.getX() + abs.getWidth(); - double y = abs.getY(); - - if (x + 120 > Minecraft.getMinecraft().displayWidth) - x = abs.getX() - 120; - - - onSelect.accept(id); - - PopupMgr popupMgr = PopupMgr.getPopupMgr(getDomElement()); - popupMgr.openPopup(popup = new LocationedPopup(x, y, new WidgetStateTooltip(room, mechanic, id)), (val) -> { - if (val == null) - onSelect.accept(null); - popup = null; - }); - } - - @Override - public void onUnmount() { - PopupMgr popupMgr = PopupMgr.getPopupMgr(getDomElement()); - if (popup != null) - popupMgr.closePopup(popup, "a"); - } -} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetState.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetState.java deleted file mode 100644 index cf65849c..00000000 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetState.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2023 cyoung06 (syeyoung) - * - * 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.mod.features.impl.secret.mechanicbrowser.v2; - -import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; -import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; -import net.minecraft.util.ResourceLocation; - -public class WidgetState extends AnnotatedWidget { - - @Bind(variableName = "state") - public final BindableAttribute state = new BindableAttribute<>(String.class); - - private DungeonRoom dungeonRoom; - private String mechanic; - private String s; - - public WidgetState(DungeonRoom dungeonRoom, String mechanic, String s) { - super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/state.gui")); - state.setValue(s); - this.dungeonRoom = dungeonRoom; - this.mechanic = mechanic; - this.s = s; - } - - @On(functionName = "navigate") - public void navigate() { - if (dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor) - ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).pathfind("MECH-BROWSER", mechanic, s, FeatureRegistry.SECRET_LINE_PROPERTIES_SECRET_BROWSER.getRouteProperties()); - } -} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetStateTooltip.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetStateTooltip.java deleted file mode 100644 index aa0eb05b..00000000 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/v2/WidgetStateTooltip.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2023 cyoung06 (syeyoung) - * - * 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.mod.features.impl.secret.mechanicbrowser.v2; - -import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; -import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; -import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; -import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; -import net.minecraft.util.ResourceLocation; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -public class WidgetStateTooltip extends AnnotatedWidget { - - @Bind(variableName = "children") - public final BindableAttribute children = new BindableAttribute(WidgetList.class); - @Bind(variableName = "scale") - public final BindableAttribute scale = new BindableAttribute<>(Double.class); - private DungeonMechanic mechanic; - public WidgetStateTooltip(DungeonRoom dungeonRoom, DungeonMechanic mechanic, String mechanicId) { - super(new ResourceLocation("dungeonsguide:gui/features/mechanicBrowser/tooltip.gui")); - scale.setValue(FeatureRegistry.SECRET_BROWSE.getScale()); - this.mechanic = mechanic; - - Set state = mechanic.getPossibleStates(dungeonRoom); - List widgetList = new ArrayList<>(); - for (String s : state) { - widgetList.add(new WidgetState(dungeonRoom, mechanicId, s)); - } - children.setValue(widgetList); - } -} -- cgit