aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java12
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java9
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java101
6 files changed, 121 insertions, 17 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
index c64d15f1..626b75b4 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
@@ -14,7 +14,7 @@ public class RoomMatcher {
@Getter
private DungeonRoomInfo match;
@Getter
- private int rotation;
+ private int rotation; // how much the "found room" has to rotate to match the given dungeon room info. !
private boolean triedMatch = false;
public RoomMatcher(DungeonRoom dungeonRoom) {
@@ -75,17 +75,17 @@ public class RoomMatcher {
int minX = dungeonRoom.getMin().getX();
int minZ = dungeonRoom.getMin().getZ();
int y = dungeonRoom.getMin().getY();
- int widthX = maxX - minX;
- int heightZ = maxZ - minZ;
- int[][] data = new int[dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 1][dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() +1];
+ int widthX = maxX - minX + 2;
+ int heightZ = maxZ - minZ + 2;
+ int[][] data = new int[dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() +2][dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 2];
for (int z = 0; z < data.length; z++) {
for (int x = 0; x < data[0].length; x++) {
- if (!(offset <= x && widthX - offset >= x && offset <= z && heightZ - offset >= z)) {
+ if (!(offset <= x && widthX - offset > x && offset <= z && heightZ - offset > z)) {
data[z][x] = -1;
continue;
}
- if (!(dungeonRoom.canAccessRelative(x + offset, z + offset) && dungeonRoom.canAccessRelative(x - offset, z - offset))) {
+ if (!(dungeonRoom.canAccessRelative(x + offset - 1, z + offset - 1) && dungeonRoom.canAccessRelative(x - offset, z - offset))) {
data[z][x] = -1;
continue;
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
index e41569d8..544dc03e 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
@@ -6,6 +6,7 @@ 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.roomedit.panes.GeneralEditPane;
+import kr.syeyoung.dungeonsguide.roomedit.panes.RoomDataDisplayPane;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
@@ -31,15 +32,9 @@ public class GuiDungeonRoomEdit extends GuiScreen {
tabbedPane.addTab("General", new GeneralEditPane(room));
+ tabbedPane.addTab("Room Match", new RoomDataDisplayPane(room));
- MButton mButton = new MButton();
- mButton.setText("this is awesome");
- mButton.setBounds(new Rectangle(30,20,50,10));
- tabbedPane.addTab("button-o", mButton);
- MTextField mTextField = new MTextField();
- mTextField.setBounds(new Rectangle(30,20,100,30));
- tabbedPane.addTab("text-o", mTextField);
}
@Override
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java
index aa54e0bd..fea3706f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java
@@ -56,6 +56,11 @@ public class MPanel {
for (MPanel childComponent : childComponents) {
childComponent.resize0(bounds.width, bounds.height);
}
+ onBoundsUpdate();
+ }
+
+ public void onBoundsUpdate() {
+
}
public void add(MPanel child) {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
index 65d23bf2..ba62e8ef 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
@@ -23,9 +23,7 @@ public class MLabelAndElement extends MPanel {
}
@Override
- public void setBounds(Rectangle bounds) {
- super.setBounds(bounds);
-
+ public void onBoundsUpdate() {
label.setBounds(new Rectangle(0,0,bounds.width / 3, bounds.height));
element.setBounds(new Rectangle(bounds.width / 3,0,bounds.width / 3 * 2, bounds.height));
}
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 d8345eb6..59620ff0 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java
@@ -88,7 +88,12 @@ System.out.println("building");
@Override
public void resize(int parentWidth, int parentHeight) {
- save.setBounds(new Rectangle(0,100,bounds.width, 20));
this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10));
}
+
+ @Override
+ public void onBoundsUpdate() {
+ if (save != null)
+ save.setBounds(new Rectangle(0,100,bounds.width, 20));
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java
new file mode 100644
index 00000000..f390f969
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java
@@ -0,0 +1,101 @@
+package kr.syeyoung.dungeonsguide.roomedit.panes;
+
+import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.roomedit.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;
+
+import java.awt.*;
+
+public class RoomDataDisplayPane extends MPanel {
+
+ private int offsetX = 0;
+ private int offsetY = 0;
+
+ private int selectedX = -1;
+ private int selectedY = -1;
+
+ private DungeonRoom dungeonRoom;
+ public RoomDataDisplayPane(DungeonRoom dungeonRoom) {
+ this.dungeonRoom = dungeonRoom;
+ }
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) {
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ int[][] blocks = dungeonRoom.getDungeonRoomInfo().getBlocks();
+ // draw Axis;
+ Gui.drawRect(0,0,10,10,0x77777777);
+ clip(sr, clip.x + 10, clip.y, clip.width - 10, 10);
+ Gui.drawRect(0,0,bounds.width, bounds.height, 0x77777777);
+ for (int x = 0; x < blocks[0].length; x++) {
+ fr.drawString(x+"", x * 16 +10 + offsetX, 0, 0xFFFFFFFF);
+ }
+ clip(sr, clip.x, clip.y +10, 10, clip.height-10);
+ Gui.drawRect(0,0,bounds.width, bounds.height, 0x77777777);
+ for (int z = 0; z < blocks.length; z++) {
+ fr.drawString(z+"", 2, z * 16 + 10 + offsetY, 0xFFFFFFFF);
+ }
+
+ int hoverX = (relMousex0 - offsetX - 10) / 16;
+ int hoverY = (relMousey0 - offsetY - 10) / 16;
+ // draw Content
+ clip(sr, clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10);
+ for (int z = 0; z < blocks.length; z++) {
+ for (int x = 0; x < blocks[z].length; x++) {
+ int data = blocks[z][x];
+ if (z == selectedY && x == selectedX){
+ Gui.drawRect(x *16 +10+offsetX, z *16 +10 + offsetY, x *16 +26 +offsetX, z *16 +26 + offsetY, 0xAA707070);
+ } else if (z == hoverY && x == hoverX) {
+ Gui.drawRect(x *16 +10+offsetX, z *16 +10 + offsetY, x *16 +26 +offsetX, z *16 +26 + offsetY, 0xAA505050);
+ }
+
+
+ if (data == -1) fr.drawString("X", x *16 +10 + offsetX, z *16 +10 + offsetY,0xFFFFFF);
+ else drawItemStack(new ItemStack(Item.getItemFromBlock(Block.getBlockById(data)), 1), x * 16 +10 + offsetX, z *16 +10 + offsetY);
+ }
+ }
+
+ }
+ private void drawItemStack(ItemStack stack, int x, int y)
+ {
+ Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, x, y);
+ }
+
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10));
+ }
+
+ private int lastX;
+ private int lastY;
+ @Override
+ protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ lastX = absMouseX;
+ lastY = absMouseY;
+
+ if (new Rectangle(new Point(0,0),getSize()).contains(relMouseX, relMouseY)) {
+ selectedX = (relMouseX - offsetX - 10) / 16;
+ selectedY = (relMouseY - offsetY - 10) / 16;
+ }
+ }
+
+ @Override
+ protected void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {
+ int dX = absMouseX - lastX;
+ int dY = absMouseY - lastY;
+ offsetX += dX;
+ offsetY += dY;
+ lastX = absMouseX;
+ lastY = absMouseY;
+ }
+}