blob: e0d93b7f69d6142b8d77093d06fb420bdcb64577 (
plain) (
blame)
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
78
79
80
81
82
|
package NET.worlds.console;
import NET.worlds.scape.DeepEnumeration;
import NET.worlds.scape.MouseDownEvent;
import NET.worlds.scape.MouseDownHandler;
import NET.worlds.scape.Pilot;
import NET.worlds.scape.Room;
import NET.worlds.scape.SuperRoot;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class BBWObjClickedCommand extends BlackBoxCommand {
private String objUrl;
int x;
int y;
char key;
public BBWObjClickedCommand() {
this.commandType = 4;
}
public BBWObjClickedCommand(String obj, char pkey, int px, int py) {
this();
this.objUrl = new String(obj);
this.key = pkey;
this.x = px;
this.y = py;
}
@Override
public boolean execute() {
MouseDownHandler target = null;
if (Pilot.getActive() == null) {
return false;
} else {
Room r = Pilot.getActive().getRoom();
if (r == null) {
return false;
} else {
DeepEnumeration de = new DeepEnumeration();
r.getChildren(de);
while (de.hasMoreElements()) {
Object o = de.nextElement();
if (o instanceof MouseDownHandler && ((SuperRoot)o).getName().equals(this.objUrl)) {
target = (MouseDownHandler)o;
break;
}
}
if (target == null) {
this.doCallback(false);
return false;
} else {
MouseDownEvent e = new MouseDownEvent(0, null, this.key, this.x, this.y);
target.handle(e);
this.doCallback(true);
return true;
}
}
}
}
@Override
public void save(DataOutputStream dos) throws IOException {
super.save(dos);
dos.writeInt(this.x);
dos.writeInt(this.y);
dos.writeChar(this.key);
dos.writeUTF(this.objUrl);
}
@Override
public void load(DataInputStream dis) throws IOException {
super.load(dis);
this.x = dis.readInt();
this.y = dis.readInt();
this.key = dis.readChar();
this.objUrl = dis.readUTF();
}
}
|