summaryrefslogtreecommitdiff
path: root/NET/worlds/console/RightMenu.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/RightMenu.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/RightMenu.java')
-rw-r--r--NET/worlds/console/RightMenu.java119
1 files changed, 119 insertions, 0 deletions
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<Action> _acts;
+ private Hashtable<Integer, Action> _inttobuttons = new Hashtable<Integer, Action>();
+ private int _edit = 0;
+ private int _pm = 0;
+ private int _lastID = 0;
+
+ public RightMenu(WObject obj, Enumeration<Action> 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<Action> acts) {
+ if (_current != null) {
+ _current.close();
+ }
+
+ _current = this;
+ int rows = 0;
+ Hashtable<String, Action> buttons = new Hashtable<String, Action>();
+
+ 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<String> 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();
+ }
+ }
+}