From c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 12 Feb 2026 22:33:32 -0800 Subject: Initial commit --- NET/worlds/console/RightMenu.java | 119 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 NET/worlds/console/RightMenu.java (limited to 'NET/worlds/console/RightMenu.java') diff --git a/NET/worlds/console/RightMenu.java b/NET/worlds/console/RightMenu.java new file mode 100644 index 0000000..832f0a4 --- /dev/null +++ b/NET/worlds/console/RightMenu.java @@ -0,0 +1,119 @@ +package NET.worlds.console; + +import NET.worlds.scape.Action; +import NET.worlds.scape.RunningActionHandler; +import NET.worlds.scape.WObject; +import java.util.Enumeration; +import java.util.Hashtable; + +public class RightMenu implements MainCallback { + private static RightMenu _current = null; + private WObject _obj; + private Enumeration _acts; + private Hashtable _inttobuttons = new Hashtable(); + private int _edit = 0; + private int _pm = 0; + private int _lastID = 0; + + public RightMenu(WObject obj, Enumeration acts) { + this._obj = obj; + this._acts = acts; + Main.register(this); + } + + private int add(String label) { + if (this._lastID == 0) { + this._lastID = 100; + } + + int id = this._lastID++; + + assert this._lastID < 200; + + nativeAdd(label, id, this._pm); + return id; + } + + private static native int create(); + + private static native void nativeAdd(String var0, int var1, int var2); + + private static native void addSeparator(int var0); + + private static native void show(int var0, int var1); + + private static native void discard(int var0); + + private static native int checkPressed(); + + private void build(Enumeration acts) { + if (_current != null) { + _current.close(); + } + + _current = this; + int rows = 0; + Hashtable buttons = new Hashtable(); + + while (acts.hasMoreElements()) { + Action act = acts.nextElement(); + String label = act.rightMenuLabel; + if (label != null && label != "") { + buttons.put(label, act); + rows++; + } + } + + if (rows <= 0 && Gamma.getShaper() == null) { + this.close(); + } else { + this._pm = create(); + if (Gamma.getShaper() != null) { + this._edit = this.add("Edit Properties..."); + if (rows > 0) { + addSeparator(this._pm); + } + } + + Enumeration en = buttons.keys(); + + while (en.hasMoreElements()) { + String label = en.nextElement(); + this._inttobuttons.put(new Integer(this.add(label)), buttons.get(label)); + } + + show(Window.getHWnd(), this._pm); + } + } + + private void close() { + discard(this._pm); + this._pm = 0; + Main.unregister(this); + _current = null; + } + + private void checkButton() { + int pressed = checkPressed(); + if (pressed != 0) { + if (pressed == this._edit) { + Console.getFrame().getEditTile().viewProperties(this._obj); + } else { + Action action = this._inttobuttons.get(new Integer(pressed)); + RunningActionHandler.trigger(action, this._obj.getWorld(), null); + } + + this.close(); + } + } + + @Override + public void mainCallback() { + if (this._acts != null) { + this.build(this._acts); + this._acts = null; + } else { + this.checkButton(); + } + } +} -- cgit v1.2.3