summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/EditRoomDialog.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/EditRoomDialog.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/EditRoomDialog.java')
-rw-r--r--NET/worlds/scape/EditRoomDialog.java122
1 files changed, 122 insertions, 0 deletions
diff --git a/NET/worlds/scape/EditRoomDialog.java b/NET/worlds/scape/EditRoomDialog.java
new file mode 100644
index 0000000..eca4180
--- /dev/null
+++ b/NET/worlds/scape/EditRoomDialog.java
@@ -0,0 +1,122 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.Console;
+import NET.worlds.console.PolledDialog;
+import NET.worlds.core.Sort;
+import java.awt.Button;
+import java.awt.Choice;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Label;
+import java.awt.Panel;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+class EditRoomDialog extends PolledDialog {
+ private Choice roomChoice = new Choice();
+ private Choice musicChoice = new Choice();
+ private Button okButton = new Button(Console.message("OK"));
+ private Button cancelButton = new Button(Console.message("Cancel"));
+ private MusicManagerDialog parent;
+ private MusicRoom room;
+ private String startSelect;
+ private static String lastMusic;
+ private static Font font = new Font(Console.message("MenuFont"), 0, 12);
+ private static Font bfont = new Font(Console.message("ButtonFont"), 0, 12);
+
+ public EditRoomDialog(MusicManagerDialog parent, MusicRoom room, String startSelect) {
+ super(parent, parent, Console.message("Assign-Music"), true);
+ this.parent = parent;
+ this.room = room;
+ this.startSelect = startSelect;
+ this.ready();
+ }
+
+ @Override
+ protected void build() {
+ GridBagLayout gbag = new GridBagLayout();
+ this.setLayout(gbag);
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = 0;
+ c.anchor = 13;
+ Label lName = new Label(Console.message("Room-name"), 2);
+ lName.setFont(font);
+ this.add(gbag, lName, c);
+ c.gridwidth = 0;
+ c.anchor = 17;
+ this.roomChoice.setFont(font);
+ this.add(gbag, this.roomChoice, c);
+ c.gridwidth = 1;
+ c.anchor = 13;
+ Label lMusic = new Label(Console.message("Music"), 2);
+ lMusic.setFont(font);
+ this.add(gbag, lMusic, c);
+ c.gridwidth = 0;
+ c.anchor = 17;
+ this.musicChoice.setFont(font);
+ this.add(gbag, this.musicChoice, c);
+ c.anchor = 10;
+ Panel p = new Panel();
+ p.setFont(bfont);
+ p.add(this.okButton);
+ p.add(this.cancelButton);
+ this.add(gbag, p, c);
+ this.roomChoice.setFont(font);
+ this.musicChoice.setFont(font);
+ if (this.room != null) {
+ this.roomChoice.add(this.room.getRoomName());
+ }
+
+ Enumeration e = this.parent.getAllRooms().elements();
+ Hashtable roomsWithMusic = this.parent.getManager().getRooms();
+ Vector v = new Vector();
+
+ while (e.hasMoreElements()) {
+ String name = (String)e.nextElement();
+ if (!roomsWithMusic.containsKey(name)) {
+ v.addElement(name);
+ }
+ }
+
+ Sort.sortInto(this.roomChoice, v);
+ Sort.sortInto(this.musicChoice, this.parent.getManager().getMusic());
+ if (this.room != null) {
+ this.roomChoice.select(this.room.getRoomName());
+ this.musicChoice.select(this.room.getMusicName());
+ } else {
+ this.roomChoice.select(this.startSelect);
+ if (lastMusic != null) {
+ this.musicChoice.select(lastMusic);
+ }
+ }
+ }
+
+ @Override
+ public boolean action(java.awt.Event event, Object what) {
+ Object target = event.target;
+ if (target == this.okButton) {
+ return this.done(true);
+ } else {
+ return target == this.cancelButton ? this.done(false) : false;
+ }
+ }
+
+ public boolean isEditor() {
+ return this.room != null;
+ }
+
+ public MusicRoom getMusicRoom() {
+ String roomName = this.roomChoice.getSelectedItem();
+ String musicName = this.musicChoice.getSelectedItem();
+ lastMusic = musicName;
+ if (this.room == null) {
+ return new MusicRoom(roomName, musicName);
+ } else {
+ this.room.setRoomName(roomName);
+ this.room.setMusicName(musicName);
+ return this.room;
+ }
+ }
+}