From c37bda238c5072fa50dfa2d87aa137e1bdf5c4ac Mon Sep 17 00:00:00 2001 From: syeyoung Date: Thu, 4 Feb 2021 21:55:02 +0900 Subject: move guis --- .../config/guiconfig/FeatureEditPane.java | 4 +- .../dungeonsguide/config/guiconfig/GuiConfig.java | 4 +- .../config/guiconfig/GuiGuiLocationConfig.java | 4 +- .../config/guiconfig/GuiParameterConfig.java | 4 +- .../config/guiconfig/GuiParameterValueEdit.java | 10 +- .../dungeonsguide/config/guiconfig/MFeature.java | 10 +- .../dungeonsguide/config/guiconfig/MParameter.java | 11 +- .../config/guiconfig/PanelDelegate.java | 4 +- .../java/kr/syeyoung/dungeonsguide/gui/MPanel.java | 206 ++++++++++++ .../dungeonsguide/gui/elements/MButton.java | 52 +++ .../dungeonsguide/gui/elements/MColor.java | 30 ++ .../gui/elements/MFloatSelectionButton.java | 74 +++++ .../gui/elements/MIntegerSelectionButton.java | 70 +++++ .../dungeonsguide/gui/elements/MLabel.java | 48 +++ .../gui/elements/MLabelAndElement.java | 52 +++ .../dungeonsguide/gui/elements/MParameter.java | 72 +++++ .../gui/elements/MStringSelectionButton.java | 74 +++++ .../dungeonsguide/gui/elements/MTabButton.java | 61 ++++ .../dungeonsguide/gui/elements/MTabbedPane.java | 72 +++++ .../dungeonsguide/gui/elements/MTextField.java | 346 ++++++++++++++++++++ .../dungeonsguide/gui/elements/MValue.java | 61 ++++ .../kr/syeyoung/dungeonsguide/roomedit/MPanel.java | 210 ------------- .../dungeonsguide/roomedit/elements/MButton.java | 54 ---- .../dungeonsguide/roomedit/elements/MColor.java | 30 -- .../roomedit/elements/MFloatSelectionButton.java | 74 ----- .../roomedit/elements/MIntegerSelectionButton.java | 71 ----- .../dungeonsguide/roomedit/elements/MLabel.java | 48 --- .../roomedit/elements/MLabelAndElement.java | 52 --- .../roomedit/elements/MParameter.java | 72 ----- .../roomedit/elements/MStringSelectionButton.java | 74 ----- .../roomedit/elements/MTabButton.java | 61 ---- .../roomedit/elements/MTabbedPane.java | 72 ----- .../roomedit/elements/MTextField.java | 349 --------------------- .../dungeonsguide/roomedit/elements/MValue.java | 63 ---- .../roomedit/gui/GuiDungeonAddSet.java | 4 +- .../roomedit/gui/GuiDungeonParameterEdit.java | 4 +- .../roomedit/gui/GuiDungeonRoomEdit.java | 7 +- .../roomedit/gui/GuiDungeonValueEdit.java | 5 +- .../mechanicedit/ValueEditBreakableWall.java | 6 +- .../roomedit/mechanicedit/ValueEditDoor.java | 4 +- .../roomedit/mechanicedit/ValueEditLever.java | 5 +- .../roomedit/mechanicedit/ValueEditOnewayDoor.java | 5 +- .../mechanicedit/ValueEditOnewayLever.java | 10 +- .../mechanicedit/ValueEditPressurePlate.java | 10 +- .../roomedit/mechanicedit/ValueEditSecret.java | 4 +- .../roomedit/mechanicedit/ValueEditTomb.java | 8 +- .../roomedit/panes/ActionDisplayPane.java | 12 +- .../roomedit/panes/ActionTreeDisplayPane.java | 10 +- .../roomedit/panes/DynamicEditor.java | 3 +- .../roomedit/panes/GeneralEditPane.java | 9 +- .../roomedit/panes/ProcessorParameterEditPane.java | 6 +- .../roomedit/panes/RoomDataDisplayPane.java | 3 +- .../roomedit/panes/RoomMatchDisplayPane.java | 2 +- .../roomedit/panes/RoommatchingPane.java | 8 +- .../roomedit/panes/SecretEditPane.java | 6 +- .../roomedit/valueedit/ValueEditAColor.java | 8 +- .../roomedit/valueedit/ValueEditBoolean.java | 8 +- .../roomedit/valueedit/ValueEditColor.java | 5 +- .../roomedit/valueedit/ValueEditFloat.java | 9 +- .../roomedit/valueedit/ValueEditInteger.java | 9 +- .../roomedit/valueedit/ValueEditOffsetPoint.java | 4 +- .../valueedit/ValueEditOffsetPointSet.java | 6 +- .../roomedit/valueedit/ValueEditString.java | 8 +- 63 files changed, 1311 insertions(+), 1376 deletions(-) create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MColor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MFloatSelectionButton.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MIntegerSelectionButton.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabel.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabelAndElement.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MParameter.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MStringSelectionButton.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabButton.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MValue.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MColor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MFloatSelectionButton.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabel.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabButton.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabbedPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MValue.java (limited to 'src') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java index 7684c5f2..049808d9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java @@ -2,8 +2,8 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java index a9d81420..421bd918 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java @@ -2,8 +2,8 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MTabbedPane; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MTabbedPane; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; 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 f4d95cbb..53727698 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java @@ -3,8 +3,8 @@ 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.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java index fa80758c..3e2309d0 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java @@ -2,8 +2,8 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java index 56cfe179..90048a69 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java @@ -1,11 +1,9 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; +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; @@ -15,13 +13,11 @@ 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.minecraftforge.common.MinecraftForge; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import java.awt.*; import java.io.IOException; -import java.util.List; public class GuiParameterValueEdit extends GuiScreen { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java index 509dc3b6..cdc15456 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java @@ -1,13 +1,11 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiGuiLocationConfig; import kr.syeyoung.dungeonsguide.features.AbstractFeature; 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.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MStringSelectionButton; +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 lombok.Getter; import lombok.Setter; import net.minecraft.client.Minecraft; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java index 62d478cf..fc215a91 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java @@ -1,16 +1,11 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiParameterConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiParameterValueEdit; import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; import lombok.Getter; import lombok.Setter; import net.minecraft.client.Minecraft; 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 5ceecc23..6add50c4 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java @@ -1,11 +1,9 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.w3c.dom.css.Rect; import java.awt.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java new file mode 100755 index 00000000..4eae2298 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java @@ -0,0 +1,206 @@ +package kr.syeyoung.dungeonsguide.gui; + +import lombok.AccessLevel; +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.opengl.GL11; + +import java.awt.*; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +@Getter +public class MPanel { + protected Rectangle bounds = new Rectangle(0,0,0,0); // relative to parent + + protected List childComponents = new CopyOnWriteArrayList(); + + protected Color backgroundColor = new Color(0,0,0,0); + + protected Rectangle lastAbsClip = new Rectangle(0,0,0,0); + + @Getter(AccessLevel.PUBLIC) + protected boolean isFocused; + + public void setBackgroundColor(Color c) { + if (c == null) return; + this.backgroundColor = c; + } + + public void setPosition(Point pt) { + this.setBounds(new Rectangle(pt.x, pt.y, getBounds().width, getBounds().height)); + } + + public void setSize(Dimension dim) { + this.setBounds(new Rectangle(getBounds().x, getBounds().y, dim.width, dim.height)); + } + + public Dimension getSize() { + return getBounds().getSize(); + } + + public void setBounds(Rectangle bounds) { + if (bounds == null) return; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; + + for (MPanel childComponent : childComponents) { + childComponent.resize0(getBounds().width, getBounds().height); + } + onBoundsUpdate(); + } + + public void onBoundsUpdate() { + + } + + public void add(MPanel child) { + this.childComponents.add(child); + } + + public void remove(MPanel panel) { + this.childComponents.remove(panel); + } + + public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a + + + int relMousex = relMousex0 - getBounds().x; + int relMousey = relMousey0 - getBounds().y; + + GlStateManager.translate(getBounds().x, getBounds().y, 0); + GlStateManager.color(1,1,1,0); + + + 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); + GlStateManager.pushAttrib(); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + GlStateManager.pushAttrib(); + GuiScreen.drawRect(0,0, getBounds().width, getBounds().height, backgroundColor.getRGB()); + GlStateManager.popAttrib(); + + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); + GlStateManager.popAttrib(); + GlStateManager.popMatrix(); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + GL11.glPopAttrib(); + + + Point newPt = new Point(parentPoint.x + getBounds().x, parentPoint.y + getBounds().y); + + for (MPanel mPanel : getChildComponents()){ + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + mPanel.render0(resolution, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); + GlStateManager.popAttrib(); + GlStateManager.popMatrix(); + } + } + + public void clip(ScaledResolution resolution, int x, int y, int width, int height) { + int scale = resolution.getScaleFactor(); + GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); + } + + private Rectangle determineClip(Rectangle rect1, Rectangle rect2) { + int minX = Math.max(rect1.x, rect2.x); + int minY = Math.max(rect1.y, rect2.y); + int maxX = Math.min(rect1.x + rect1.width, rect2.x + rect2.width); + int maxY = Math.min(rect1.y + rect1.height, rect2.y +rect2.height); + if (minX > maxX) return new Rectangle(0,0,0,0); + if (minY > maxY) return new Rectangle(0,0,0,0); + return new Rectangle(minX, minY, maxX - minX, maxY - minY); + } + + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {} + + public void resize0(int parentWidth, int parentHeight) { + resize(parentWidth, parentHeight); + } + + public void resize(int parentWidth, int parentHeight) {} + + + public void keyTyped0(char typedChar, int keyCode) { + for (MPanel childComponent : getChildComponents()) { + childComponent.keyTyped0(typedChar, keyCode); + } + + if (isFocused) + keyTyped(typedChar, keyCode); + } + public void keyTyped(char typedChar, int keyCode) {} + + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + boolean noClip = true; + boolean focusedOverall = false; + for (MPanel childComponent : getChildComponents()) { + if (childComponent.mouseClicked0(absMouseX, absMouseY, relMousex, relMousey, mouseButton)) { + noClip = false; + focusedOverall = true; + } + } + + if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { + isFocused = true; + focusedOverall = true; + } else { + isFocused = false; + } + + mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); + return focusedOverall; + } + + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {} + + public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseReleased0(absMouseX, absMouseY, relMousex, relMousey, state); + } + mouseReleased(absMouseX, absMouseY, relMousex, relMousey, state); + } + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) {} + + public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseClickMove0(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); + } + mouseClickMove(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); + } + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {} + + public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseScrolled0(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); + } + mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); + } + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {} +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java new file mode 100755 index 00000000..17196ebc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java @@ -0,0 +1,52 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +@Getter +@Setter +public class MButton extends MPanel { + private String text; + + private Color foreground = Color.white; + private Color hover = Color.gray; + private Color clicked = Color.lightGray; + private Color disabled = Color.darkGray; + + private boolean enabled = true; + + private Runnable onActionPerformed; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + Color bg = backgroundColor; + if (!enabled) { + bg = disabled; + } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { + bg = hover; + } + if (bg != null) + Gui.drawRect(0,0,getBounds().width, getBounds().height, bg.getRGB()); + + FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; + int width = renderer.getStringWidth(getText()); + int x = (getBounds().width - width) / 2; + int y = (getBounds().height - renderer.FONT_HEIGHT) / 2; + + renderer.drawString(getText(), x,y, foreground.getRGB()); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (onActionPerformed != null && lastAbsClip.contains(absMouseX, absMouseY)) + onActionPerformed.run(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MColor.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MColor.java new file mode 100644 index 00000000..44be2d13 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MColor.java @@ -0,0 +1,30 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +@AllArgsConstructor +@NoArgsConstructor +public class MColor extends MPanel { + @Getter + @Setter + private Color color = Color.white; + @Getter + @Setter + private Dimension size = new Dimension(20,15); + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Rectangle rectangle = getBounds(); + + int x = (rectangle.width - getSize().width) / 2; + int y = (rectangle.height - getSize().height) / 2; + + Gui.drawRect(x,y,x+getSize().width,y+getSize().height, getColor().getRGB()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MFloatSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MFloatSelectionButton.java new file mode 100755 index 00000000..46e97cea --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MFloatSelectionButton.java @@ -0,0 +1,74 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; + +@Getter +@Setter +public class MFloatSelectionButton extends MPanel { + + private float data; + + private MButton dec; + private MButton inc; + private MTextField selected; + + @Getter + @Setter + private Runnable onUpdate; + + public MFloatSelectionButton(float data2) { + this.data = data2; + + dec = new MButton(); dec.setText("<"); add(dec); + inc = new MButton(); inc.setText(">"); add(inc); + selected = new MTextField() { + @Override + public String getText() { + return data +""; + } + @Override + public void edit(String str) { + try { + data = Float.parseFloat(str); + onUpdate.run(); + } catch (Exception e) {} + } + }; updateSelected(); add(selected); + + dec.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data--; + updateSelected(); + onUpdate.run(); + } + }); + inc.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data ++; + updateSelected(); + onUpdate.run(); + } + }); + } + + public float getSelected() { + return data; + } + + public void updateSelected() { + selected.setText(data+""); + } + + @Override + public void onBoundsUpdate() { + dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); + inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); + selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MIntegerSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MIntegerSelectionButton.java new file mode 100755 index 00000000..6e66c4f0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MIntegerSelectionButton.java @@ -0,0 +1,70 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; + +@Getter +@Setter +public class MIntegerSelectionButton extends MPanel { + + private int data; + + private MButton dec; + private MButton inc; + private MTextField selected; + + @Getter + @Setter + private Runnable onUpdate; + + public MIntegerSelectionButton(int data2) { + this.data = data2; + + dec = new MButton(); dec.setText("<"); add(dec); + inc = new MButton(); inc.setText(">"); add(inc); + selected = new MTextField() { + @Override + public void edit(String str) { + try { + data = Integer.parseInt(str); + onUpdate.run(); + } catch (Exception e) {} + } + }; updateSelected(); add(selected); + + dec.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data--; + updateSelected(); + onUpdate.run(); + } + }); + inc.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data ++; + updateSelected(); + onUpdate.run(); + } + }); + } + + public int getSelected() { + return data; + } + + private void updateSelected() { + selected.setText(data+""); + } + + @Override + public void onBoundsUpdate() { + dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); + inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); + selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabel.java new file mode 100755 index 00000000..024f0c1f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabel.java @@ -0,0 +1,48 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; + +public class MLabel extends MPanel { + @Getter + @Setter + private String text; + + @Getter + @Setter + private Color foreground = Color.white; + + public enum Alignment { + LEFT, CENTER, RIGHT + } + @Getter + @Setter + private Alignment alignment= Alignment.LEFT; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; + int width = renderer.getStringWidth(getText()); + int x,y; + if (alignment == Alignment.CENTER) { + x = (getBounds().width - width) / 2; + y = (getBounds().height - renderer.FONT_HEIGHT) / 2; + } else if (alignment == Alignment.LEFT) { + x = 0; + y = (getBounds().height - renderer.FONT_HEIGHT) / 2; + } else if (alignment == Alignment.RIGHT) { + x = getBounds().width - width; + y = (getBounds().height - renderer.FONT_HEIGHT) / 2; + } else{ + return; + } + renderer.drawString(getText(), x,y, 0xffffff); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabelAndElement.java new file mode 100755 index 00000000..601cb1aa --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabelAndElement.java @@ -0,0 +1,52 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +public class MLabelAndElement extends MPanel { + private MLabel label; + private MPanel element; + + @Getter @Setter + private Color hover; + @Getter @Setter + private Runnable onClick; + + public MLabelAndElement(String label, MPanel element) { + this.add(this.label = new MLabel()); + this.label.setText(label); + this.add(element); + this.element = element; + } + + @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 mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (onClick!= null && lastAbsClip.contains(absMouseX, absMouseY)) { + onClick.run(); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + label.setBounds(new Rectangle(0,0,parentHeight / 3, getBounds().height)); + element.setBounds(new Rectangle(parentWidth / 3,0,parentWidth / 3 * 2, getBounds().height)); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width / 3, getBounds().height)); + element.setBounds(new Rectangle(getBounds().width / 3,0,getBounds().width / 3 * 2, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MParameter.java new file mode 100755 index 00000000..bc7f81e1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MParameter.java @@ -0,0 +1,72 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; +import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +public class MParameter extends MPanel { + private MLabel label; + private MLabel data; + + @Getter @Setter + private Color hover = Color.gray; + + @Getter @Setter + private Parameter parameter; + private DynamicEditor processorParameterEditPane; + + public MParameter(final Parameter parameter, DynamicEditor processorParameterEditPane) { + this.processorParameterEditPane = processorParameterEditPane; + this.add(this.label = new MLabel() { + @Override + public String getText() { + return parameter.getName(); + } + }); + this.add(this.data = new MLabel() { + @Override + public String getText() { + return parameter.getNewData() != null ?parameter.getNewData().toString() :"-empty-"; + } + }); + this.label.setAlignment(MLabel.Alignment.LEFT); + this.data.setAlignment(MLabel.Alignment.RIGHT); + + this.parameter = parameter; + } + + @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 mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (this.getBounds().x > -20 && lastAbsClip.contains(absMouseX, absMouseY)) { + // open new gui; + EditingContext.getEditingContext().openGui(new GuiDungeonParameterEdit(this, processorParameterEditPane)); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + label.setBounds(new Rectangle(0,0,parentHeight / 3, getBounds().height)); + data.setBounds(new Rectangle(parentWidth / 3,0,parentWidth / 3 * 2, getBounds().height)); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width / 3, getBounds().height)); + data.setBounds(new Rectangle(getBounds().width / 3,0,getBounds().width / 3 * 2, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MStringSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MStringSelectionButton.java new file mode 100755 index 00000000..b3f78fa3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MStringSelectionButton.java @@ -0,0 +1,74 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; +import java.util.List; + +@Getter +@Setter +public class MStringSelectionButton extends MPanel { + + private List possible; + private int selectedIndex; + + private MButton dec; + private MButton inc; + private MLabel selected; + + @Getter + @Setter + private Runnable onUpdate; + + public MStringSelectionButton(final List possible, String defaultValue) { + this.possible = possible; + selectedIndex = possible.indexOf(defaultValue); + if (selectedIndex == -1) selectedIndex = 0; + + dec = new MButton(); dec.setText("<"); add(dec); + inc = new MButton(); inc.setText(">"); add(inc); + selected = new MLabel(); updateSelected(); add(selected); + + dec.setOnActionPerformed(new Runnable() { + @Override + public void run() { + selectedIndex++; + if (selectedIndex >= possible.size()) selectedIndex = 0; + updateSelected(); + onUpdate.run(); + } + }); + inc.setOnActionPerformed(new Runnable() { + @Override + public void run() { + selectedIndex --; + if (selectedIndex < 0) selectedIndex = possible.size() - 1; + updateSelected(); + onUpdate.run(); + } + }); + } + + public String selectionToDisplay(String selection) { + return selection; + } + + public String getSelected() { + if (possible.size() == 0) return null; + return possible.get(selectedIndex); + } + + private void updateSelected() { + if (possible.size() == 0) selected.setText("-Empty-"); + else selected.setText(selectionToDisplay(possible.get(selectedIndex))); + } + + @Override + public void onBoundsUpdate() { + dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); + inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); + selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabButton.java new file mode 100755 index 00000000..cf6f6fc7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabButton.java @@ -0,0 +1,61 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +@Getter +@Setter +public class MTabButton extends MPanel { + private String text; + + private Color foreground = Color.white; + private Color hover = new Color(236, 236, 236, 64); + private Color clicked = new Color(30,30,30,0); + private Color selected = new Color(0,0,0,255); + private Color disabled = new Color(0,0,0); + + private boolean enabled = true; + + private MTabbedPane tabbedPane; + + public MTabButton(MTabbedPane tabbedPane, String key) { + this.tabbedPane = tabbedPane; + this.text = key; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + Color bg = null; + if (!enabled) { + bg = disabled; + } else if (tabbedPane.getSelectedKey().equals(text)) { + bg = selected; + } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { + bg = hover; + } + if (bg != null) + Gui.drawRect(0,0,getBounds().width, getBounds().height, bg.getRGB()); + + FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; + int width = renderer.getStringWidth(text); + int x = (getBounds().width - width) / 2; + int y = (getBounds().height - renderer.FONT_HEIGHT) / 2; + + renderer.drawString(text, x,y, foreground.getRGB()); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY)) { + tabbedPane.setSelectedKey(text); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java new file mode 100755 index 00000000..96b2e81d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java @@ -0,0 +1,72 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MTabbedPane extends MPanel { + + private Map tabs = new HashMap(); + private Map buttons = new HashMap(); + + @Getter + @Setter + private String selectedKey = ""; + + @Getter + private Color background2; + + public void setBackground2(Color background2) { + this.background2 = background2; + for (MPanel value : tabs.values()) { + value.setBackgroundColor(background2); + } + for (MTabButton value : buttons.values()) { + value.setBackgroundColor(background2.brighter()); + } + } + + public void addTab(String tab, MPanel panel) { + MPanel panel2 = new MPanel() ; + panel2.add(panel); + panel2.setBackgroundColor(background2); + tabs.put(tab, panel2); + panel2.setBounds(new Rectangle(0,15,getBounds().width, getBounds().height-15)); + + MTabButton button = new MTabButton(this, tab); + button.setBackgroundColor(background2.brighter()); + button.setBounds(new Rectangle(buttons.size()* 50, 0, 50, 15)); + buttons.put(tab, button); + if (tabs.size() == 1) + selectedKey = tab; + } + + @Override + public List getChildComponents() { + ArrayList dynamic = new ArrayList(buttons.values()); + dynamic.add(tabs.get(selectedKey)); + return dynamic; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + for (MPanel ma:tabs.values()) + ma.setBounds(new Rectangle(0,15,parentWidth, parentHeight-15)); + } + + @Override + public void setBounds(Rectangle bounds) { + if (bounds == null) return; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java new file mode 100755 index 00000000..57232f7f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java @@ -0,0 +1,346 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import org.lwjgl.input.Keyboard; + +import java.awt.*; +import java.awt.datatransfer.*; +import java.awt.event.KeyEvent; +import java.io.IOException; + +@Getter +public class MTextField extends MPanel { + private Color foreground = Color.white; + + private String text = "asdasdasd"; + private int cursorBlickTicker = 0; + + private int selectionStart = 0; + private int selectionEnd = 0; + + private int cursor = 0; + + private int xOffset = 0; + + public void edit(String str) { + + } + + public void setText(String text) { + this.text = text; + } + private void setText0(String text) { + this.text = text; + edit(text); + } + + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, isFocused ? Color.white.getRGB() : Color.gray.getRGB()); + Gui.drawRect(1,1,getBounds().width - 2, getBounds().height - 2, Color.black.getRGB()); + + Minecraft mc = Minecraft.getMinecraft(); + clip(new ScaledResolution(mc), clip.x + 1, clip.y + 1, clip.width - 2, clip.height - 2); + FontRenderer fr = mc.fontRendererObj; + int y = (getBounds().height - fr.FONT_HEIGHT) / 2; + fr.drawString(text, 3 - xOffset, y, foreground.getRGB()); + // draw selection + if (isFocused) { + if (selectionStart != -1) { + int startX = fr.getStringWidth(text.substring(0, selectionStart)) - xOffset; + int endX = fr.getStringWidth(text.substring(0, selectionEnd)) - xOffset; + Gui.drawRect(3 + startX, y, 3 + endX, y + fr.FONT_HEIGHT, 0xFF00FF00); + fr.drawString(text.substring(selectionStart, selectionEnd), 3 + startX, y, foreground.getRGB()); + } + + // draw cursor + if (cursor != -1) { + if (cursor > text.length()) cursor = text.length(); + int x = fr.getStringWidth(text.substring(0, cursor)) - xOffset; + cursorBlickTicker++; + if (cursorBlickTicker < 10) + Gui.drawRect(3 + x, y, 4 + x, y + fr.FONT_HEIGHT, 0xFFFFFFFF); + if (cursorBlickTicker == 20) cursorBlickTicker = 0; + } + } + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + Rectangle actualField = new Rectangle(1, 3,getBounds().width - 2, getBounds().height - 6); + if (!actualField.contains(relMouseX, relMouseY)) return; + if (!lastAbsClip.contains(absMouseX, absMouseY)) return; + + + + + int relStartT = relMouseX-3; + int offseted = relStartT + xOffset; + + selectionStart = -1; + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + for (int i = 0; i < text.length(); i++) { + int totalWidth = fr.getStringWidth(text.substring(0, i)); + if (offseted < totalWidth) { + cursor = i; + return; + } + } + cursor = text.length(); + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + if (!isFocused) return; + selectionStart = cursor; + selectionEnd = cursor; + + int relStartT = relMouseX-3; + int offseted = relStartT + xOffset; + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + for (int i = 0; i < text.length(); i++) { + int totalWidth = fr.getStringWidth(text.substring(0, i)); + if (offseted < totalWidth) { + if (i < cursor) { + selectionStart = i; + selectionEnd = cursor; + } else { + selectionStart = cursor; + selectionEnd = i; + } + return; + } + } + selectionEnd = text.length(); + if (selectionStart == selectionEnd) { + selectionStart = -1; + } + } + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (!isFocused) return; + if (scrollAmount > 0) { + xOffset += 5; + } else if (scrollAmount < 0){ + xOffset -= 5; + } + if (xOffset < 0) { + xOffset = 0; + } + int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text); + int overflow = getBounds().width - 3 - width; + if (overflow >= 0) { + xOffset = 0; + } else if (width - xOffset + 10 < getBounds().width) { + xOffset = width - getBounds().width+10; + } + } + + @Override + public void keyTyped(char typedChar, int keycode) { + if (!isFocused) return; + + + if (selectionStart == -1) { + if (keycode == 199) { // home + cursor = 0; + return; + } + + if (keycode == 207) { // end + cursor = text.length(); + return; + } + + if (keycode == 203) { // left + cursor--; + if (cursor < 0) cursor = 0; + return; + } + + if (keycode == 205) { // right + cursor ++; + if (cursor > text.length()) cursor = text.length(); + return; + } + + // backspace + if (keycode == 14 && cursor > 0) { + setText0(this.text.substring(0, cursor - 1) + this.text.substring(cursor)); + cursor--; + return; + } + + //del + if (keycode == 211 && cursor < text.length()) { + setText0(this.text.substring(0, cursor) + this.text.substring(cursor+1)); + return; + } + + // paste + boolean shouldPaste = false; + if (keycode == 47) { + if (Minecraft.isRunningOnMac) { // mac + if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { + shouldPaste = true; + } + } else { // literally everything else + if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { + shouldPaste = true; + } + } + } + if (shouldPaste) { + Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); + if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { + try { + Object theText = transferable.getTransferData(DataFlavor.stringFlavor); + setText0( + this.text.substring(0, this.cursor) + + theText + + this.text.substring(this.cursor)); + + cursor += theText.toString().length(); + } catch (UnsupportedFlavorException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return; + } + + // text + if (isPrintableChar(typedChar)) { + setText0( + this.text.substring(0, this.cursor) + + typedChar + + this.text.substring(this.cursor)); + this.cursor++; + return; + } + } else { + if (keycode == 199) { // home + cursor = 0; + selectionStart = -1; + return; + } + + if (keycode == 207) { // end + selectionStart = -1; + cursor = text.length(); + return; + } + + if (keycode == 203) { // left + cursor = selectionStart; + selectionStart = -1; + return; + } + + if (keycode == 205) { // right + cursor = selectionEnd; + selectionStart = -1; + return; + } + + // backspace + if (keycode == 14 && cursor > 0) { + setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); + cursor = selectionStart; + selectionStart = -1; + return; + } + + //del + if (keycode == 211 && cursor < text.length()) { + setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); + cursor = selectionStart; + selectionStart = -1; + return; + } + + // paste + boolean shouldPaste = false; + if (keycode == 47) { + if (Minecraft.isRunningOnMac) { // mac + if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { + shouldPaste = true; + } + } else { // literally everything else + if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { + shouldPaste = true; + } + } + } + if (shouldPaste) { + Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); + if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { + try { + Object theText = transferable.getTransferData(DataFlavor.stringFlavor); + setText0( + this.text.substring(0, this.selectionStart) + + theText + + this.text.substring(this.selectionEnd)); + cursor = this.selectionStart + theText.toString().length(); + } catch (UnsupportedFlavorException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + selectionStart = -1; + } + return; + } + boolean shouldCopy = false; + if (keycode == 46) { + if (Minecraft.isRunningOnMac) { // mac + if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { + shouldCopy = true; + } + } else { // literally everything else + if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { + shouldCopy = true; + } + } + } + if (shouldCopy) { + StringSelection selection = new StringSelection(text.substring(selectionStart, selectionEnd)); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(selection, selection); + return; + } + + // text + if (isPrintableChar(typedChar)) { + setText0( + this.text.substring(0, this.selectionStart) + + typedChar + + this.text.substring(this.selectionEnd)); + this.cursor = this.selectionStart + 1; + selectionStart = -1; + return; + } + } + } + public boolean isPrintableChar( char c ) { + Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); + return (!Character.isISOControl(c)) && + c != KeyEvent.CHAR_UNDEFINED && + block != null && + block != Character.UnicodeBlock.SPECIALS; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MValue.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MValue.java new file mode 100755 index 00000000..e4e51841 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MValue.java @@ -0,0 +1,61 @@ +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditOffsetPointSet; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; +import java.util.List; +public class MValue extends MPanel { + @Getter + private T data; + private ValueEditOffsetPointSet valueEditOffsetPointSet; + private MLabel dataLab; + + @Getter @Setter + private Color hover = Color.gray; + + private List addons; + + public MValue(final T parameter, List addons) { + this.addons = addons; + this.add(this.dataLab = new MLabel() { + @Override + public String getText() { + return data != null ?data.toString() :"-empty-"; + } + }); + this.dataLab.setAlignment(MLabel.Alignment.RIGHT); + + this.data = parameter; + } + + @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 mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (this.getBounds().x > -20 && lastAbsClip.contains(absMouseX, absMouseY)) { + EditingContext.getEditingContext().openGui(new GuiDungeonValueEdit(data, addons)); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + dataLab.setBounds(new Rectangle(0,0,parentWidth, getBounds().height)); + } + + @Override + public void onBoundsUpdate() { + dataLab.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java deleted file mode 100755 index ad350863..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java +++ /dev/null @@ -1,210 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit; - -import lombok.AccessLevel; -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.client.renderer.OpenGlHelper; -import org.lwjgl.opengl.GL11; -import org.w3c.dom.css.Rect; - -import java.awt.*; -import java.io.IOException; -import java.util.List; -import java.util.ArrayList; -import java.util.concurrent.CopyOnWriteArrayList; - -@Getter -public class MPanel { - protected Rectangle bounds = new Rectangle(0,0,0,0); // relative to parent - - protected List childComponents = new CopyOnWriteArrayList(); - - protected Color backgroundColor = new Color(0,0,0,0); - - protected Rectangle lastAbsClip = new Rectangle(0,0,0,0); - - @Getter(AccessLevel.PUBLIC) - protected boolean isFocused; - - public void setBackgroundColor(Color c) { - if (c == null) return; - this.backgroundColor = c; - } - - public void setPosition(Point pt) { - this.setBounds(new Rectangle(pt.x, pt.y, getBounds().width, getBounds().height)); - } - - public void setSize(Dimension dim) { - this.setBounds(new Rectangle(getBounds().x, getBounds().y, dim.width, dim.height)); - } - - public Dimension getSize() { - return getBounds().getSize(); - } - - public void setBounds(Rectangle bounds) { - if (bounds == null) return; - this.bounds.x = bounds.x; - this.bounds.y = bounds.y; - this.bounds.width = bounds.width; - this.bounds.height = bounds.height; - - for (MPanel childComponent : childComponents) { - childComponent.resize0(getBounds().width, getBounds().height); - } - onBoundsUpdate(); - } - - public void onBoundsUpdate() { - - } - - public void add(MPanel child) { - this.childComponents.add(child); - } - - public void remove(MPanel panel) { - this.childComponents.remove(panel); - } - - public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a - - - int relMousex = relMousex0 - getBounds().x; - int relMousey = relMousey0 - getBounds().y; - - GlStateManager.translate(getBounds().x, getBounds().y, 0); - GlStateManager.color(1,1,1,0); - - - 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); - GlStateManager.pushAttrib(); - GL11.glEnable(GL11.GL_SCISSOR_TEST); - - GlStateManager.pushAttrib(); - GuiScreen.drawRect(0,0, getBounds().width, getBounds().height, backgroundColor.getRGB()); - GlStateManager.popAttrib(); - - GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); - render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); - GlStateManager.popAttrib(); - GlStateManager.popMatrix(); - - GL11.glDisable(GL11.GL_SCISSOR_TEST); - GL11.glPopAttrib(); - - - Point newPt = new Point(parentPoint.x + getBounds().x, parentPoint.y + getBounds().y); - - for (MPanel mPanel : getChildComponents()){ - GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); - mPanel.render0(resolution, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); - GlStateManager.popAttrib(); - GlStateManager.popMatrix(); - } - } - - public void clip(ScaledResolution resolution, int x, int y, int width, int height) { - int scale = resolution.getScaleFactor(); - GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); - } - - private Rectangle determineClip(Rectangle rect1, Rectangle rect2) { - int minX = Math.max(rect1.x, rect2.x); - int minY = Math.max(rect1.y, rect2.y); - int maxX = Math.min(rect1.x + rect1.width, rect2.x + rect2.width); - int maxY = Math.min(rect1.y + rect1.height, rect2.y +rect2.height); - if (minX > maxX) return new Rectangle(0,0,0,0); - if (minY > maxY) return new Rectangle(0,0,0,0); - return new Rectangle(minX, minY, maxX - minX, maxY - minY); - } - - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {} - - public void resize0(int parentWidth, int parentHeight) { - resize(parentWidth, parentHeight); - } - - public void resize(int parentWidth, int parentHeight) {} - - - public void keyTyped0(char typedChar, int keyCode) { - for (MPanel childComponent : getChildComponents()) { - childComponent.keyTyped0(typedChar, keyCode); - } - - if (isFocused) - keyTyped(typedChar, keyCode); - } - public void keyTyped(char typedChar, int keyCode) {} - - public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - boolean noClip = true; - boolean focusedOverall = false; - for (MPanel childComponent : getChildComponents()) { - if (childComponent.mouseClicked0(absMouseX, absMouseY, relMousex, relMousey, mouseButton)) { - noClip = false; - focusedOverall = true; - } - } - - if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { - isFocused = true; - focusedOverall = true; - } else { - isFocused = false; - } - - mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); - return focusedOverall; - } - - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {} - - public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseReleased0(absMouseX, absMouseY, relMousex, relMousey, state); - } - mouseReleased(absMouseX, absMouseY, relMousex, relMousey, state); - } - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) {} - - public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseClickMove0(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); - } - mouseClickMove(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); - } - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {} - - public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseScrolled0(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); - } - mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); - } - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {} -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java deleted file mode 100755 index 7d6581fc..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java +++ /dev/null @@ -1,54 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import org.lwjgl.opengl.GL11; -import org.w3c.dom.css.Rect; - -import java.awt.*; - -@Getter -@Setter -public class MButton extends MPanel { - private String text; - - private Color foreground = Color.white; - private Color hover = Color.gray; - private Color clicked = Color.lightGray; - private Color disabled = Color.darkGray; - - private boolean enabled = true; - - private Runnable onActionPerformed; - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Dimension bounds = getSize(); - - Color bg = backgroundColor; - if (!enabled) { - bg = disabled; - } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { - bg = hover; - } - if (bg != null) - Gui.drawRect(0,0,getBounds().width, getBounds().height, bg.getRGB()); - - FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(getText()); - int x = (getBounds().width - width) / 2; - int y = (getBounds().height - renderer.FONT_HEIGHT) / 2; - - renderer.drawString(getText(), x,y, foreground.getRGB()); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (onActionPerformed != null && lastAbsClip.contains(absMouseX, absMouseY)) - onActionPerformed.run(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MColor.java deleted file mode 100644 index 360d1992..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MColor.java +++ /dev/null @@ -1,30 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -@AllArgsConstructor -@NoArgsConstructor -public class MColor extends MPanel { - @Getter - @Setter - private Color color = Color.white; - @Getter - @Setter - private Dimension size = new Dimension(20,15); - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Rectangle rectangle = getBounds(); - - int x = (rectangle.width - getSize().width) / 2; - int y = (rectangle.height - getSize().height) / 2; - - Gui.drawRect(x,y,x+getSize().width,y+getSize().height, getColor().getRGB()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MFloatSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MFloatSelectionButton.java deleted file mode 100755 index 504d3e33..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MFloatSelectionButton.java +++ /dev/null @@ -1,74 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.Getter; -import lombok.Setter; - -import java.awt.*; - -@Getter -@Setter -public class MFloatSelectionButton extends MPanel { - - private float data; - - private MButton dec; - private MButton inc; - private MTextField selected; - - @Getter - @Setter - private Runnable onUpdate; - - public MFloatSelectionButton(float data2) { - this.data = data2; - - dec = new MButton(); dec.setText("<"); add(dec); - inc = new MButton(); inc.setText(">"); add(inc); - selected = new MTextField() { - @Override - public String getText() { - return data +""; - } - @Override - public void edit(String str) { - try { - data = Float.parseFloat(str); - onUpdate.run(); - } catch (Exception e) {} - } - }; updateSelected(); add(selected); - - dec.setOnActionPerformed(new Runnable() { - @Override - public void run() { - data--; - updateSelected(); - onUpdate.run(); - } - }); - inc.setOnActionPerformed(new Runnable() { - @Override - public void run() { - data ++; - updateSelected(); - onUpdate.run(); - } - }); - } - - public float getSelected() { - return data; - } - - public void updateSelected() { - selected.setText(data+""); - } - - @Override - public void onBoundsUpdate() { - dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); - inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); - selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java deleted file mode 100755 index c61e4f08..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java +++ /dev/null @@ -1,71 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.Getter; -import lombok.Setter; - -import java.awt.*; -import java.util.List; - -@Getter -@Setter -public class MIntegerSelectionButton extends MPanel { - - private int data; - - private MButton dec; - private MButton inc; - private MTextField selected; - - @Getter - @Setter - private Runnable onUpdate; - - public MIntegerSelectionButton(int data2) { - this.data = data2; - - dec = new MButton(); dec.setText("<"); add(dec); - inc = new MButton(); inc.setText(">"); add(inc); - selected = new MTextField() { - @Override - public void edit(String str) { - try { - data = Integer.parseInt(str); - onUpdate.run(); - } catch (Exception e) {} - } - }; updateSelected(); add(selected); - - dec.setOnActionPerformed(new Runnable() { - @Override - public void run() { - data--; - updateSelected(); - onUpdate.run(); - } - }); - inc.setOnActionPerformed(new Runnable() { - @Override - public void run() { - data ++; - updateSelected(); - onUpdate.run(); - } - }); - } - - public int getSelected() { - return data; - } - - private void updateSelected() { - selected.setText(data+""); - } - - @Override - public void onBoundsUpdate() { - dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); - inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); - selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabel.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabel.java deleted file mode 100755 index d01b858f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabel.java +++ /dev/null @@ -1,48 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; - -import java.awt.*; - -public class MLabel extends MPanel { - @Getter - @Setter - private String text; - - @Getter - @Setter - private Color foreground = Color.white; - - public enum Alignment { - LEFT, CENTER, RIGHT - } - @Getter - @Setter - private Alignment alignment= Alignment.LEFT; - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Dimension bounds = getSize(); - - FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(getText()); - int x,y; - if (alignment == Alignment.CENTER) { - x = (getBounds().width - width) / 2; - y = (getBounds().height - renderer.FONT_HEIGHT) / 2; - } else if (alignment == Alignment.LEFT) { - x = 0; - y = (getBounds().height - renderer.FONT_HEIGHT) / 2; - } else if (alignment == Alignment.RIGHT) { - x = getBounds().width - width; - y = (getBounds().height - renderer.FONT_HEIGHT) / 2; - } else{ - return; - } - renderer.drawString(getText(), x,y, 0xffffff); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java deleted file mode 100755 index 9bab1bdb..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java +++ /dev/null @@ -1,52 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -public class MLabelAndElement extends MPanel { - private MLabel label; - private MPanel element; - - @Getter @Setter - private Color hover; - @Getter @Setter - private Runnable onClick; - - public MLabelAndElement(String label, MPanel element) { - this.add(this.label = new MLabel()); - this.label.setText(label); - this.add(element); - this.element = element; - } - - @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 mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (onClick!= null && lastAbsClip.contains(absMouseX, absMouseY)) { - onClick.run(); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setSize(new Dimension(parentWidth, getBounds().height)); - label.setBounds(new Rectangle(0,0,parentHeight / 3, getBounds().height)); - element.setBounds(new Rectangle(parentWidth / 3,0,parentWidth / 3 * 2, getBounds().height)); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width / 3, getBounds().height)); - element.setBounds(new Rectangle(getBounds().width / 3,0,getBounds().width / 3 * 2, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java deleted file mode 100755 index 12ad9972..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java +++ /dev/null @@ -1,72 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; -import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -public class MParameter extends MPanel { - private MLabel label; - private MLabel data; - - @Getter @Setter - private Color hover = Color.gray; - - @Getter @Setter - private Parameter parameter; - private DynamicEditor processorParameterEditPane; - - public MParameter(final Parameter parameter, DynamicEditor processorParameterEditPane) { - this.processorParameterEditPane = processorParameterEditPane; - this.add(this.label = new MLabel() { - @Override - public String getText() { - return parameter.getName(); - } - }); - this.add(this.data = new MLabel() { - @Override - public String getText() { - return parameter.getNewData() != null ?parameter.getNewData().toString() :"-empty-"; - } - }); - this.label.setAlignment(MLabel.Alignment.LEFT); - this.data.setAlignment(MLabel.Alignment.RIGHT); - - this.parameter = parameter; - } - - @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 mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (this.getBounds().x > -20 && lastAbsClip.contains(absMouseX, absMouseY)) { - // open new gui; - EditingContext.getEditingContext().openGui(new GuiDungeonParameterEdit(this, processorParameterEditPane)); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setSize(new Dimension(parentWidth, getBounds().height)); - label.setBounds(new Rectangle(0,0,parentHeight / 3, getBounds().height)); - data.setBounds(new Rectangle(parentWidth / 3,0,parentWidth / 3 * 2, getBounds().height)); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width / 3, getBounds().height)); - data.setBounds(new Rectangle(getBounds().width / 3,0,getBounds().width / 3 * 2, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java deleted file mode 100755 index 39eec74f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java +++ /dev/null @@ -1,74 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.Getter; -import lombok.Setter; - -import java.awt.*; -import java.util.List; - -@Getter -@Setter -public class MStringSelectionButton extends MPanel { - - private List possible; - private int selectedIndex; - - private MButton dec; - private MButton inc; - private MLabel selected; - - @Getter - @Setter - private Runnable onUpdate; - - public MStringSelectionButton(final List possible, String defaultValue) { - this.possible = possible; - selectedIndex = possible.indexOf(defaultValue); - if (selectedIndex == -1) selectedIndex = 0; - - dec = new MButton(); dec.setText("<"); add(dec); - inc = new MButton(); inc.setText(">"); add(inc); - selected = new MLabel(); updateSelected(); add(selected); - - dec.setOnActionPerformed(new Runnable() { - @Override - public void run() { - selectedIndex++; - if (selectedIndex >= possible.size()) selectedIndex = 0; - updateSelected(); - onUpdate.run(); - } - }); - inc.setOnActionPerformed(new Runnable() { - @Override - public void run() { - selectedIndex --; - if (selectedIndex < 0) selectedIndex = possible.size() - 1; - updateSelected(); - onUpdate.run(); - } - }); - } - - public String selectionToDisplay(String selection) { - return selection; - } - - public String getSelected() { - if (possible.size() == 0) return null; - return possible.get(selectedIndex); - } - - private void updateSelected() { - if (possible.size() == 0) selected.setText("-Empty-"); - else selected.setText(selectionToDisplay(possible.get(selectedIndex))); - } - - @Override - public void onBoundsUpdate() { - dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); - inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); - selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabButton.java deleted file mode 100755 index 799c68a9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabButton.java +++ /dev/null @@ -1,61 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -@Getter -@Setter -public class MTabButton extends MPanel { - private String text; - - private Color foreground = Color.white; - private Color hover = new Color(236, 236, 236, 64); - private Color clicked = new Color(30,30,30,0); - private Color selected = new Color(0,0,0,255); - private Color disabled = new Color(0,0,0); - - private boolean enabled = true; - - private MTabbedPane tabbedPane; - - public MTabButton(MTabbedPane tabbedPane, String key) { - this.tabbedPane = tabbedPane; - this.text = key; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Dimension bounds = getSize(); - - Color bg = null; - if (!enabled) { - bg = disabled; - } else if (tabbedPane.getSelectedKey().equals(text)) { - bg = selected; - } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { - bg = hover; - } - if (bg != null) - Gui.drawRect(0,0,getBounds().width, getBounds().height, bg.getRGB()); - - FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(text); - int x = (getBounds().width - width) / 2; - int y = (getBounds().height - renderer.FONT_HEIGHT) / 2; - - renderer.drawString(text, x,y, foreground.getRGB()); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY)) { - tabbedPane.setSelectedKey(text); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabbedPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabbedPane.java deleted file mode 100755 index a9a6922e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabbedPane.java +++ /dev/null @@ -1,72 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.Getter; -import lombok.Setter; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class MTabbedPane extends MPanel { - - private Map tabs = new HashMap(); - private Map buttons = new HashMap(); - - @Getter - @Setter - private String selectedKey = ""; - - @Getter - private Color background2; - - public void setBackground2(Color background2) { - this.background2 = background2; - for (MPanel value : tabs.values()) { - value.setBackgroundColor(background2); - } - for (MTabButton value : buttons.values()) { - value.setBackgroundColor(background2.brighter()); - } - } - - public void addTab(String tab, MPanel panel) { - MPanel panel2 = new MPanel() ; - panel2.add(panel); - panel2.setBackgroundColor(background2); - tabs.put(tab, panel2); - panel2.setBounds(new Rectangle(0,15,getBounds().width, getBounds().height-15)); - - MTabButton button = new MTabButton(this, tab); - button.setBackgroundColor(background2.brighter()); - button.setBounds(new Rectangle(buttons.size()* 50, 0, 50, 15)); - buttons.put(tab, button); - if (tabs.size() == 1) - selectedKey = tab; - } - - @Override - public List getChildComponents() { - ArrayList dynamic = new ArrayList(buttons.values()); - dynamic.add(tabs.get(selectedKey)); - return dynamic; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - for (MPanel ma:tabs.values()) - ma.setBounds(new Rectangle(0,15,parentWidth, parentHeight-15)); - } - - @Override - public void setBounds(Rectangle bounds) { - if (bounds == null) return; - this.bounds.x = bounds.x; - this.bounds.y = bounds.y; - this.bounds.width = bounds.width; - this.bounds.height = bounds.height; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java deleted file mode 100755 index 49c36d3c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java +++ /dev/null @@ -1,349 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.awt.datatransfer.*; -import java.awt.event.KeyEvent; -import java.io.IOException; - -@Getter -public class MTextField extends MPanel { - private Color foreground = Color.white; - - private String text = "asdasdasd"; - private int cursorBlickTicker = 0; - - private int selectionStart = 0; - private int selectionEnd = 0; - - private int cursor = 0; - - private int xOffset = 0; - - public void edit(String str) { - - } - - public void setText(String text) { - this.text = text; - } - private void setText0(String text) { - this.text = text; - edit(text); - } - - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Gui.drawRect(0,0,getBounds().width, getBounds().height, isFocused ? Color.white.getRGB() : Color.gray.getRGB()); - Gui.drawRect(1,1,getBounds().width - 2, getBounds().height - 2, Color.black.getRGB()); - - Minecraft mc = Minecraft.getMinecraft(); - clip(new ScaledResolution(mc), clip.x + 1, clip.y + 1, clip.width - 2, clip.height - 2); - FontRenderer fr = mc.fontRendererObj; - int y = (getBounds().height - fr.FONT_HEIGHT) / 2; - fr.drawString(text, 3 - xOffset, y, foreground.getRGB()); - // draw selection - if (isFocused) { - if (selectionStart != -1) { - int startX = fr.getStringWidth(text.substring(0, selectionStart)) - xOffset; - int endX = fr.getStringWidth(text.substring(0, selectionEnd)) - xOffset; - Gui.drawRect(3 + startX, y, 3 + endX, y + fr.FONT_HEIGHT, 0xFF00FF00); - fr.drawString(text.substring(selectionStart, selectionEnd), 3 + startX, y, foreground.getRGB()); - } - - // draw cursor - if (cursor != -1) { - if (cursor > text.length()) cursor = text.length(); - int x = fr.getStringWidth(text.substring(0, cursor)) - xOffset; - cursorBlickTicker++; - if (cursorBlickTicker < 10) - Gui.drawRect(3 + x, y, 4 + x, y + fr.FONT_HEIGHT, 0xFFFFFFFF); - if (cursorBlickTicker == 20) cursorBlickTicker = 0; - } - } - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - Rectangle actualField = new Rectangle(1, 3,getBounds().width - 2, getBounds().height - 6); - if (!actualField.contains(relMouseX, relMouseY)) return; - if (!lastAbsClip.contains(absMouseX, absMouseY)) return; - - - - - int relStartT = relMouseX-3; - int offseted = relStartT + xOffset; - - selectionStart = -1; - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - for (int i = 0; i < text.length(); i++) { - int totalWidth = fr.getStringWidth(text.substring(0, i)); - if (offseted < totalWidth) { - cursor = i; - return; - } - } - cursor = text.length(); - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - if (!isFocused) return; - selectionStart = cursor; - selectionEnd = cursor; - - int relStartT = relMouseX-3; - int offseted = relStartT + xOffset; - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - for (int i = 0; i < text.length(); i++) { - int totalWidth = fr.getStringWidth(text.substring(0, i)); - if (offseted < totalWidth) { - if (i < cursor) { - selectionStart = i; - selectionEnd = cursor; - } else { - selectionStart = cursor; - selectionEnd = i; - } - return; - } - } - selectionEnd = text.length(); - if (selectionStart == selectionEnd) { - selectionStart = -1; - } - } - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (!isFocused) return; - if (scrollAmount > 0) { - xOffset += 5; - } else if (scrollAmount < 0){ - xOffset -= 5; - } - if (xOffset < 0) { - xOffset = 0; - } - int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text); - int overflow = getBounds().width - 3 - width; - if (overflow >= 0) { - xOffset = 0; - } else if (width - xOffset + 10 < getBounds().width) { - xOffset = width - getBounds().width+10; - } - } - - @Override - public void keyTyped(char typedChar, int keycode) { - if (!isFocused) return; - - - if (selectionStart == -1) { - if (keycode == 199) { // home - cursor = 0; - return; - } - - if (keycode == 207) { // end - cursor = text.length(); - return; - } - - if (keycode == 203) { // left - cursor--; - if (cursor < 0) cursor = 0; - return; - } - - if (keycode == 205) { // right - cursor ++; - if (cursor > text.length()) cursor = text.length(); - return; - } - - // backspace - if (keycode == 14 && cursor > 0) { - setText0(this.text.substring(0, cursor - 1) + this.text.substring(cursor)); - cursor--; - return; - } - - //del - if (keycode == 211 && cursor < text.length()) { - setText0(this.text.substring(0, cursor) + this.text.substring(cursor+1)); - return; - } - - // paste - boolean shouldPaste = false; - if (keycode == 47) { - if (Minecraft.isRunningOnMac) { // mac - if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { - shouldPaste = true; - } - } else { // literally everything else - if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { - shouldPaste = true; - } - } - } - if (shouldPaste) { - Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); - if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { - try { - Object theText = transferable.getTransferData(DataFlavor.stringFlavor); - setText0( - this.text.substring(0, this.cursor) - + theText - + this.text.substring(this.cursor)); - - cursor += theText.toString().length(); - } catch (UnsupportedFlavorException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return; - } - - // text - if (isPrintableChar(typedChar)) { - setText0( - this.text.substring(0, this.cursor) - + typedChar - + this.text.substring(this.cursor)); - this.cursor++; - return; - } - } else { - if (keycode == 199) { // home - cursor = 0; - selectionStart = -1; - return; - } - - if (keycode == 207) { // end - selectionStart = -1; - cursor = text.length(); - return; - } - - if (keycode == 203) { // left - cursor = selectionStart; - selectionStart = -1; - return; - } - - if (keycode == 205) { // right - cursor = selectionEnd; - selectionStart = -1; - return; - } - - // backspace - if (keycode == 14 && cursor > 0) { - setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); - cursor = selectionStart; - selectionStart = -1; - return; - } - - //del - if (keycode == 211 && cursor < text.length()) { - setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); - cursor = selectionStart; - selectionStart = -1; - return; - } - - // paste - boolean shouldPaste = false; - if (keycode == 47) { - if (Minecraft.isRunningOnMac) { // mac - if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { - shouldPaste = true; - } - } else { // literally everything else - if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { - shouldPaste = true; - } - } - } - if (shouldPaste) { - Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); - if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { - try { - Object theText = transferable.getTransferData(DataFlavor.stringFlavor); - setText0( - this.text.substring(0, this.selectionStart) - + theText - + this.text.substring(this.selectionEnd)); - cursor = this.selectionStart + theText.toString().length(); - } catch (UnsupportedFlavorException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - selectionStart = -1; - } - return; - } - boolean shouldCopy = false; - if (keycode == 46) { - if (Minecraft.isRunningOnMac) { // mac - if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { - shouldCopy = true; - } - } else { // literally everything else - if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { - shouldCopy = true; - } - } - } - if (shouldCopy) { - StringSelection selection = new StringSelection(text.substring(selectionStart, selectionEnd)); - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - clipboard.setContents(selection, selection); - return; - } - - // text - if (isPrintableChar(typedChar)) { - setText0( - this.text.substring(0, this.selectionStart) - + typedChar - + this.text.substring(this.selectionEnd)); - this.cursor = this.selectionStart + 1; - selectionStart = -1; - return; - } - } - } - public boolean isPrintableChar( char c ) { - Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); - return (!Character.isISOControl(c)) && - c != KeyEvent.CHAR_UNDEFINED && - block != null && - block != Character.UnicodeBlock.SPECIALS; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MValue.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MValue.java deleted file mode 100755 index ab568e1c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MValue.java +++ /dev/null @@ -1,63 +0,0 @@ -package kr.syeyoung.dungeonsguide.roomedit.elements; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditOffsetPointSet; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; -public class MValue extends MPanel { - @Getter - private T data; - private ValueEditOffsetPointSet valueEditOffsetPointSet; - private MLabel dataLab; - - @Getter @Setter - private Color hover = Color.gray; - - private List addons; - - public MValue(final T parameter, List addons) { - this.addons = addons; - this.add(this.dataLab = new MLabel() { - @Override - public String getText() { - return data != null ?data.toString() :"-empty-"; - } - }); - this.dataLab.setAlignment(MLabel.Alignment.RIGHT); - - this.data = parameter; - } - - @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 mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (this.getBounds().x > -20 && lastAbsClip.contains(absMouseX, absMouseY)) { - EditingContext.getEditingContext().openGui(new GuiDungeonValueEdit(data, addons)); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setSize(new Dimension(parentWidth, getBounds().height)); - dataLab.setBounds(new Rectangle(0,0,parentWidth, getBounds().height)); - } - - @Override - public void onBoundsUpdate() { - dataLab.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java index 651a892a..f0530cfa 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java @@ -2,8 +2,8 @@ package kr.syeyoung.dungeonsguide.roomedit.gui; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditOffsetPointSet; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.client.Minecraft; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java index c9bdc050..e39b136a 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java @@ -2,9 +2,9 @@ package kr.syeyoung.dungeonsguide.roomedit.gui; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java index d2c9abd9..d37e7c53 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java @@ -1,11 +1,8 @@ package kr.syeyoung.dungeonsguide.roomedit.gui; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MTabbedPane; -import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MTabbedPane; import kr.syeyoung.dungeonsguide.roomedit.panes.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java index 50269853..74bffd78 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java @@ -2,10 +2,9 @@ package kr.syeyoung.dungeonsguide.roomedit.gui; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java index f20709b9..3644f425 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java @@ -3,14 +3,12 @@ package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonBreakableWall; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.init.Blocks; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDoor.java index 506b7e8a..aa9684ba 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDoor.java @@ -4,9 +4,9 @@ import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDoor; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.utils.TextUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java index 4c208068..f9c0e91a 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java @@ -2,11 +2,10 @@ package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonLever; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayLever; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.utils.TextUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java index 31b2c6b5..7629360e 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java @@ -2,12 +2,11 @@ package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDoor; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayDoor; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.utils.TextUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java index 84bba521..ec1702e5 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java @@ -3,12 +3,12 @@ package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayLever; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; -import kr.syeyoung.dungeonsguide.roomedit.elements.MValue; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.gui.elements.MTextField; +import kr.syeyoung.dungeonsguide.gui.elements.MValue; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.utils.TextUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java index 03c2ae73..f52c8b69 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java @@ -3,12 +3,12 @@ package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonPressurePlate; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; -import kr.syeyoung.dungeonsguide.roomedit.elements.MValue; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.gui.elements.MTextField; +import kr.syeyoung.dungeonsguide.gui.elements.MValue; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.utils.TextUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java index bc153f10..eb8349c4 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java @@ -3,9 +3,9 @@ package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.utils.TextUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java index 5f4f52fc..205c5431 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java @@ -1,18 +1,14 @@ package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonTomb; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.util.BlockPos; import java.awt.*; import java.util.Arrays; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java index 80e74839..60e4995a 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java @@ -1,20 +1,12 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; -import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.*; import java.awt.*; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Set; public class ActionDisplayPane extends MPanel { private DungeonRoom dungeonRoom; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java index 13d636ea..b85f9060 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java @@ -3,20 +3,12 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; import kr.syeyoung.dungeonsguide.dungeon.actions.Action; import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; +import kr.syeyoung.dungeonsguide.gui.MPanel; 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.client.renderer.vertex.VertexFormat; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import org.lwjgl.opengl.GL11; import java.awt.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/DynamicEditor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/DynamicEditor.java index f1b78cb2..c8a1ed9c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/DynamicEditor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/DynamicEditor.java @@ -1,7 +1,6 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MParameter; +import kr.syeyoung.dungeonsguide.gui.elements.MParameter; import java.util.List; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java index 06cfca2e..11e1982c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java @@ -4,8 +4,8 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -16,16 +16,11 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; -import scala.collection.immutable.List; import java.awt.*; -import java.io.DataOutputStream; import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; import java.util.ArrayList; import java.util.UUID; -import java.util.zip.GZIPOutputStream; public class GeneralEditPane extends MPanel { private DungeonRoom dungeonRoom; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java index 04747487..9ea8cf79 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java @@ -2,10 +2,10 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MParameter; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MParameter; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java index ebffa29d..86739f46 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java @@ -1,13 +1,12 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import net.minecraft.block.Block; 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.item.Item; import net.minecraft.item.ItemStack; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java index 7188c8a7..2daaf265 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java @@ -3,7 +3,7 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.utils.ArrayUtils; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoommatchingPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoommatchingPane.java index 5369f40a..1bb143ef 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoommatchingPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoommatchingPane.java @@ -1,11 +1,9 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MTextField; import java.awt.*; import java.util.UUID; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/SecretEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/SecretEditPane.java index 84c36aab..10a40013 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/SecretEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/SecretEditPane.java @@ -3,10 +3,10 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MParameter; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MParameter; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java index 22b0fe71..b904c039 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java @@ -1,11 +1,11 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MColor; -import kr.syeyoung.dungeonsguide.roomedit.elements.MFloatSelectionButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.gui.elements.MColor; +import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; +import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java index 5954d857..b485986c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java @@ -1,10 +1,10 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.roomedit.elements.MStringSelectionButton; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton; import java.awt.*; import java.util.Arrays; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java index 52b0bcca..c39c2179 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java @@ -1,9 +1,8 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; -import net.minecraft.client.gui.Gui; +import kr.syeyoung.dungeonsguide.gui.elements.*; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java index 0e263561..c5d23053 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java @@ -1,11 +1,10 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MFloatSelectionButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MIntegerSelectionButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; import java.awt.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java index 0dbeeb24..4d61cdd6 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java @@ -1,11 +1,10 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MIntegerSelectionButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; +import kr.syeyoung.dungeonsguide.gui.elements.MIntegerSelectionButton; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; import java.awt.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java index 19b90527..3d121493 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java @@ -2,9 +2,9 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java index 1f732cd3..bf26c3ea 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java @@ -3,10 +3,10 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MValue; +import kr.syeyoung.dungeonsguide.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.gui.elements.MValue; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Getter; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java index 2ec869e1..f978d845 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java @@ -1,10 +1,10 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; -import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; +import kr.syeyoung.dungeonsguide.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.gui.elements.MTextField; import java.awt.*; -- cgit