summaryrefslogtreecommitdiff
path: root/NET/worlds/console/FileSaver.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/console/FileSaver.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/FileSaver.java')
-rw-r--r--NET/worlds/console/FileSaver.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/NET/worlds/console/FileSaver.java b/NET/worlds/console/FileSaver.java
new file mode 100644
index 0000000..dce997d
--- /dev/null
+++ b/NET/worlds/console/FileSaver.java
@@ -0,0 +1,77 @@
+package NET.worlds.console;
+
+import NET.worlds.scape.World;
+import java.text.MessageFormat;
+import java.util.Enumeration;
+import java.util.Vector;
+
+class FileSaver implements DialogReceiver {
+ private Vector<World> saveList = new Vector<World>();
+ private int state;
+ public static final int QUIT = 0;
+ public static final int SAVING = 1;
+ public static final int CANCEL = 2;
+
+ FileSaver() {
+ Enumeration<World> e = World.getWorlds();
+
+ while (e.hasMoreElements()) {
+ World w = e.nextElement();
+ if (w.getEdited()) {
+ this.saveList.addElement(w);
+ }
+ }
+
+ this.saveNext(false);
+ }
+
+ public int getState() {
+ return this.state;
+ }
+
+ private World getWorld() {
+ return this.saveList.elementAt(0);
+ }
+
+ private void saveNext(boolean removeFirst) {
+ if (removeFirst) {
+ this.saveList.removeElementAt(0);
+ }
+
+ if (this.saveList.size() != 0) {
+ this.state = 1;
+ Object[] arguments = new Object[]{new String(this.getWorld().getName())};
+ new YesNoCancelDialog(Console.getFrame(), this, Console.message("Save-Changes2"), MessageFormat.format(Console.message("has-changed"), arguments));
+ } else {
+ this.state = 0;
+ }
+ }
+
+ @Override
+ public void dialogDone(Object who, boolean confirmed) {
+ if (who instanceof YesNoCancelDialog) {
+ switch (((YesNoCancelDialog)who).getChoice()) {
+ case -1:
+ this.state = 2;
+ break;
+ case 0:
+ this.saveNext(true);
+ break;
+ case 1:
+ new FileSysDialog(
+ Console.getFrame(), this, Console.message("Save-World"), 1, "World Save Files|*.world", Shaper.getSaveName(this.getWorld()), true
+ );
+ }
+ } else {
+ if (confirmed) {
+ FileSysDialog fileDialog = (FileSysDialog)who;
+ if (Shaper.doSave(fileDialog.fileName(), this.getWorld(), false)) {
+ this.saveNext(true);
+ return;
+ }
+ }
+
+ this.state = 2;
+ }
+ }
+}