diff options
author | syeyoung <cyong06@naver.com> | 2021-02-04 21:55:02 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-04 21:55:02 +0900 |
commit | c37bda238c5072fa50dfa2d87aa137e1bdf5c4ac (patch) | |
tree | 5a276b3db53c9275cb0da74cf8aed0cfa0e79491 /src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements | |
parent | 809f6b70870ec2a0fd4e4abfd24539e30d8db11b (diff) | |
download | Skyblock-Dungeons-Guide-c37bda238c5072fa50dfa2d87aa137e1bdf5c4ac.tar.gz Skyblock-Dungeons-Guide-c37bda238c5072fa50dfa2d87aa137e1bdf5c4ac.tar.bz2 Skyblock-Dungeons-Guide-c37bda238c5072fa50dfa2d87aa137e1bdf5c4ac.zip |
move guis
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements')
12 files changed, 0 insertions, 1020 deletions
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<String> possible; - private int selectedIndex; - - private MButton dec; - private MButton inc; - private MLabel selected; - - @Getter - @Setter - private Runnable onUpdate; - - public MStringSelectionButton(final List<String> 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<String, MPanel> tabs = new HashMap<String, MPanel>(); - private Map<String, MTabButton> buttons = new HashMap<String, MTabButton>(); - - @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<MPanel> getChildComponents() { - ArrayList<MPanel> dynamic = new ArrayList<MPanel>(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<T> extends MPanel { - @Getter - private T data; - private ValueEditOffsetPointSet valueEditOffsetPointSet; - private MLabel dataLab; - - @Getter @Setter - private Color hover = Color.gray; - - private List<MPanel> addons; - - public MValue(final T parameter, List<MPanel> 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)); - } -} |