aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/roomedit
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-25 15:37:57 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-25 15:37:57 +0900
commit81a315f025f361d1155305e55dfee29308a74ed3 (patch)
tree9be59a599ef9821ca9e66005207cee32022e5a4f /src/main/java/kr/syeyoung/dungeonsguide/roomedit
parenta49e2c1970f6f77079a860dd5e92741251f41c9c (diff)
downloadSkyblock-Dungeons-Guide-81a315f025f361d1155305e55dfee29308a74ed3.tar.gz
Skyblock-Dungeons-Guide-81a315f025f361d1155305e55dfee29308a74ed3.tar.bz2
Skyblock-Dungeons-Guide-81a315f025f361d1155305e55dfee29308a74ed3.zip
room processor stuff
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomedit')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java69
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java25
3 files changed, 89 insertions, 7 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
index 544dc03e..5b52bcf0 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
@@ -33,8 +33,6 @@ public class GuiDungeonRoomEdit extends GuiScreen {
tabbedPane.addTab("General", new GeneralEditPane(room));
tabbedPane.addTab("Room Match", new RoomDataDisplayPane(room));
-
-
}
@Override
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java
new file mode 100644
index 00000000..7e9e42cb
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java
@@ -0,0 +1,69 @@
+package kr.syeyoung.dungeonsguide.roomedit.elements;
+
+import kr.syeyoung.dungeonsguide.roomedit.MPanel;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.awt.*;
+import java.util.List;
+
+@Getter
+@Setter
+public class MStringSelectionButton extends MPanel {
+
+ private List<String> possible;
+ private int selectedIndex;
+
+ private MButton dec;
+ private MButton inc;
+ private MLabel selected;
+
+ @Getter
+ @Setter
+ private Runnable onUpdate;
+
+ public MStringSelectionButton(final List<String> possible) {
+ this.possible = possible;
+ selectedIndex = 0;
+
+ dec = new MButton(); dec.setText("<"); add(dec);
+ inc = new MButton(); inc.setText(">"); add(inc);
+ selected = new MLabel(); updateSelected(); add(selected);
+
+ dec.setOnActionPerformed(new Runnable() {
+ @Override
+ public void run() {
+ selectedIndex++;
+ if (selectedIndex >= possible.size()) selectedIndex = 0;
+ updateSelected();
+ onUpdate.run();
+ }
+ });
+ inc.setOnActionPerformed(new Runnable() {
+ @Override
+ public void run() {
+ selectedIndex --;
+ if (selectedIndex < 0) selectedIndex = possible.size() - 1;
+ updateSelected();
+ onUpdate.run();
+ }
+ });
+ }
+
+ public String getSelected() {
+ if (possible.size() == 0) return null;
+ return possible.get(selectedIndex);
+ }
+
+ private void updateSelected() {
+ if (possible.size() == 0) selected.setText("-Empty-");
+ else selected.setText(possible.get(selectedIndex));
+ }
+
+ @Override
+ public void onBoundsUpdate() {
+ dec.setBounds(new Rectangle(0,0,bounds.height, bounds.height));
+ inc.setBounds(new Rectangle(bounds.width - bounds.height, 0, bounds.height, bounds.height));
+ selected.setBounds(new Rectangle(bounds.height, 0, bounds.width - bounds.height - bounds.height, 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 59620ff0..eec9a63b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java
@@ -4,8 +4,10 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry;
import kr.syeyoung.dungeonsguide.roomedit.MPanel;
import kr.syeyoung.dungeonsguide.roomedit.elements.*;
+import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory;
import java.awt.*;
+import java.util.ArrayList;
public class GeneralEditPane extends MPanel {
private DungeonRoom dungeonRoom;
@@ -19,6 +21,8 @@ public class GeneralEditPane extends MPanel {
private MButton save;
+ private MLabelAndElement roomProcessor;
+
public GeneralEditPane(final DungeonRoom dungeonRoom) {
this.dungeonRoom = dungeonRoom;
System.out.println("building");
@@ -66,9 +70,21 @@ System.out.println("building");
add(shape2);
}
{
- System.out.println("roomdata");
+ final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList<String>(ProcessorFactory.getProcessors()));
+ roomProcessor = new MLabelAndElement("Room Processor: ", mStringSelectionButton);
+ roomProcessor.setBounds(new Rectangle(0,100,bounds.width, 20));
+ add(roomProcessor);
+
+ mStringSelectionButton.setOnUpdate(new Runnable() {
+ @Override
+ public void run() {
+ dungeonRoom.getDungeonRoomInfo().setProcessorId(mStringSelectionButton.getSelected());
+ dungeonRoom.updateRoomProcessor();
+ }
+ });
+ }
+ {
if (dungeonRoom.getDungeonRoomInfo().isRegistered()) return;
- System.out.println("roomdata");
save = new MButton();
save.setText("Save RoomData");
save.setOnActionPerformed(new Runnable() {
@@ -79,8 +95,7 @@ System.out.println("building");
}
});
save.setBackgroundColor(Color.green);
- save.setBounds(new Rectangle(1,100,bounds.width-2, 20));
- System.out.println("roomdata");
+ save.setBounds(new Rectangle(1,120,bounds.width-2, 20));
add(save);
System.out.println(save.getBounds());
}
@@ -94,6 +109,6 @@ System.out.println("building");
@Override
public void onBoundsUpdate() {
if (save != null)
- save.setBounds(new Rectangle(0,100,bounds.width, 20));
+ save.setBounds(new Rectangle(0,120,bounds.width, 20));
}
}