diff options
author | syeyoung <cyoung06@naver.com> | 2021-10-04 15:30:39 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2021-10-04 15:30:39 +0900 |
commit | a971611398de71a0d46ae093fb4e78af4acc7604 (patch) | |
tree | a197ee848c666c84281fa91f6a63e4c49bc38a37 /src/main/java/kr | |
parent | 1b8e3e9eb53c55bf8cd97f3c8fa0ac804297477e (diff) | |
download | Skyblock-Dungeons-Guide-a971611398de71a0d46ae093fb4e78af4acc7604.tar.gz Skyblock-Dungeons-Guide-a971611398de71a0d46ae093fb4e78af4acc7604.tar.bz2 Skyblock-Dungeons-Guide-a971611398de71a0d46ae093fb4e78af4acc7604.zip |
- Choose rooms in fairysoul alert
Diffstat (limited to 'src/main/java/kr')
2 files changed, 144 insertions, 3 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java index fd659596..e336ae21 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java @@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.dungeon.roomfinder; import com.google.common.io.Files; import kr.syeyoung.dungeonsguide.Main; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import lombok.Getter; import net.minecraft.client.Minecraft; import org.apache.commons.io.IOUtils; @@ -36,6 +37,7 @@ import java.security.NoSuchAlgorithmException; import java.util.*; public class DungeonRoomInfoRegistry { + @Getter private static final List<DungeonRoomInfo> registered = new ArrayList<DungeonRoomInfo>(); private static final Map<Short, List<DungeonRoomInfo>> shapeMap = new HashMap<Short, List<DungeonRoomInfo>>(); private static final Map<UUID, DungeonRoomInfo> uuidMap = new HashMap<UUID, DungeonRoomInfo>(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureSoulRoomWarning.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureSoulRoomWarning.java index 8ce7282a..0c3ae9e6 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureSoulRoomWarning.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureSoulRoomWarning.java @@ -18,29 +18,49 @@ package kr.syeyoung.dungeonsguide.features.impl.secret; +import com.google.common.base.Supplier; import kr.syeyoung.dungeonsguide.DungeonsGuide; import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; import kr.syeyoung.dungeonsguide.config.types.AColor; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.listener.TickListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.features.text.*; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MPassiveLabelAndElement; +import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton; +import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; +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.*; import java.util.List; +import java.util.function.Predicate; public class FeatureSoulRoomWarning extends TextHUDFeature implements TickListener { public FeatureSoulRoomWarning() { super("Dungeon.Dungeon Information","Secret Soul Alert", "Alert if there is an fairy soul in the room", "secret.fairysoulwarn", true, getFontRenderer().getStringWidth("There is a fairy soul in this room!"), getFontRenderer().FONT_HEIGHT); getStyles().add(new TextStyle("warning", new AColor(0xFF, 0x69,0x17,255), new AColor(0, 0,0,0), false)); + + this.parameters.put("roomuids", new FeatureParameter("roomuids", "Disabled room Names", "Disable for these rooms", new ArrayList<>(), "stringlist")); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); @@ -89,4 +109,123 @@ public class FeatureSoulRoomWarning extends TextHUDFeature implements TickListen lastRoomUID = dungeonRoom.getDungeonRoomInfo().getUuid(); } } + + @Override + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier<MPanel>() { + @Override + public MPanel get() { + + MFeatureEdit featureEdit = new MFeatureEdit(FeatureSoulRoomWarning.this, rootConfigPanel); + featureEdit.addParameterEdit("textStyleNEW", new PanelTextParameterConfig(FeatureSoulRoomWarning.this)); + + StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(FeatureSoulRoomWarning.this.<String>getParameter("alignment").getValue()); + MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name()); + mStringSelectionButton.setOnUpdate(() -> { + FeatureSoulRoomWarning.this.<String>getParameter("alignment").setValue(mStringSelectionButton.getSelected()); + }); + featureEdit.addParameterEdit("alignment", new MParameterEdit(FeatureSoulRoomWarning.this, FeatureSoulRoomWarning.this.<String>getParameter("alignment"), rootConfigPanel, mStringSelectionButton, (a) -> false)); + + for (FeatureParameter parameter: getParameters()) { + if (parameter.getKey().equals("textStylesNEW")) continue; + if (parameter.getKey().equals("alignment")) continue; + if (parameter.getKey().equals("roomuids")) continue; + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureSoulRoomWarning.this, parameter, rootConfigPanel)); + } + featureEdit.addParameterEdit("roomuids", new RoomSelectionPanel(FeatureSoulRoomWarning.this.<List<String>>getParameter("roomuids"), (a) -> { + for (DungeonMechanic value : a.getMechanics().values()) { + if (value instanceof DungeonFairySoul) return true; + } + return false; + }) ); + return featureEdit; + } + }); + return "base." + getKey() ; + } + + public static class RoomSelectionPanel extends MPanel { + FeatureParameter<List<String>> uids; + private List<MPassiveLabelAndElement> passiveLabelAndElements = new ArrayList<>(); + private List<MToggleButton> toggleButtons = new ArrayList<>(); + private MButton addAll, removeAll; + public RoomSelectionPanel(FeatureParameter<List<String>> roomuids, Predicate<DungeonRoomInfo> selectableRooms) { + this.uids = roomuids; + for (DungeonRoomInfo dungeonRoomInfo : DungeonRoomInfoRegistry.getRegistered()) { + if (!selectableRooms.test(dungeonRoomInfo)) continue; + MToggleButton mToggleButton = new MToggleButton(); + mToggleButton.setEnabled(!roomuids.getValue().contains(dungeonRoomInfo.getUuid().toString())); + mToggleButton.setOnToggle(() -> { + if (mToggleButton.isEnabled()) + roomuids.getValue().remove(dungeonRoomInfo.getUuid().toString()); + else + roomuids.getValue().add(dungeonRoomInfo.getUuid().toString()); + }); + toggleButtons.add(mToggleButton); + MPassiveLabelAndElement passiveLabelAndElement = new MPassiveLabelAndElement(dungeonRoomInfo.getName(), mToggleButton); + passiveLabelAndElement.setDivideRatio(0.7); + passiveLabelAndElements.add(passiveLabelAndElement); + } + for (MPassiveLabelAndElement passiveLabelAndElement : passiveLabelAndElements) { + add(passiveLabelAndElement); + } + { + addAll = new MButton(); addAll.setText("Enable All"); + addAll.setOnActionPerformed(() -> { + roomuids.getValue().clear(); + for (MToggleButton toggleButton : toggleButtons) { + toggleButton.setEnabled(true); + } + }); + removeAll = new MButton(); removeAll.setText("Disable All"); + removeAll.setOnActionPerformed(() -> { + for (MToggleButton toggleButton : toggleButtons) { + toggleButton.setEnabled(false); + toggleButton.getOnToggle().run(); + } + }); + add(addAll); add(removeAll); + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(-1, (int) (20 * Math.ceil(passiveLabelAndElements.size() / 3) + 27)); + } + + @Override + public void onBoundsUpdate() { + int xI = 0; + int y = 22; + int w3 = (getBounds().width-20) / 3; + for (MPassiveLabelAndElement passiveLabelAndElement : passiveLabelAndElements) { + passiveLabelAndElement.setBounds(new Rectangle(5 + xI * (w3+5), y, w3, 20)); + xI ++; + if (xI == 3) { + xI = 0; + y += 20; + } + } + + addAll.setBounds(new Rectangle(getBounds().width-150, 2, 70, 14)); + removeAll.setBounds(new Rectangle(getBounds().width-75, 2, 70, 14)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Gui.drawRect(0,0,getBounds().width, getBounds().height,RenderUtils.blendAlpha(0x141414, 0.12f)); + Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); + Gui.drawRect(1,1,getBounds().width-1, 18, RenderUtils.blendAlpha(0x141414, 0.12f)); + + 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("Enable for these rooms", 0,0, 0xFFFFFFFF); + GlStateManager.popMatrix(); + } + } } |