1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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;
}
}
}
|