aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-25 22:22:24 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-25 22:22:24 +0900
commit3a3b70806358e5e44232e793c84879514b1857b4 (patch)
tree2e3b77b56c1b0234b4deef384b3c8dd9eb2752cf /src
parenta34fa2c68fd4a1c47fd22d5de5b87959210eceab (diff)
downloadSkyblock-Dungeons-Guide-3a3b70806358e5e44232e793c84879514b1857b4.tar.gz
Skyblock-Dungeons-Guide-3a3b70806358e5e44232e793c84879514b1857b4.tar.bz2
Skyblock-Dungeons-Guide-3a3b70806358e5e44232e793c84879514b1857b4.zip
conttexaltasdhuewbgsidqeaghosguh[ujw-fia
Diffstat (limited to 'src')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/EventListener.java12
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java17
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java21
-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
6 files changed, 119 insertions, 9 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
index 15929c2e..daf1c00f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
@@ -37,9 +37,11 @@ public class DungeonsGuide
ClientCommandHandler.instance.registerCommand(new CommandLoadData());
ClientCommandHandler.instance.registerCommand(new CommandSaveData());
+ //noinspection ResultOfMethodCallIgnored
configDir.mkdirs();
DungeonRoomInfoRegistry.loadAll(configDir);
+ Keybinds.register();
}
@Getter
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
index 93457e8e..1a5731fd 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
@@ -4,6 +4,7 @@ import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
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.utils.MapUtils;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.client.Minecraft;
@@ -12,10 +13,12 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
+import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.GL11;
@@ -104,4 +107,13 @@ public class EventListener {
}
}
}
+
+ @SubscribeEvent
+ public void onKeyInput(InputEvent.KeyInputEvent keyInputEvent) {
+ if (Keybinds.opengui.isKeyDown()){
+ EditingContext ec = EditingContext.getEditingContext();
+ if (ec == null) Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("No Editing session is open right now"));
+ else ec.reopen();
+ }
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java
new file mode 100644
index 00000000..17d0ccaa
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java
@@ -0,0 +1,17 @@
+package kr.syeyoung.dungeonsguide;
+
+import net.minecraft.client.settings.KeyBinding;
+import net.minecraftforge.fml.client.registry.ClientRegistry;
+import org.lwjgl.input.Keyboard;
+
+public class Keybinds
+{
+ public static KeyBinding opengui;
+
+ public static void register()
+ {
+ opengui = new KeyBinding("ay", Keyboard.KEY_R, "key.categories.misc");
+
+ ClientRegistry.registerKeyBinding(opengui);
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java
index b1f15300..77f9718b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java
@@ -4,6 +4,7 @@ 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.roomedit.EditingContext;
import kr.syeyoung.dungeonsguide.roomedit.GuiDungeonRoomEdit;
import kr.syeyoung.dungeonsguide.utils.MapUtils;
import net.minecraft.client.Minecraft;
@@ -23,12 +24,12 @@ import java.awt.*;
public class CommandEditRoom extends CommandBase {
@Override
public String getCommandName() {
- return "editroom";
+ return "editsession";
}
@Override
public String getCommandUsage(ICommandSender sender) {
- return "editroom";
+ return "editsession";
}
@Override
@@ -55,16 +56,22 @@ public class CommandEditRoom extends CommandBase {
return;
}
- openit = new GuiDungeonRoomEdit(dungeonRoom);
+ if (EditingContext.getEditingContext() != null) {
+ sender.addChatMessage(new ChatComponentText("There is an editing session currently open."));
+ return;
+ }
+
+ EditingContext.createEditingContext(dungeonRoom);
+ openGuiReq = true;
}
- GuiScreen openit = null;
+ private boolean openGuiReq = false;
@SubscribeEvent
public void tick(TickEvent.ClientTickEvent tick){
- if ( openit != null &&tick.phase == TickEvent.Phase.END && tick.side == Side.CLIENT && tick.type == TickEvent.Type.CLIENT) {
- Minecraft.getMinecraft().displayGuiScreen(openit);
- openit = null;
+ if ( openGuiReq &&tick.phase == TickEvent.Phase.END && tick.side == Side.CLIENT && tick.type == TickEvent.Type.CLIENT) {
+ DungeonRoom dr = EditingContext.getEditingContext().getRoom();
+ EditingContext.getEditingContext().openGui(new GuiDungeonRoomEdit(dr));
}
}
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));
}
}