aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/EventListener.java18
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MOffsetPoint.java64
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonOffsetPointEdit.java164
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java13
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java178
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java71
15 files changed, 470 insertions, 83 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
index 1a5731fd..195c15bb 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
@@ -5,6 +5,9 @@ import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo;
import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonOffsetPointEdit;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit;
import kr.syeyoung.dungeonsguide.utils.MapUtils;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.client.Minecraft;
@@ -106,6 +109,21 @@ public class EventListener {
RenderUtils.renderDoor(door, renderWorldLastEvent.partialTicks);
}
}
+
+ if (EditingContext.getEditingContext() != null) {
+ GuiScreen guiScreen = EditingContext.getEditingContext().getCurrent();
+ if (guiScreen instanceof GuiDungeonParameterEdit) {
+ ValueEdit valueEdit = ((GuiDungeonParameterEdit) guiScreen).getValueEdit();
+ if (valueEdit != null) {
+ valueEdit.renderWorld(renderWorldLastEvent.partialTicks);
+ }
+ } else if (guiScreen instanceof GuiDungeonOffsetPointEdit) {
+ ValueEdit valueEdit = ((GuiDungeonOffsetPointEdit) guiScreen).getValueEdit();
+ if (valueEdit != null) {
+ valueEdit.renderWorld(renderWorldLastEvent.partialTicks);
+ }
+ }
+ }
}
@SubscribeEvent
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java
index 05bc7138..ecb3b268 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java
@@ -21,7 +21,7 @@ public class OffsetPoint implements Cloneable {
}
public void setPosInWorld(DungeonRoom dungeonRoom, BlockPos pos) {
- Vector2d vector2d = new Vector2d(pos.getX(), pos.getZ());
+ Vector2d vector2d = new Vector2d(pos.getX() - dungeonRoom.getMin().getX(), pos.getZ() - dungeonRoom.getMin().getZ());
for (int i = 0; i < dungeonRoom.getRoomMatcher().getRotation(); i++)
vector2d = VectorUtils.rotateClockwise(vector2d);
@@ -30,7 +30,7 @@ public class OffsetPoint implements Cloneable {
this.x = (int) vector2d.x;
this.z = (int) vector2d.y;
- this.y = dungeonRoom.getMin().getY() + pos.getY();
+ this.y = pos.getY()-dungeonRoom.getMin().getY();
}
public BlockPos toRotatedRelBlockPos(DungeonRoom dungeonRoom) {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java
index a381ac49..c33f7af8 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java
@@ -6,6 +6,15 @@ import java.util.ArrayList;
import java.util.List;
@Data
-public class OffsetPointSet {
+public class OffsetPointSet implements Cloneable{
private List<OffsetPoint> offsetPointList = new ArrayList<OffsetPoint>();
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ OffsetPointSet ops = new OffsetPointSet();
+ for (OffsetPoint offsetPoint : offsetPointList) {
+ ops.offsetPointList.add((OffsetPoint) offsetPoint.clone());
+ }
+ return ops;
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
index 2b56b139..c6afb59f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
@@ -108,21 +108,21 @@ public class DungeonRoom {
public Block getRelativeBlockAt(int x, int y, int z) {
// validate x y z's
if (canAccessRelative(x,z)) {
- BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getZ(),min.getZ());
+ BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getY(),min.getZ());
return this.context.getWorld().getChunkFromBlockCoords(pos).getBlock(pos);
}
return null;
}
public BlockPos getRelativeBlockPosAt(int x, int y, int z) {
- BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getZ(),min.getZ());
+ BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getY(),min.getZ());
return pos;
}
public int getRelativeBlockDataAt(int x, int y, int z) {
// validate x y z's
if (canAccessRelative(x,z)) {
- BlockPos pos = new BlockPos(x,y,z).add(min.getX(),0,min.getZ());
+ BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getY(),min.getZ());
return this.context.getWorld().getChunkFromBlockCoords(pos).getBlockMetadata(pos);
}
return -1;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MOffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MOffsetPoint.java
new file mode 100644
index 00000000..3143f42a
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MOffsetPoint.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.Parameter;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonOffsetPointEdit;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit;
+import kr.syeyoung.dungeonsguide.roomedit.panes.ProcessorParameterEditPane;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditOffsetPointSet;
+import lombok.Getter;
+import lombok.Setter;
+import net.minecraft.client.gui.Gui;
+
+import java.awt.*;
+
+public class MOffsetPoint extends MPanel {
+ @Getter
+ private OffsetPoint data;
+ private ValueEditOffsetPointSet valueEditOffsetPointSet;
+ private MLabel dataLab;
+
+ @Getter @Setter
+ private Color hover = Color.gray;
+
+
+ public MOffsetPoint(ValueEditOffsetPointSet valueEditOffsetPointSet, final OffsetPoint parameter) {
+ this.valueEditOffsetPointSet = valueEditOffsetPointSet;
+ 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 GuiDungeonOffsetPointEdit(valueEditOffsetPointSet, data));
+ }
+ }
+
+ @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));
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonOffsetPointEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonOffsetPointEdit.java
new file mode 100644
index 00000000..f78504fd
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonOffsetPointEdit.java
@@ -0,0 +1,164 @@
+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.Parameter;
+import kr.syeyoung.dungeonsguide.roomedit.elements.MButton;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditOffsetPointSet;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry;
+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.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+import java.io.IOException;
+
+public class GuiDungeonOffsetPointEdit extends GuiScreen {
+ private MPanel mainPanel = new MPanel();
+ @Getter
+ private OffsetPoint offsetPoint;
+ private MButton save;
+ private MButton delete;
+
+ @Getter
+ private ValueEdit valueEdit;
+
+ public GuiDungeonOffsetPointEdit(final ValueEditOffsetPointSet valueEditOffsetPointSet, final OffsetPoint offsetPoint) {
+ this.offsetPoint = offsetPoint;
+ {
+ MPanel thing = (MPanel) ValueEditRegistry.getValueEditMap(OffsetPoint.class.getName()).createValueEdit(new Parameter(null, null, null) {
+ @Override
+ public Object getPreviousData() {
+ return offsetPoint;
+ }
+
+ @Override
+ public Object getNewData() {
+ return offsetPoint;
+ }
+
+ @Override
+ public String getName() {
+ return "";
+ }
+
+ @Override
+ public void setName(String name) {
+ return;
+ }
+
+ @Override
+ public void setPreviousData(Object previousData) {
+ return;
+ }
+
+ @Override
+ public void setNewData(Object newData) {
+ return;
+ }
+ });
+ valueEdit = (ValueEdit) thing;
+ MPanel wrapper = new MPanel() {
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ setBounds(new Rectangle(0, 0, parentWidth,parentHeight - 20));
+ }
+ };
+ wrapper.add(thing);
+ mainPanel.add(wrapper);
+ }
+ {
+ delete = new MButton() {
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ setBounds(new Rectangle(0,parentHeight - 20, parentWidth / 2, 20));
+ }
+ };
+ delete.setText("Delete");
+ delete.setBackgroundColor(Color.red);
+ delete.setOnActionPerformed(new Runnable() {
+ @Override
+ public void run() {
+ valueEditOffsetPointSet.delete(offsetPoint);
+ EditingContext.getEditingContext().goBack();
+ }
+ });
+
+ save = new MButton(){
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ setBounds(new Rectangle(parentWidth / 2,parentHeight - 20, parentWidth / 2, 20));
+ }
+ };
+ save.setText("Go back");
+ save.setBackgroundColor(Color.green);
+ save.setOnActionPerformed(new Runnable() {
+ @Override
+ public void run() {
+ EditingContext.getEditingContext().goBack();
+ }
+ });
+ mainPanel.add(delete);
+ mainPanel.add(save);
+ }
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+ // update bounds
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ mainPanel.setBounds(new Rectangle(10, Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),200,300));
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GL11.glPushMatrix();
+ GlStateManager.pushAttrib();
+ mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
+ GlStateManager.popAttrib();
+ GL11.glPopMatrix();
+ }
+
+ @Override
+ public void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+ mainPanel.keyTyped0(typedChar, keyCode);
+ }
+
+ @Override
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
+ }
+
+ @Override
+ public void mouseReleased(int mouseX, int mouseY, int state) {
+ mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
+ }
+
+ @Override
+ public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
+ }
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ super.handleMouseInput();
+
+ int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
+ int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
+
+ int wheel = Mouse.getDWheel();
+ if (wheel != 0) {
+ mainPanel.mouseScrolled0(i, j,i,j, wheel);
+ }
+ }
+}
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 4798e59d..26ebbe5b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java
@@ -13,6 +13,7 @@ import kr.syeyoung.dungeonsguide.roomedit.panes.RoomDataDisplayPane;
import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit;
import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator;
import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry;
+import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
@@ -38,6 +39,9 @@ public class GuiDungeonParameterEdit extends GuiScreen {
private MButton save;
private MButton delete;
+ @Getter
+ private ValueEdit valueEdit;
+
public GuiDungeonParameterEdit(final MParameter parameter2, final ProcessorParameterEditPane processorParameterEditPane) {
dungeonRoom = EditingContext.getEditingContext().getRoom();
mainPanel.setBackgroundColor(new Color(17, 17, 17, 179));
@@ -141,6 +145,9 @@ public class GuiDungeonParameterEdit extends GuiScreen {
valueEdit2.setText("No Value Edit");
valueEdit2.setBounds(new Rectangle(0,0,150,20));
valueEdit = valueEdit2;
+ this.valueEdit = null;
+ } else{
+ this.valueEdit = (ValueEdit) valueEdit;
}
valueEdit.resize0(currentValueEdit.getBounds().width, currentValueEdit.getBounds().height);
currentValueEdit.add(valueEdit);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java
index dcff4ebd..5025132d 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java
@@ -4,4 +4,6 @@ import kr.syeyoung.dungeonsguide.roomedit.Parameter;
public interface ValueEdit<T extends Object> {
public void setParameter(Parameter parameter);
+
+ public void renderWorld(float partialTicks);
}
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 7a9b4259..27e4d21d 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java
@@ -55,6 +55,11 @@ public class ValueEditBoolean extends MPanel implements ValueEdit<Boolean> {
}
@Override
+ public void renderWorld(float partialTicks) {
+
+ }
+
+ @Override
public void resize(int parentWidth, int parentHeight) {
this.setBounds(new Rectangle(0,0,parentWidth, parentHeight));
}
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 7806cafc..63ccfd64 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java
@@ -13,6 +13,10 @@ public class ValueEditInteger extends MPanel implements ValueEdit<Integer> {
private Parameter parameter;
+ @Override
+ public void renderWorld(float partialTicks) {
+
+ }
public ValueEditInteger(final Parameter parameter2) {
this.parameter = parameter2;
{
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 c91e0bea..7e603dc5 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java
@@ -15,6 +15,11 @@ import java.awt.*;
public class ValueEditOffsetPoint extends MPanel implements ValueEdit<String> {
private Parameter parameter;
+ @Override
+ public void renderWorld(float partialTicks) {
+ RenderUtils.highlightBlock(((OffsetPoint)parameter.getPreviousData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(255,0,0,150), partialTicks);
+ RenderUtils.highlightBlock(((OffsetPoint)parameter.getNewData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,0,150), partialTicks);
+ }
public ValueEditOffsetPoint(final Parameter parameter2) {
this.parameter = parameter2;
@@ -59,7 +64,7 @@ public class ValueEditOffsetPoint extends MPanel implements ValueEdit<String> {
textField.setOnUpdate(new Runnable() {
@Override
public void run() {
- ((OffsetPoint) parameter.getNewData()).setX(textField.getData());
+ ((OffsetPoint) parameter.getNewData()).setZ(textField.getData());
}
});
MLabelAndElement mLabelAndElement = new MLabelAndElement("z",textField);
@@ -82,12 +87,6 @@ public class ValueEditOffsetPoint extends MPanel implements ValueEdit<String> {
}
@Override
- public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
- RenderUtils.highlightBlock2(((OffsetPoint)parameter.getPreviousData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(255,0,0,150), partialTicks);
- RenderUtils.highlightBlock2(((OffsetPoint)parameter.getNewData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,0,150), partialTicks);
- }
-
- @Override
public void onBoundsUpdate() {
for (MPanel panel :getChildComponents()){
panel.setSize(new Dimension(bounds.width, 20));
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java
new file mode 100644
index 00000000..a701894f
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java
@@ -0,0 +1,178 @@
+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.roomedit.Parameter;
+import kr.syeyoung.dungeonsguide.roomedit.elements.MButton;
+import kr.syeyoung.dungeonsguide.roomedit.elements.MOffsetPoint;
+import kr.syeyoung.dungeonsguide.roomedit.elements.MParameter;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+import lombok.Getter;
+import net.minecraft.client.Minecraft;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+
+public class ValueEditOffsetPointSet extends MPanel implements ValueEdit<OffsetPointSet> {
+ private Parameter parameter;
+
+ // scroll pane
+ // just create
+ // add set
+
+ private MPanel scroll;
+ @Getter
+ private List<MPanel> MParameters = new ArrayList<MPanel>();
+
+ private MButton add, addSet;
+
+ public void delete(OffsetPoint offsetPoint) {
+ ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().remove(offsetPoint);
+ Iterator<MPanel> iterator = MParameters.iterator();
+ while (iterator.hasNext()) {
+ MOffsetPoint panel = (MOffsetPoint) iterator.next();
+ if (panel.getData() == offsetPoint) {
+ iterator.remove();
+ break;
+ }
+ }
+
+ }
+
+ public ValueEditOffsetPointSet(final Parameter parameter2) {
+ this.parameter = parameter2;
+ {
+ scroll = new MPanel() {
+ private int offsetY = 0;
+
+ @Override
+ public List<MPanel> getChildComponents() {
+ return MParameters;
+ }
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+ int heights = 0;
+ for (MPanel panel:getChildComponents()) {
+ panel.setPosition(new Point(0, -offsetY + heights));
+ heights += panel.getBounds().height;
+ }
+ }
+
+ @Override
+ public void onBoundsUpdate() {
+ for (MPanel panel :getChildComponents()){
+ panel.setSize(new Dimension(bounds.width, 20));
+ }
+ }
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10));
+ }
+
+ @Override
+ public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
+ if (new Rectangle(new Point(0,0), getSize()).contains(relMouseX0, relMouseY0)) {
+ if (scrollAmount >0) offsetY += 20;
+ else if (scrollAmount < 0) offsetY -= 20;
+ if (offsetY <0) offsetY = 0;
+ }
+ }
+ };
+ scroll.setBounds(new Rectangle(0,0,bounds.width, bounds.height-20));
+ add(scroll);
+ }
+
+ {
+ add = new MButton() {
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ setBounds(new Rectangle(0,parentHeight - 20, parentWidth / 2, 20));
+ }
+ };
+ add.setText("Add");
+ add.setBackgroundColor(Color.green);
+ add.setOnActionPerformed(new Runnable() {
+ @Override
+ public void run() {
+ OffsetPoint offsetPoint = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition());
+ MParameters.add(new MOffsetPoint(ValueEditOffsetPointSet.this, offsetPoint));
+ ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().add(offsetPoint);
+ }
+ });
+
+ addSet = new MButton(){
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ setBounds(new Rectangle(parentWidth / 2,parentHeight - 20, parentWidth / 2, 20));
+ }
+ };
+ addSet.setText("Add Set");
+ addSet.setBackgroundColor(Color.cyan);
+ addSet.setOnActionPerformed(new Runnable() {
+ @Override
+ public void run() {
+ //open gui
+ }
+ });
+ add(add);
+ add(addSet);
+ }
+ for (OffsetPoint offsetPoint : ((OffsetPointSet)parameter.getNewData()).getOffsetPointList()) {
+ MParameters.add(new MOffsetPoint(this, offsetPoint));
+ }
+ }
+
+ @Override
+ public void onBoundsUpdate() {
+ scroll.setBounds(new Rectangle(0,0,bounds.width, bounds.height-20));
+ add.setBounds(new Rectangle(0,bounds.height-20,bounds.width / 2, 20));
+ addSet.setBounds(new Rectangle(bounds.width / 2,bounds.height-20,bounds.width / 2, 20));
+ }
+
+ @Override
+ public void setParameter(Parameter parameter) {
+ this.parameter = parameter;
+ }
+
+ @Override
+ public void renderWorld(float partialTicks) {
+ for (OffsetPoint offsetPoint :((OffsetPointSet)parameter.getNewData()).getOffsetPointList()) {
+ RenderUtils.highlightBlock(offsetPoint.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,255,50), partialTicks);
+ }
+ }
+
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ this.setBounds(new Rectangle(0,0,parentWidth, parentHeight));
+ }
+
+ public static class Generator implements ValueEditCreator<ValueEditOffsetPointSet> {
+
+ @Override
+ public ValueEditOffsetPointSet createValueEdit(Parameter parameter) {
+ return new ValueEditOffsetPointSet(parameter);
+ }
+
+ @Override
+ public Object createDefaultValue(Parameter parameter) {
+ return new OffsetPointSet();
+ }
+
+ @Override
+ public Object cloneObj(Object object) {
+ try {
+ return ((OffsetPointSet)object).clone();
+ } catch (CloneNotSupportedException e) {
+ e.printStackTrace();
+ }
+ assert false;
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java
index 5fd86b22..9ceef61e 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java
@@ -1,6 +1,7 @@
package kr.syeyoung.dungeonsguide.roomedit.valueedit;
import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
+import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet;
import java.util.ArrayList;
import java.util.HashMap;
@@ -24,5 +25,6 @@ public class ValueEditRegistry {
valueEditMap.put(Boolean.class.getName(), new ValueEditBoolean.Generator());
valueEditMap.put(Integer.class.getName(), new ValueEditInteger.Generator());
valueEditMap.put(OffsetPoint.class.getName(), new ValueEditOffsetPoint.Generator());
+ valueEditMap.put(OffsetPointSet.class.getName(), new ValueEditOffsetPointSet.Generator());
}
}
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 96bb9a4f..abdda81f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java
@@ -11,6 +11,10 @@ import java.awt.*;
public class ValueEditString extends MPanel implements ValueEdit<String> {
private Parameter parameter;
+ @Override
+ public void renderWorld(float partialTicks) {
+
+ }
public ValueEditString(Parameter parameter2) {
this.parameter = parameter2;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
index bc741e04..c985cf42 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
@@ -111,7 +111,7 @@ public class RenderUtils {
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(false);
- GL11.glColor3ub((byte)c.getRed(), (byte)c.getGreen(), (byte)c.getBlue());
+ GL11.glColor4ub((byte)c.getRed(), (byte)c.getGreen(), (byte)c.getBlue(), (byte)c.getAlpha());
GL11.glTranslated(blockpos.getX(), blockpos.getY(), blockpos.getZ());
@@ -163,75 +163,6 @@ public class RenderUtils {
//...
}
- public static void highlightBlock2(BlockPos blockpos, Color c, float partialTicks) {
-
- RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
-
- Vector3f renderPos = getRenderPos(blockpos.getX(), blockpos.getY(), blockpos.getZ(), partialTicks);
-
-
- GL11.glPushMatrix();
- GlStateManager.pushAttrib();
- GL11.glTranslatef(renderPos.x, renderPos.y, renderPos.z);
- GL11.glRotatef(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f);
- GL11.glRotatef(renderManager.playerViewX, 1.0f, 0.0f, 0.0f);
- GL11.glDisable(GL11.GL_LIGHTING);
- GL11.glDepthMask(false);
- GL11.glDisable(GL11.GL_DEPTH_TEST);
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.disableTexture2D();
-
- GL11.glColor4ub((byte)c.getRed(), (byte)c.getGreen(), (byte)c.getBlue(), (byte)c.getAlpha());
-
- GL11.glBegin(GL11.GL_QUADS);
- GL11.glVertex3d(0, 0, 0);
- GL11.glVertex3d(0, 0, 1);
- GL11.glVertex3d(0, 1, 1);
- GL11.glVertex3d(0, 1, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT
-
- GL11.glVertex3d(1, 0, 1);
- GL11.glVertex3d(1, 0, 0);
- GL11.glVertex3d(1, 1, 0);
- GL11.glVertex3d(1, 1, 1);
-
- GL11.glVertex3d(0, 1, 1);
- GL11.glVertex3d(0, 0, 1);
- GL11.glVertex3d(1, 0, 1);
- GL11.glVertex3d(1, 1, 1); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT
-
- GL11.glVertex3d(0, 0, 0);
- GL11.glVertex3d(0, 1, 0);
- GL11.glVertex3d(1, 1, 0);
- GL11.glVertex3d(1, 0, 0);
-
- GL11.glVertex3d(0,1,0);
- GL11.glVertex3d(0,1,1);
- GL11.glVertex3d(1,1,1);
- GL11.glVertex3d(1,1,0);
-
- GL11.glVertex3d(0,0,1);
- GL11.glVertex3d(0,0,0);
- GL11.glVertex3d(1,0,0);
- GL11.glVertex3d(1,0,1);
-
-
-
- GL11.glEnd();
-
-
- GL11.glEnable(GL11.GL_DEPTH_TEST);
- GL11.glDepthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
- GlStateManager.enableLighting();
- GlStateManager.popMatrix();
- GlStateManager.popAttrib();
-
-
-//...
-
- }
public static void drawTextAtWorld(String text, float x, float y, float z, int color, float scale, boolean increase, boolean renderBlackBox, float partialTicks) {
float lScale = scale;