summaryrefslogtreecommitdiff
path: root/NET/worlds/console/BBWObjClickedCommand.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/BBWObjClickedCommand.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/BBWObjClickedCommand.java')
-rw-r--r--NET/worlds/console/BBWObjClickedCommand.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/NET/worlds/console/BBWObjClickedCommand.java b/NET/worlds/console/BBWObjClickedCommand.java
new file mode 100644
index 0000000..e0d93b7
--- /dev/null
+++ b/NET/worlds/console/BBWObjClickedCommand.java
@@ -0,0 +1,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();
+ }
+}