diff options
author | syeyoung <cyong06@naver.com> | 2021-01-01 14:24:06 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-01 14:24:06 +0900 |
commit | be44a7665e4982934998020d3bb930be25a50c25 (patch) | |
tree | 62a8ba38bf5dccf98eec1876f1d3267bf161bca0 /src | |
parent | a09e7553a93a177df7a6a3c7db5a1383b08a2416 (diff) | |
download | Skyblock-Dungeons-Guide-be44a7665e4982934998020d3bb930be25a50c25.tar.gz Skyblock-Dungeons-Guide-be44a7665e4982934998020d3bb930be25a50c25.tar.bz2 Skyblock-Dungeons-Guide-be44a7665e4982934998020d3bb930be25a50c25.zip |
gui glitch fix and such
Diffstat (limited to 'src')
19 files changed, 226 insertions, 130 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java index fefc3723..93f0745a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java @@ -60,6 +60,7 @@ public class CommandDungeonsGuide extends CommandBase { sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cAn error has occurred while loading roomdata")); } 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")); sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg saverooms §7-§f Saves usergenerated dungeon roomdata.")); sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg loadrooms §7-§f Reloads dungeon roomdata.")); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java index 908d8ca2..5652a2e5 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java @@ -3,11 +3,8 @@ package kr.syeyoung.dungeonsguide.config; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.google.gson.stream.JsonWriter; import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; import java.io.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java index f723646c..2296f8a6 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java @@ -2,22 +2,15 @@ package kr.syeyoung.dungeonsguide.config; import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; import kr.syeyoung.dungeonsguide.roomedit.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiScreen; 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 net.minecraftforge.common.config.ConfigCategory; -import net.minecraftforge.common.config.Property; import java.awt.*; import java.io.IOException; @@ -96,10 +89,11 @@ public class FeatureEditPane extends MPanel { 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); - if (within instanceof MFeature) { AbstractFeature feature = ((MFeature) within).getFeature(); + GlStateManager.pushAttrib(); drawHoveringText(new ArrayList<String>(Arrays.asList(feature.getDescription().split("\n"))), relMousex0, relMousey0, Minecraft.getMinecraft().fontRendererObj); + GlStateManager.popAttrib(); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java index ef7d0a12..5b408181 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java @@ -8,11 +8,13 @@ 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 java.awt.*; import java.io.IOException; +import java.nio.FloatBuffer; import java.util.List; import java.util.Map; @@ -39,16 +41,15 @@ public class GuiConfig extends GuiScreen { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); mainPanel.setBounds(new Rectangle(Math.min((scaledResolution.getScaledWidth() - 500) / 2, scaledResolution.getScaledWidth()), Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),500,300)); } + FloatBuffer floatBuffer = BufferUtils.createFloatBuffer(16); @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GL11.glPushMatrix(); - GlStateManager.pushAttrib(); - GlStateManager.color(0,0,0,0); + GlStateManager.color(1,1,1,1); + GL11.glDisable(GL11.GL_DEPTH_TEST); mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks); - GlStateManager.popAttrib(); GL11.glPopMatrix(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java index f151b77f..25436572 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java @@ -34,17 +34,17 @@ public class MFeature extends MPanel { this.add(this.label = new MLabel()); this.label.setText(abstractFeature.getName()); - if (abstractFeature instanceof GuiFeature) { - MButton button = new MButton(); - button.setText("GUI"); - button.setOnActionPerformed(new Runnable() { + { + final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList<String>(Arrays.asList(new String[] {"on", "off"})), abstractFeature.isEnabled() ? "on" : "off"); + mStringSelectionButton.setOnUpdate(new Runnable() { @Override public void run() { - Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig()); + String selected = mStringSelectionButton.getSelected(); + feature.setEnabled("on".equals(selected)); } }); - addons.add(button); - add(button); + addons.add(mStringSelectionButton); + add(mStringSelectionButton); } if (!abstractFeature.getParameters().isEmpty()) { MButton button = new MButton(); @@ -52,17 +52,17 @@ public class MFeature extends MPanel { addons.add(button); add(button); } - { - final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList<String>(Arrays.asList(new String[] {"on", "off"})), abstractFeature.isEnabled() ? "on" : "off"); - mStringSelectionButton.setOnUpdate(new Runnable() { + if (abstractFeature instanceof GuiFeature) { + MButton button = new MButton(); + button.setText("GUI"); + button.setOnActionPerformed(new Runnable() { @Override public void run() { - String selected = mStringSelectionButton.getSelected(); - feature.setEnabled("on".equals(selected)); + Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig()); } }); - addons.add(mStringSelectionButton); - add(mStringSelectionButton); + addons.add(button); + add(button); } } @@ -80,10 +80,10 @@ public class MFeature extends MPanel { @Override public void onBoundsUpdate() { - int x = getBounds().width - 70; + int x = getBounds().width - 50; for (MPanel panel : addons) { - panel.setBounds(new Rectangle(x, 0, 70, getBounds().height)); - x -= 70; + panel.setBounds(new Rectangle(x, 3, 50, getBounds().height - 6)); + x -= 50; } label.setBounds(new Rectangle(0,0,x, getBounds().height)); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java index 75021e66..f7660788 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java @@ -6,7 +6,6 @@ import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.GuiFeature; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MTabbedPane; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; @@ -16,8 +15,6 @@ import org.lwjgl.opengl.GL11; import java.awt.*; import java.io.IOException; -import java.util.List; -import java.util.Map; public class GuiGuiLocationConfig extends GuiScreen { @@ -25,15 +22,17 @@ public class GuiGuiLocationConfig extends GuiScreen { public GuiGuiLocationConfig() { for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { - if (feature instanceof GuiFeature) { + if (feature instanceof GuiFeature && feature.isEnabled()) { mainPanel.add(new PanelDelegate((GuiFeature) feature)); } } + + mainPanel.setBackgroundColor(new Color(0,0,0, 60)); { MButton button = new MButton() { @Override public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(parentWidth-100,parentHeight-30,100,30)); + setBounds(new Rectangle(parentWidth-50,parentHeight-20,50,20)); } }; button.setText("back"); @@ -59,10 +58,10 @@ public class GuiGuiLocationConfig extends GuiScreen { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); GL11.glPushMatrix(); - GlStateManager.pushAttrib(); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GlStateManager.color(0,0,0,0); mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks); - GlStateManager.popAttrib(); + GL11.glPopAttrib(); GL11.glPopMatrix(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java index fd8b3f25..2e6ca8be 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java @@ -3,6 +3,7 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; import kr.syeyoung.dungeonsguide.features.GuiFeature; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import net.minecraft.client.gui.Gui; +import org.lwjgl.opengl.GL11; import org.w3c.dom.css.Rect; import java.awt.*; @@ -20,28 +21,30 @@ public class PanelDelegate extends MPanel { @Override public void render(int absMousex, int absMousey, int relMouseX, int relMouseY, float partialTicks, Rectangle scissor) { + GL11.glPushMatrix(); guiFeature.drawDemo(partialTicks); + GL11.glPopMatrix(); - Gui.drawRect(0,0, 3, 3, 0x55777777); - Gui.drawRect(0, getBounds().height - 3, 3, 3, 0x55777777); - Gui.drawRect(getBounds().width - 3,0, 3, 3, 0x55777777); - Gui.drawRect(getBounds().width - 3,getBounds().height - 3, 3, 3, 0x55777777); + Gui.drawRect(0,0, 3, 3, 0xFFBBBBBB); + Gui.drawRect(0, getBounds().height - 3, 3, getBounds().height, 0xFFBBBBBB); + Gui.drawRect(getBounds().width - 3,0, getBounds().width, 3, 0xFFBBBBBB); + Gui.drawRect(getBounds().width - 3,getBounds().height - 3, getBounds().width, getBounds().height, 0xFFBBBBBB); if (lastAbsClip.contains(absMousex, absMousey)) { if (relMouseX < 3 && relMouseY < 3) { Gui.drawRect(0,0, 3, 3, 0x55FFFFFF); } else if (relMouseX < 3 && relMouseY > getBounds().height - 3) { - Gui.drawRect(0, getBounds().height - 3, 3, 3, 0x55FFFFFF); - } else if (relMouseX > getBounds().width - 3 && relMouseY < getBounds().height - 3) { - Gui.drawRect(getBounds().width - 3,getBounds().height - 3, 3, 3, 0x55FFFFFF); + Gui.drawRect(0, getBounds().height - 3, 3, getBounds().height, 0x55FFFFFF); + } else if (relMouseX > getBounds().width - 3 && relMouseY > getBounds().height - 3) { + Gui.drawRect(getBounds().width - 3,getBounds().height - 3, getBounds().width, getBounds().height, 0x55FFFFFF); } else if (relMouseX > getBounds().width - 3 && relMouseY < 3) { - Gui.drawRect(getBounds().width - 3,0, 3, 3, 0x55FFFFFF); - } else { + Gui.drawRect(getBounds().width - 3,0, getBounds().width, 3, 0x55FFFFFF); + } else if (selectedPart == -2){ Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55FFFFFF); } } } - private int selectedPart = 0; + private int selectedPart = -2; private int lastX = 0; private int lastY = 0; @@ -54,7 +57,7 @@ public class PanelDelegate extends MPanel { selectedPart = 0; } else if (relMouseX < 3 && relMouseY > getBounds().height - 3) { selectedPart = 2; - } else if (relMouseX > getBounds().width - 3 && relMouseY < getBounds().height - 3) { + } else if (relMouseX > getBounds().width - 3 && relMouseY > getBounds().height - 3) { selectedPart = 3; } else if (relMouseX > getBounds().width - 3 && relMouseY < 3) { selectedPart = 1; @@ -67,22 +70,46 @@ public class PanelDelegate extends MPanel { @Override public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { - selectedPart = 0; + if (selectedPart >= -1) { + int minWidth; + int minHeight; + if (guiFeature.isKeepRatio()) { + minHeight = (int) Math.max(10, 10 / guiFeature.getDefaultRatio()); + minWidth = (int) (guiFeature.getDefaultRatio() * minHeight); + } else { + minWidth = 10; + minHeight = 10; + } + Rectangle rectangle = guiFeature.getFeatureRect().getBounds(); + if (rectangle.width < minWidth || rectangle.height < minHeight) { + rectangle.width = minWidth; + rectangle.height= minHeight; + } + + if (rectangle.x < 0) rectangle.x = 0; + if (rectangle.y < 0) rectangle.y = 0; + + guiFeature.setFeatureRect(rectangle); + } + + selectedPart = -2; + + } @Override public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { int dx = absMouseX - lastX; int dy = absMouseY - lastY; - if (selectedPart > 0) { + if (selectedPart >= 0) { boolean revChangeX = (selectedPart & 0x1) == 0; boolean revChangeY = (selectedPart & 0x2) == 0; Rectangle rectangle = guiFeature.getFeatureRect().getBounds(); int prevWidth = rectangle.width; int prevHeight= rectangle.height; - rectangle.width = prevWidth + dx; - rectangle.height = prevHeight + dy; + rectangle.width = prevWidth + (revChangeX ? -1 : 1) * dx; + rectangle.height = prevHeight + (revChangeY ? - 1: 1 ) * dy; if (guiFeature.isKeepRatio()) { double ratio = guiFeature.getDefaultRatio(); @@ -92,22 +119,43 @@ public class PanelDelegate extends MPanel { int width2 = (int) (rectangle.height * ratio); int height2 = rectangle.height; - if (width1 * height1 < width2 * height2) { + if (ratio >= 1) { rectangle.width = width1; rectangle.height = height1; } else { rectangle.width = width2; - rectangle.height= height2; + rectangle.height = height2; } } - if (revChangeX) rectangle.x -= (rectangle.width - prevWidth); + + + if (revChangeX) rectangle.x -= (rectangle.width - prevWidth ); if (revChangeY) rectangle.y -= (rectangle.height - prevHeight); + lastX = absMouseX; + lastY = absMouseY; + + if (rectangle.height < 0) { + rectangle.height = -rectangle.height; + rectangle.y -= rectangle.height; + selectedPart = selectedPart ^ 0x2; + lastY += revChangeY ? 3 : 3; + } + + if (rectangle.width < 0) { + rectangle.width = -rectangle.width; + rectangle.x -= rectangle.width; + selectedPart = selectedPart ^ 0x1; + lastX += revChangeX ? 3 : 3; + } + guiFeature.setFeatureRect(rectangle); } else if (selectedPart == -1){ Rectangle rectangle = guiFeature.getFeatureRect().getBounds(); rectangle.translate(dx, dy); guiFeature.setFeatureRect(rectangle); + lastX = absMouseX; + lastY = absMouseY; } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java index 82bfe3fc..ee6fdfce 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java @@ -18,4 +18,11 @@ public class TypeConverterRegistry { public static <T> TypeConverter<T> getTypeConverter(String type_string, Class<T> t) { return (TypeConverter<T>)typeConverterMap.get(type_string); } + + static { + register(new TCBoolean()); + register(new TCInteger()); + register(new TCRectangle()); + register(new TCString()); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/e.java b/src/main/java/kr/syeyoung/dungeonsguide/e.java index 5af7fb15..4835b114 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/e.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/e.java @@ -5,7 +5,6 @@ import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import kr.syeyoung.dungeonsguide.eventlistener.DungeonListener; import kr.syeyoung.dungeonsguide.eventlistener.FeatureListener; -import kr.syeyoung.dungeonsguide.eventlistener.ItemGuiListener; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.AhUtils; import lombok.Getter; @@ -51,7 +50,6 @@ public class e implements c { skyblockStatus = new SkyblockStatus(); MinecraftForge.EVENT_BUS.register(new DungeonListener()); - MinecraftForge.EVENT_BUS.register(new ItemGuiListener()); CommandDungeonsGuide commandDungeonsGuide; ClientCommandHandler.instance.registerCommand(commandDungeonsGuide = new CommandDungeonsGuide()); MinecraftForge.EVENT_BUS.register(commandDungeonsGuide); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java index cc4246da..31a70285 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java @@ -3,12 +3,15 @@ package kr.syeyoung.dungeonsguide.eventlistener; import kr.syeyoung.dungeonsguide.SkyblockStatus; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.*; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.listener.ChatListener; import kr.syeyoung.dungeonsguide.features.listener.ScreenRenderListener; +import kr.syeyoung.dungeonsguide.features.listener.TooltipListener; import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class FeatureListener { @@ -16,7 +19,7 @@ public class FeatureListener { public void onRender(RenderGameOverlayEvent.Post postRender) { try { if (postRender.type != RenderGameOverlayEvent.ElementType.TEXT) return; - SkyblockStatus skyblockStatus = (SkyblockStatus) e.getDungeonsGuide().getSkyblockStatus(); + SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); if (!skyblockStatus.isOnSkyblock()) return; for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { @@ -33,7 +36,7 @@ public class FeatureListener { @SubscribeEvent public void onRenderWorld(RenderWorldLastEvent postRender) { try { - SkyblockStatus skyblockStatus = (SkyblockStatus) e.getDungeonsGuide().getSkyblockStatus(); + SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); if (!skyblockStatus.isOnSkyblock()) return; for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { @@ -50,7 +53,7 @@ public class FeatureListener { @SubscribeEvent public void onRenderWorld(ClientChatReceivedEvent postRender) { try { - SkyblockStatus skyblockStatus = (SkyblockStatus) e.getDungeonsGuide().getSkyblockStatus(); + SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); if (!skyblockStatus.isOnSkyblock()) return; for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { @@ -62,4 +65,20 @@ public class FeatureListener { t.printStackTrace(); } } + + @SubscribeEvent + public void dungeonTooltip(ItemTooltipEvent event) { + try { + SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + if (!skyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof TooltipListener) { + ((TooltipListener) abstractFeature).onTooltip(event); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java index 2e2105b6..2facddbe 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java @@ -4,6 +4,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import kr.syeyoung.dungeonsguide.config.types.TypeConverter; import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index c92e09a1..d04ed884 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -1,5 +1,8 @@ package kr.syeyoung.dungeonsguide.features; +import kr.syeyoung.dungeonsguide.features.impl.FeatureCooldownCounter; +import kr.syeyoung.dungeonsguide.features.impl.FeatureTooltipDungeonStat; +import kr.syeyoung.dungeonsguide.features.impl.FeatureTooltipPrice; import lombok.Getter; import java.util.ArrayList; @@ -18,7 +21,7 @@ public class FeatureRegistry { return featureByKey.get(key); } - public static AbstractFeature register(AbstractFeature abstractFeature) { + public static <T extends AbstractFeature> T register(T abstractFeature) { featureList.add(abstractFeature); featureByKey.put(abstractFeature.getKey(), abstractFeature); List<AbstractFeature> features = featuresByCategory.get(abstractFeature.getCategory()); @@ -30,23 +33,24 @@ public class FeatureRegistry { return abstractFeature; } - public static final AbstractFeature SOLVER_RIDDLE = register(new SimpleFeature("solver", "Riddle Puzzle (3 weirdo) Solver", "Highlights the correct box after clicking on all 3 weirdos", "solver.riddle")); - public static final AbstractFeature SOLVER_KAHOOT = register(new SimpleFeature("solver", "Trivia Puzzle (Omnicrescent) Solver", "Highlights the correct solution for trivia puzzle", "solver.trivia")); - public static final AbstractFeature SOLVER_BLAZE = register(new SimpleFeature("solver", "Blaze Puzzle Solver", "Highlights the blaze that needs to be killed in an blaze room", "solver.blaze")); - public static final AbstractFeature SOLVER_TICTACTOE = register(new SimpleFeature("solver", "Tictactoe Solver", "Shows the best move that could be taken by player in the tictactoe room", "solver.tictactoe")); - public static final AbstractFeature SOLVER_ICEPATH = register(new SimpleFeature("solver", "Icepath Puzzle Solver (Advanced)", "Calculates solution for icepath puzzle and displays it to user", "solver.icepath")); - public static final AbstractFeature SOLVER_SILVERFISH = register(new SimpleFeature("solver", "Silverfish Puzzle Solver (Advanced)", "Actively calculates solution for silverfish puzzle and displays it to user", "solver.silverfish")); - public static final AbstractFeature SOLVER_WATERPUZZLE = register(new SimpleFeature("solver", "Waterboard Puzzle Solver (Advanced)", "Calculates solution for waterboard puzzle and displays it to user", "solver.waterboard")); - public static final AbstractFeature SOLVER_BOX = register(new SimpleFeature("solver", "Box Puzzle Solver (Advanced)", "Calculates solution for box puzzle room, and displays it to user", "solver.box")); - public static final AbstractFeature SOLVER_CREEPER = register(new SimpleFeature("solver", "Creeper Puzzle Solver", "Draws line between prismarine lamps in creeper room", "solver.creeper")); - public static final AbstractFeature SOLVER_TELEPORT = register(new SimpleFeature("solver", "Teleport Puzzle Solver", "Shows teleport pads you've visited in a teleport maze room", "solver.teleport")); + public static final SimpleFeature SOLVER_RIDDLE = register(new SimpleFeature("solver", "Riddle Puzzle (3 weirdo) Solver", "Highlights the correct box after clicking on all 3 weirdos", "solver.riddle")); + public static final SimpleFeature SOLVER_KAHOOT = register(new SimpleFeature("solver", "Trivia Puzzle (Omnicrescent) Solver", "Highlights the correct solution for trivia puzzle", "solver.trivia")); + public static final SimpleFeature SOLVER_BLAZE = register(new SimpleFeature("solver", "Blaze Puzzle Solver", "Highlights the blaze that needs to be killed in an blaze room", "solver.blaze")); + public static final SimpleFeature SOLVER_TICTACTOE = register(new SimpleFeature("solver", "Tictactoe Solver", "Shows the best move that could be taken by player in the tictactoe room", "solver.tictactoe")); + public static final SimpleFeature SOLVER_ICEPATH = register(new SimpleFeature("solver", "Icepath Puzzle Solver (Advanced)", "Calculates solution for icepath puzzle and displays it to user", "solver.icepath")); + public static final SimpleFeature SOLVER_SILVERFISH = register(new SimpleFeature("solver", "Silverfish Puzzle Solver (Advanced)", "Actively calculates solution for silverfish puzzle and displays it to user", "solver.silverfish")); + public static final SimpleFeature SOLVER_WATERPUZZLE = register(new SimpleFeature("solver", "Waterboard Puzzle Solver (Advanced)", "Calculates solution for waterboard puzzle and displays it to user", "solver.waterboard")); + public static final SimpleFeature SOLVER_BOX = register(new SimpleFeature("solver", "Box Puzzle Solver (Advanced)", "Calculates solution for box puzzle room, and displays it to user", "solver.box")); + public static final SimpleFeature SOLVER_CREEPER = register(new SimpleFeature("solver", "Creeper Puzzle Solver", "Draws line between prismarine lamps in creeper room", "solver.creeper")); + public static final SimpleFeature SOLVER_TELEPORT = register(new SimpleFeature("solver", "Teleport Puzzle Solver", "Shows teleport pads you've visited in a teleport maze room", "solver.teleport")); - public static final AbstractFeature TOOLTIP_DUNGEONSTAT = register(new SimpleFeature("tooltip", "Dungeon Item Stats", "Shows quality of dungeon items (floor, percentage)", "tooltip.dungeonitem")); - public static final AbstractFeature TOOLTIP_PRICE = register(new SimpleFeature("tooltip", "Item Price", "Shows price of items", "tooltip.price")); + public static final FeatureTooltipDungeonStat TOOLTIP_DUNGEONSTAT = register(new FeatureTooltipDungeonStat()); + public static final FeatureTooltipPrice TOOLTIP_PRICE = register(new FeatureTooltipPrice()); - public static final AbstractFeature ADVANCED_ROOMEDIT = register(new SimpleFeature("advanced", "Room Edit", "Allow editing dungeon rooms\n\nWarning: using this feature can break or freeze your Minecraft\nThis is only for advanced users only", "advanced.roomedit", false)); + public static final SimpleFeature ADVANCED_ROOMEDIT = register(new SimpleFeature("advanced", "Room Edit", "Allow editing dungeon rooms\n\nWarning: using this feature can break or freeze your Minecraft\nThis is only for advanced users only", "advanced.roomedit", false)); - public static final AbstractFeature DEBUG = register(new SimpleFeature("hidden", "Debug", "Toggles debug mode", "debug", false)); + public static final SimpleFeature DEBUG = register(new SimpleFeature("hidden", "Debug", "Toggles debug mode", "debug", false)); + public static final FeatureCooldownCounter QOL_COOLDOWN = (FeatureCooldownCounter) register(new FeatureCooldownCounter()); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java index d47b6c34..98f8af15 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java @@ -37,14 +37,13 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender @Override public void drawScreen(float partialTicks) { if (!isEnabled()) return; - + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); clip(new ScaledResolution(Minecraft.getMinecraft()), featureRect.x, featureRect.y, featureRect.width, featureRect.height); - GL11.glPushAttrib(GL11.GL_SCISSOR_BIT); GL11.glEnable(GL11.GL_SCISSOR_TEST); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); +// GL11.glEnable(GL11.GL_BLEND); +// OpenGlHelper.glBlendFunc(770, 771, 1, 0); +// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPushMatrix(); GL11.glTranslated(featureRect.x, featureRect.y, 0); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java index e5e0b1b6..dc2b7dd8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureCooldownCounter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java @@ -1,11 +1,12 @@ -package kr.syeyoung.dungeonsguide.features; +package kr.syeyoung.dungeonsguide.features.impl; +import kr.syeyoung.dungeonsguide.features.GuiFeature; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import org.lwjgl.opengl.GL11; public class FeatureCooldownCounter extends GuiFeature { - protected FeatureCooldownCounter() { + public FeatureCooldownCounter() { super("QoL", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, 100, 50); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java new file mode 100644 index 00000000..250d230d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java @@ -0,0 +1,35 @@ +package kr.syeyoung.dungeonsguide.features.impl; + +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.TooltipListener; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +public class FeatureTooltipDungeonStat extends SimpleFeature implements TooltipListener { + public FeatureTooltipDungeonStat() { + super("tooltip", "Dungeon Item Stats", "Shows quality of dungeon items (floor, percentage)", "tooltip.dungeonitem"); + } + + @Override + public void onTooltip(ItemTooltipEvent event) { + if (!isEnabled()) return; + + ItemStack hoveredItem = event.itemStack; + NBTTagCompound compound = hoveredItem.getTagCompound(); + if (compound == null) + return; + if (!compound.hasKey("ExtraAttributes")) + return; + NBTTagCompound nbtTagCompound = compound.getCompoundTag("ExtraAttributes"); + + int floor = nbtTagCompound.getInteger("item_tier"); + int percentage = nbtTagCompound.getInteger("baseStatBoostPercentage"); + + if (nbtTagCompound.hasKey("item_tier")) + event.toolTip.add("§7Obtained in: §c"+(floor == 0 ? "Entrance" : "Floor "+floor)); + if (nbtTagCompound.hasKey("baseStatBoostPercentage")) + event.toolTip.add("§7Stat Percentage: §"+(percentage == 50 ? "6§l":"c")+(percentage * 2)+"%"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/ItemGuiListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java index 561ba81c..b54fa682 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/ItemGuiListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java @@ -1,43 +1,26 @@ -package kr.syeyoung.dungeonsguide.eventlistener; +package kr.syeyoung.dungeonsguide.features.impl; -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.TooltipListener; import kr.syeyoung.dungeonsguide.utils.AhUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.util.*; +import java.util.Comparator; +import java.util.Set; +import java.util.TreeSet; -public class ItemGuiListener { - @SubscribeEvent - public void dungeonTooltip(ItemTooltipEvent event) { - if (!e.getDungeonsGuide().getSkyblockStatus().isOnSkyblock()) return; - if (!FeatureRegistry.TOOLTIP_DUNGEONSTAT.isEnabled()) return; - - ItemStack hoveredItem = event.itemStack; - NBTTagCompound compound = hoveredItem.getTagCompound(); - if (compound == null) - return; - if (!compound.hasKey("ExtraAttributes")) - return; - NBTTagCompound nbtTagCompound = compound.getCompoundTag("ExtraAttributes"); - - int floor = nbtTagCompound.getInteger("item_tier"); - int percentage = nbtTagCompound.getInteger("baseStatBoostPercentage"); - - if (nbtTagCompound.hasKey("item_tier")) - event.toolTip.add("§7Obtained in: §c"+(floor == 0 ? "Entrance" : "Floor "+floor)); - if (nbtTagCompound.hasKey("baseStatBoostPercentage")) - event.toolTip.add("§7Stat Percentage: §"+(percentage == 50 ? "6§l":"c")+(percentage * 2)+"%"); +public class FeatureTooltipPrice extends SimpleFeature implements TooltipListener { + public FeatureTooltipPrice() { + super("tooltip", "Item Price", "Shows price of items", "tooltip.price"); } - @SubscribeEvent - public void priceTooltip(ItemTooltipEvent event) { - if (!e.getDungeonsGuide().getSkyblockStatus().isOnSkyblock()) return; - if (!FeatureRegistry.TOOLTIP_PRICE.isEnabled()) return; + + @Override + public void onTooltip(ItemTooltipEvent event) { + if (!isEnabled()) return; ItemStack hoveredItem = event.itemStack; NBTTagCompound compound = hoveredItem.getTagCompound(); @@ -79,7 +62,7 @@ public class ItemGuiListener { } if (iterations < 10) event.toolTip.add("§f"+ key + " " + enchants.getInteger(key) + "§7: §e"+ TextUtils.format((Integer) auctionData.prices.first()) + " §7to§e "+ TextUtils.format(auctionData.prices.last())); - totalLowestPrice += auctionData.prices.first(); + totalLowestPrice += auctionData.prices.first(); totalHighestPrice += auctionData.prices.last(); } if (iterations >= 10) @@ -101,4 +84,4 @@ public class ItemGuiListener { } } } -}
\ No newline at end of file +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java new file mode 100644 index 00000000..df1cf7ae --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java @@ -0,0 +1,7 @@ +package kr.syeyoung.dungeonsguide.features.listener; + +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +public interface TooltipListener { + void onTooltip(ItemTooltipEvent event); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java index adf1bc09..2c1e1889 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java @@ -48,10 +48,10 @@ public class MPanel { public void setBounds(Rectangle bounds) { if (bounds == null) return; - this.bounds.x = getBounds().x; - this.bounds.y = getBounds().y; - this.bounds.width = getBounds().width; - this.bounds.height = getBounds().height; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; for (MPanel childComponent : childComponents) { childComponent.resize0(getBounds().width, getBounds().height); @@ -79,23 +79,23 @@ public class MPanel { GL11.glTranslated(getBounds().x, getBounds().y, 0); - Rectangle absBound = getBounds(); + Rectangle absBound = getBounds().getBounds(); absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); Rectangle clip = determineClip(parentClip, absBound); lastAbsClip = clip; clip(resolution, clip.x, clip.y, clip.width, clip.height); - GL11.glPushAttrib(GL11.GL_SCISSOR_BIT); + GlStateManager.pushAttrib(); GL11.glEnable(GL11.GL_SCISSOR_TEST); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - + GlStateManager.pushAttrib(); GuiScreen.drawRect(0,0, getBounds().width, getBounds().height, backgroundColor.getRGB()); + GlStateManager.popAttrib(); GL11.glPushMatrix(); + GlStateManager.pushAttrib(); render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); + GlStateManager.popAttrib(); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_SCISSOR_TEST); @@ -106,7 +106,9 @@ public class MPanel { for (MPanel mPanel : getChildComponents()){ GL11.glPushMatrix(); + GlStateManager.pushAttrib(); mPanel.render0(resolution, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); + GlStateManager.popAttrib(); GL11.glPopMatrix(); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabbedPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabbedPane.java index 7ac824ba..a9a6922e 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabbedPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabbedPane.java @@ -64,9 +64,9 @@ public class MTabbedPane extends MPanel { @Override public void setBounds(Rectangle bounds) { if (bounds == null) return; - this.bounds.x = getBounds().x; - this.bounds.y = getBounds().y; - this.bounds.width = getBounds().width; - this.bounds.height = getBounds().height; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; } } |