From 75aa91678c2dfdf844ecfcbb68bcf9389028ca4e Mon Sep 17 00:00:00 2001 From: syeyoung <42869671+cyoung06@users.noreply.github.com> Date: Thu, 10 Dec 2020 22:46:37 +0900 Subject: secretz --- .../dungeonsguide/roomedit/elements/MValue.java | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MValue.java (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MValue.java') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MValue.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MValue.java new file mode 100644 index 00000000..9c733fd6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MValue.java @@ -0,0 +1,64 @@ +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 scala.actors.threadpool.Arrays; + +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),bounds.getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,bounds.width, bounds.height, hover.getRGB()); + } + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (this.bounds.x > -20 && new Rectangle(new Point(0,0),bounds.getSize()).contains(relMouseX, relMouseY)) { + EditingContext.getEditingContext().openGui(new GuiDungeonValueEdit(data, addons)); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, bounds.height)); + dataLab.setBounds(new Rectangle(0,0,parentWidth, bounds.height)); + } + + @Override + public void onBoundsUpdate() { + dataLab.setBounds(new Rectangle(0,0,bounds.width, bounds.height)); + } +} -- cgit