aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/roomedit
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomedit')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java56
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java20
2 files changed, 74 insertions, 2 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java
new file mode 100644
index 00000000..8b5cecdd
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java
@@ -0,0 +1,56 @@
+package kr.syeyoung.dungeonsguide.roomedit;
+
+import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import lombok.Data;
+import lombok.Getter;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiScreen;
+
+import java.util.LinkedList;
+import java.util.Stack;
+
+public class EditingContext {
+
+ private static EditingContext editingContext;
+
+ public static void createEditingContext(DungeonRoom dungeonRoom) {
+ editingContext = new EditingContext(dungeonRoom);
+ }
+
+ public static EditingContext getEditingContext() {
+ return editingContext;
+ }
+
+ public static void endEditingSession() {
+ editingContext = null;
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ }
+
+
+ private EditingContext(DungeonRoom dungeonRoom) {
+ this.room = dungeonRoom;
+ }
+
+ @Getter
+ private DungeonRoom room;
+
+ private Stack<GuiScreen> guiStack = new Stack<GuiScreen>();
+
+ private GuiScreen current;
+
+ public void openGui(GuiScreen gui) {
+ guiStack.push(current);
+ this.current = gui;
+ Minecraft.getMinecraft().displayGuiScreen(gui);
+ }
+
+ public void goBack() {
+ current = guiStack.pop();
+ Minecraft.getMinecraft().displayGuiScreen(current);
+ }
+
+ public void reopen() {
+ Minecraft.getMinecraft().displayGuiScreen(current);
+ }
+}
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 eec9a63b..51ccc1d5 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java
@@ -2,6 +2,7 @@ package kr.syeyoung.dungeonsguide.roomedit.panes;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry;
+import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
import kr.syeyoung.dungeonsguide.roomedit.MPanel;
import kr.syeyoung.dungeonsguide.roomedit.elements.*;
import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory;
@@ -20,6 +21,7 @@ public class GeneralEditPane extends MPanel {
private MLabelAndElement shape2;
private MButton save;
+ private MButton end;
private MLabelAndElement roomProcessor;
@@ -84,6 +86,19 @@ System.out.println("building");
});
}
{
+ end = new MButton();
+ end.setText("End Editing Session");
+ end.setOnActionPerformed(new Runnable() {
+ @Override
+ public void run() {
+ EditingContext.endEditingSession();
+ }
+ });
+ end.setBackgroundColor(Color.green);
+ end.setBounds(new Rectangle(0,120,bounds.width, 20));
+ add(end);
+ }
+ {
if (dungeonRoom.getDungeonRoomInfo().isRegistered()) return;
save = new MButton();
save.setText("Save RoomData");
@@ -95,7 +110,7 @@ System.out.println("building");
}
});
save.setBackgroundColor(Color.green);
- save.setBounds(new Rectangle(1,120,bounds.width-2, 20));
+ save.setBounds(new Rectangle(0,140,bounds.width, 20));
add(save);
System.out.println(save.getBounds());
}
@@ -109,6 +124,7 @@ System.out.println("building");
@Override
public void onBoundsUpdate() {
if (save != null)
- save.setBounds(new Rectangle(0,120,bounds.width, 20));
+ save.setBounds(new Rectangle(0,140,bounds.width, 20));
+ end.setBounds(new Rectangle(1,120,bounds.width-2, 20));
}
}