aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-26 12:09:38 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-26 12:09:38 +0900
commit4ada6858039f3ca2f5de3c81df8c78f481d897d4 (patch)
treeec8438ec41929552d74d9630525ad8fcd62594d4 /src
parent49b083afffdf24f0bcd637909d15b88d9ed272b8 (diff)
downloadSkyblock-Dungeons-Guide-4ada6858039f3ca2f5de3c81df8c78f481d897d4.tar.gz
Skyblock-Dungeons-Guide-4ada6858039f3ca2f5de3c81df8c78f481d897d4.tar.bz2
Skyblock-Dungeons-Guide-4ada6858039f3ca2f5de3c81df8c78f481d897d4.zip
value edit stuff
Diffstat (limited to 'src')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandSaveData.java13
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java20
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java9
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabButton.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java8
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java196
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java)11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java17
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ActuallyClonable.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java15
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java23
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java75
22 files changed, 385 insertions, 54 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java
index 733c3ba5..083d6295 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java
@@ -5,14 +5,10 @@ import kr.syeyoung.dungeonsguide.SkyblockStatus;
import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
-import kr.syeyoung.dungeonsguide.roomedit.GuiDungeonRoomEdit;
-import kr.syeyoung.dungeonsguide.utils.MapUtils;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.command.CommandBase;
-import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandSaveData.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandSaveData.java
index 56d42d66..1cdfc791 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandSaveData.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandSaveData.java
@@ -1,22 +1,9 @@
package kr.syeyoung.dungeonsguide.commands;
import kr.syeyoung.dungeonsguide.DungeonsGuide;
-import kr.syeyoung.dungeonsguide.SkyblockStatus;
-import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
-import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry;
-import kr.syeyoung.dungeonsguide.roomedit.GuiDungeonRoomEdit;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.client.gui.GuiScreen;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
-import net.minecraft.util.ChatComponentText;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent;
-import net.minecraftforge.fml.relauncher.Side;
-
-import java.awt.*;
public class CommandSaveData extends CommandBase {
@Override
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java
index abe3e263..b8891a19 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java
@@ -1,5 +1,6 @@
package kr.syeyoung.dungeonsguide.dungeon.data;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ActuallyClonable;
import lombok.Getter;
import lombok.Setter;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java
index 5b3e119c..d5586ce3 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java
@@ -136,7 +136,7 @@ public class MPanel {
public void resize(int parentWidth, int parentHeight) {}
- protected void keyTyped0(char typedChar, int keyCode) {
+ public void keyTyped0(char typedChar, int keyCode) {
for (MPanel childComponent : getChildComponents()) {
childComponent.keyTyped0(typedChar, keyCode);
}
@@ -144,9 +144,9 @@ public class MPanel {
if (isFocused)
keyTyped(typedChar, keyCode);
}
- protected void keyTyped(char typedChar, int keyCode) {}
+ public void keyTyped(char typedChar, int keyCode) {}
- protected boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) {
+ public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) {
int relMousex = relMouseX0 - bounds.x;
int relMousey = relMouseY0 - bounds.y;
@@ -170,9 +170,9 @@ public class MPanel {
return focusedOverall;
}
- protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {}
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {}
- protected void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) {
+ public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) {
int relMousex = relMouseX0 - bounds.x;
int relMousey = relMouseY0 - bounds.y;
@@ -181,9 +181,9 @@ public class MPanel {
}
mouseReleased(absMouseX, absMouseY, relMousex, relMousey, state);
}
- protected void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) {}
+ public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) {}
- protected void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) {
+ public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) {
int relMousex = relMouseX0 - bounds.x;
int relMousey = relMouseY0 - bounds.y;
@@ -192,9 +192,9 @@ public class MPanel {
}
mouseClickMove(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick);
}
- protected void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {}
+ public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {}
- protected void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
+ public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
int relMousex = relMouseX0 - bounds.x;
int relMousey = relMouseY0 - bounds.y;
@@ -203,5 +203,5 @@ public class MPanel {
}
mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount);
}
- protected void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {}
+ public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java
index 024fa69e..98b0a136 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java
@@ -1,5 +1,6 @@
package kr.syeyoung.dungeonsguide.roomedit;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ActuallyClonable;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -7,6 +8,6 @@ import lombok.Data;
@AllArgsConstructor
public class Parameter {
private String name;
- private Object data;
-
+ private Object previousData;
+ private Object newData;
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java
index e32181ed..866951ab 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java
@@ -47,7 +47,7 @@ public class MButton extends MPanel {
}
@Override
- protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
if (onActionPerformed != null && new Rectangle(new Point(0,0),getSize()).contains(relMouseX, relMouseY))
onActionPerformed.run();
}
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 298a88e0..7a284433 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
@@ -31,7 +31,7 @@ public class MLabelAndElement extends MPanel {
}
@Override
- protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
if (onClick!= null && new Rectangle(new Point(0,0),bounds.getSize()).contains(relMouseX, relMouseY)) {
onClick.run();
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java
index 9a599075..13e1c6ed 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java
@@ -3,6 +3,7 @@ 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.panes.ProcessorParameterEditPane;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.gui.Gui;
@@ -18,8 +19,10 @@ public class MParameter extends MPanel {
@Getter @Setter
private Parameter parameter;
+ private ProcessorParameterEditPane processorParameterEditPane;
- public MParameter(final Parameter parameter) {
+ public MParameter(final Parameter parameter, ProcessorParameterEditPane processorParameterEditPane) {
+ this.processorParameterEditPane = processorParameterEditPane;
this.add(this.label = new MLabel() {
@Override
public String getText() {
@@ -29,7 +32,7 @@ public class MParameter extends MPanel {
this.add(this.data = new MLabel() {
@Override
public String getText() {
- return parameter.getData() != null ?parameter.getData().toString() :"-empty-";
+ return parameter.getNewData() != null ?parameter.getNewData().toString() :"-empty-";
}
});
this.label.setAlignment(MLabel.Alignment.LEFT);
@@ -46,7 +49,7 @@ public class MParameter extends MPanel {
}
@Override
- protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ 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)) {
// open new gui;
System.out.println("hey I'm "+parameter.getName()+", i'ma open gui");
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java
index 7e9e42cb..94f79f7d 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java
@@ -22,9 +22,10 @@ public class MStringSelectionButton extends MPanel {
@Setter
private Runnable onUpdate;
- public MStringSelectionButton(final List<String> possible) {
+ public MStringSelectionButton(final List<String> possible, String defaultValue) {
this.possible = possible;
- selectedIndex = 0;
+ selectedIndex = possible.indexOf(defaultValue);
+ if (selectedIndex == -1) selectedIndex = 0;
dec = new MButton(); dec.setText("<"); add(dec);
inc = new MButton(); inc.setText(">"); add(inc);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabButton.java
index 96f8d4db..eee366cc 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabButton.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTabButton.java
@@ -53,7 +53,7 @@ public class MTabButton extends MPanel {
}
@Override
- protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
if (new Rectangle(new Point(0,0),getSize()).contains(relMouseX, relMouseY)) {
tabbedPane.setSelectedKey(text);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java
index 083bb356..d571384f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java
@@ -71,7 +71,7 @@ public class MTextField extends MPanel {
}
@Override
- protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
Rectangle actualField = new Rectangle(1, 3,bounds.width - 2, bounds.height - 6);
if (!actualField.contains(relMouseX, relMouseY)) return;
@@ -96,7 +96,7 @@ public class MTextField extends MPanel {
}
@Override
- protected void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {
+ public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {
if (!isFocused) return;
selectionStart = cursor;
selectionEnd = cursor;
@@ -127,7 +127,7 @@ public class MTextField extends MPanel {
}
@Override
- protected void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
+ public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
if (!isFocused) return;
if (scrollAmount > 0) {
xOffset += 5;
@@ -147,7 +147,7 @@ public class MTextField extends MPanel {
}
@Override
- protected void keyTyped(char typedChar, int keycode) {
+ public void keyTyped(char typedChar, int keycode) {
if (!isFocused) return;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java
new file mode 100644
index 00000000..83383954
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java
@@ -0,0 +1,196 @@
+package kr.syeyoung.dungeonsguide.roomedit.gui;
+
+import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
+import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo;
+import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
+import kr.syeyoung.dungeonsguide.roomedit.MPanel;
+import kr.syeyoung.dungeonsguide.roomedit.Parameter;
+import kr.syeyoung.dungeonsguide.roomedit.elements.*;
+import kr.syeyoung.dungeonsguide.roomedit.panes.GeneralEditPane;
+import kr.syeyoung.dungeonsguide.roomedit.panes.ProcessorParameterEditPane;
+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 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;
+import java.util.UUID;
+
+public class GuiDungeonParameterEdit extends GuiScreen {
+
+ private MPanel mainPanel = new MPanel();
+
+ private Parameter parameter;
+ private DungeonRoom dungeonRoom;
+
+ private String classSelection;
+
+ private MPanel currentValueEdit;
+
+ private MButton save;
+ private MButton delete;
+
+ public GuiDungeonParameterEdit(final MParameter parameter2, final ProcessorParameterEditPane processorParameterEditPane) {
+ dungeonRoom = EditingContext.getEditingContext().getRoom();
+ this.parameter = parameter2.getParameter();
+ {
+ MTextField mTextField = new MTextField() {
+ @Override
+ public void edit(String str) {
+ parameter.setName(str);
+ }
+ };
+ MLabelAndElement mLabelAndElement = new MLabelAndElement("Name", mTextField);
+
+ mTextField.setText(parameter.getName());
+ mLabelAndElement.setBounds(new Rectangle(0,20,200, 20));
+ mainPanel.add(mLabelAndElement);
+ }
+ {
+ classSelection = parameter.getNewData() == null ?"null" : parameter.getNewData().getClass().getName();
+ final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(ValueEditRegistry.getClassesSupported(), classSelection) {
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ setBounds(new Rectangle(0, 20, parentWidth,parentHeight - 20));
+ }
+ };
+
+ mStringSelectionButton.setOnUpdate(new Runnable() {
+ @Override
+ public void run() {
+ classSelection = mStringSelectionButton.getSelected();
+ updateClassSelection();
+ }
+ });
+ mStringSelectionButton.setBounds(new Rectangle(0,20,150,20));
+ mainPanel.add(mStringSelectionButton);
+ }
+ {
+ currentValueEdit = new MPanel(){
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ setBounds(new Rectangle(0, 40, parentWidth,parentHeight - 60));
+ }
+ };
+ mainPanel.add(currentValueEdit);
+ }
+ {
+ 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() {
+ processorParameterEditPane.delete(parameter2);
+ 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);
+ }
+ updateClassSelection();
+ }
+
+ public void updateClassSelection() {
+ currentValueEdit.getChildComponents().clear();
+
+ ValueEditCreator valueEditCreator = ValueEditRegistry.getValueEditMap(classSelection);
+ parameter.setNewData(valueEditCreator.createDefaultValue(parameter));
+ parameter.setPreviousData(valueEditCreator.cloneObj(parameter.getNewData()));
+
+ MPanel valueEdit = (MPanel) valueEditCreator.createValueEdit(parameter);
+ if (valueEdit == null) {
+ MLabel valueEdit2 = new MLabel() {
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ setBounds(new Rectangle(0, 0, parentWidth,20));
+ }
+ };
+ valueEdit2.setText("No Value Edit");
+ valueEdit2.setBounds(new Rectangle(0,0,150,20));
+ valueEdit = valueEdit2;
+ }
+ valueEdit.resize0(currentValueEdit.getBounds().width, currentValueEdit.getBounds().height);
+ currentValueEdit.add(valueEdit);
+ }
+ @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/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java
index 2d1fe191..6ca1b3c9 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java
@@ -1,6 +1,7 @@
-package kr.syeyoung.dungeonsguide.roomedit;
+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;
@@ -56,24 +57,24 @@ public class GuiDungeonRoomEdit extends GuiScreen {
}
@Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ public void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
mainPanel.keyTyped0(typedChar, keyCode);
}
@Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
}
@Override
- protected void mouseReleased(int mouseX, int mouseY, int state) {
+ public void mouseReleased(int mouseX, int mouseY, int state) {
mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
}
@Override
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
}
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 51ccc1d5..fb2b2160 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java
@@ -72,7 +72,7 @@ System.out.println("building");
add(shape2);
}
{
- final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList<String>(ProcessorFactory.getProcessors()));
+ final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList<String>(ProcessorFactory.getProcessors()), dungeonRoom.getDungeonRoomInfo().getProcessorId());
roomProcessor = new MLabelAndElement("Room Processor: ", mStringSelectionButton);
roomProcessor.setBounds(new Rectangle(0,100,bounds.width, 20));
add(roomProcessor);
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 edc81ac3..a6606a0f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java
@@ -7,6 +7,9 @@ import kr.syeyoung.dungeonsguide.roomedit.Parameter;
import kr.syeyoung.dungeonsguide.roomedit.elements.MButton;
import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement;
import kr.syeyoung.dungeonsguide.roomedit.elements.MParameter;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ActuallyClonable;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry;
import java.awt.*;
import java.util.ArrayList;
@@ -36,7 +39,7 @@ public class ProcessorParameterEditPane extends MPanel {
@Override
public void run() {
MParameter parameter;
- parameters.add(parameter = new MParameter(new Parameter(UUID.randomUUID().toString(), null)));
+ parameters.add(parameter = new MParameter(new Parameter(UUID.randomUUID().toString(), null, null), ProcessorParameterEditPane.this));
parameter.setBounds(new Rectangle(0,0,bounds.width, 20));
}
});
@@ -53,14 +56,20 @@ public class ProcessorParameterEditPane extends MPanel {
for (MParameter parameter : parameters) {
Parameter real = parameter.getParameter();
- dungeonRoomInfo.getProperties().put(real.getName(), real.getData());
+
+ ValueEditCreator vec = ValueEditRegistry.getValueEditMap(real.getNewData() == null ? "null" :real.getNewData().getClass().getName());
+
+ real.setPreviousData(vec.cloneObj(real.getNewData()));
+ dungeonRoomInfo.getProperties().put(real.getName(), real.getNewData());
}
}
});
}
{
for (Map.Entry<String, Object> en : dungeonRoom.getDungeonRoomInfo().getProperties().entrySet()) {
- MParameter mParameter = new MParameter(new Parameter(en.getKey(), en.getValue()));
+ ValueEditCreator vec = ValueEditRegistry.getValueEditMap(en.getValue() == null ? "null" :en.getValue().getClass().getName());
+
+ MParameter mParameter = new MParameter(new Parameter(en.getKey(), vec.cloneObj(en.getValue()), vec.cloneObj(en.getValue())), this);
mParameter.setBounds(new Rectangle(0,0,bounds.width,20));
parameters.add(mParameter);
}
@@ -103,7 +112,7 @@ public class ProcessorParameterEditPane extends MPanel {
}
@Override
- protected void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
+ public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
if (scrollAmount > 0) offsetY -= 20;
else if (scrollAmount < 0) offsetY += 20;
if (offsetY < 0) offsetY = 0;
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 f390f969..38d57eef 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java
@@ -79,7 +79,7 @@ public class RoomDataDisplayPane extends MPanel {
private int lastX;
private int lastY;
@Override
- protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
lastX = absMouseX;
lastY = absMouseY;
@@ -90,7 +90,7 @@ public class RoomDataDisplayPane extends MPanel {
}
@Override
- protected void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {
+ public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {
int dX = absMouseX - lastX;
int dY = absMouseY - lastY;
offsetX += dX;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ActuallyClonable.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ActuallyClonable.java
new file mode 100644
index 00000000..4473954e
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ActuallyClonable.java
@@ -0,0 +1,5 @@
+package kr.syeyoung.dungeonsguide.roomedit.valueedit;
+
+public interface ActuallyClonable extends Cloneable {
+ public ActuallyClonable clone();
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java
new file mode 100644
index 00000000..dcff4ebd
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java
@@ -0,0 +1,7 @@
+package kr.syeyoung.dungeonsguide.roomedit.valueedit;
+
+import kr.syeyoung.dungeonsguide.roomedit.Parameter;
+
+public interface ValueEdit<T extends Object> {
+ public void setParameter(Parameter parameter);
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java
new file mode 100644
index 00000000..2991e03e
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java
@@ -0,0 +1,11 @@
+package kr.syeyoung.dungeonsguide.roomedit.valueedit;
+
+import kr.syeyoung.dungeonsguide.roomedit.Parameter;
+
+public interface ValueEditCreator<T extends ValueEdit> {
+ public T createValueEdit(Parameter parameter);
+
+ public Object createDefaultValue(Parameter parameter);
+
+ public Object cloneObj(Object object);
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java
new file mode 100644
index 00000000..42488e98
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java
@@ -0,0 +1,15 @@
+package kr.syeyoung.dungeonsguide.roomedit.valueedit;
+
+import kr.syeyoung.dungeonsguide.roomedit.Parameter;
+
+public class ValueEditNull implements ValueEditCreator {
+ @Override
+ public ValueEdit createValueEdit(Parameter parameter) {
+ return null;
+ }
+
+ @Override
+ public ActuallyClonable createDefaultValue(Parameter parameter) {
+ 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
new file mode 100644
index 00000000..72120c0f
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java
@@ -0,0 +1,23 @@
+package kr.syeyoung.dungeonsguide.roomedit.valueedit;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ValueEditRegistry {
+ private static Map<String, ValueEditCreator> valueEditMap = new HashMap<String, ValueEditCreator>();
+
+ public static ValueEditCreator getValueEditMap(String className) {
+ return valueEditMap.get(className);
+ }
+
+ public static List<String> getClassesSupported() {
+ return new ArrayList<String>(valueEditMap.keySet());
+ }
+
+ static {
+ valueEditMap.put("null", new ValueEditNull());
+ valueEditMap.put(String.class.getName(), new ValueEditString.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
new file mode 100644
index 00000000..e7162a1a
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java
@@ -0,0 +1,75 @@
+package kr.syeyoung.dungeonsguide.roomedit.valueedit;
+
+import kr.syeyoung.dungeonsguide.roomedit.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 java.awt.*;
+
+public class ValueEditString extends MPanel implements ValueEdit<String> {
+ private Parameter parameter;
+
+
+ public ValueEditString(Parameter parameter2) {
+ this.parameter = parameter2;
+ {
+ MLabel label = new MLabel() {
+ @Override
+ public String getText() {
+ return parameter.getPreviousData().toString();
+ }
+ };
+ MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label);
+ mLabelAndElement.setBounds(new Rectangle(0,0,bounds.width,20));
+ add(mLabelAndElement);
+ }
+ {
+ MTextField textField = new MTextField() {
+ @Override
+ public void edit(String str) {
+ parameter.setNewData(str);
+ }
+ };
+ MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField);
+ mLabelAndElement.setBounds(new Rectangle(0,20,bounds.width,20));
+ add(mLabelAndElement);
+ }
+ }
+
+ @Override
+ public void onBoundsUpdate() {
+ for (MPanel panel :getChildComponents()){
+ panel.setSize(new Dimension(bounds.width, 20));
+ }
+ }
+
+ @Override
+ public void setParameter(Parameter parameter) {
+ this.parameter = parameter;
+ }
+
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ this.setBounds(new Rectangle(0,0,parentWidth, parentHeight));
+ }
+
+ public static class Generator implements ValueEditCreator<ValueEditString> {
+
+ @Override
+ public ValueEditString createValueEdit(Parameter parameter) {
+ return new ValueEditString(parameter);
+ }
+
+ @Override
+ public Object createDefaultValue(Parameter parameter) {
+ return "default";
+ }
+
+ @Override
+ public Object cloneObj(Object object) {
+ return object;
+ }
+ }
+}