From 58d4ba209614bcc4dc500b931b09fc237c835c40 Mon Sep 17 00:00:00 2001 From: JKetelaar Date: Sat, 7 May 2016 03:01:56 +0200 Subject: [PATCH] [FEATURE] Added ability to change debug output - issue #46 --- .DS_Store | Bin 0 -> 6148 bytes .../org/rev317/min/callback/MenuAction.java | 34 ++++++++++++++++-- src/main/java/org/rev317/min/ui/BotMenu.java | 24 +++++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a04998626b9d45e9214db0794cb348215efbb638 GIT binary patch literal 6148 zcmeHKUu)Yi5SNmybD9^AwPny3zZN?11|xfPv+S`D@JJYI$!u&Afw6F^S(r3 z>%Xs2wlC37(%0TeN@z&?*s+c~ar&K3car^+ku1g-Z;hjOjMW5i5`(_$1RS-2KWj(?E>T)Pb>S-^5OV5{qQ8;%lDNY}mLm1^z9#!IWd*}!7I z+C27$+0>VT92c!1|E5|ZibG>}0y$jRU$QJ&+CkVA@w9Jmeacc9h&0acr5^P}8fDW~ zHcq4B$k*fbL?nlOd%Kgz6G-g@Y1|cs2t^{~iB-qaw|8c7j`MV&Ewm!2Q7iMf41o8r9YT75+YAe+>}@Y`jY#ItD$1rAFuh z;W`yir*d<};5r@rj*0UOmKt?B<7#FY$IQ&l4TY=O!SASW#yyQx69dG+Dg#yBwDJ7^ z{P_KUHHlip05R}iF~DnWzukgYGH2`B%i&q;fPM!>!MIZ6G6f8E6hkZ?#cx2BfZss_ V&@)(S1P=)P2q+q;A_o2{19v9xWfcGb literal 0 HcmV?d00001 diff --git a/src/main/java/org/rev317/min/callback/MenuAction.java b/src/main/java/org/rev317/min/callback/MenuAction.java index e596d62..fdf0947 100644 --- a/src/main/java/org/rev317/min/callback/MenuAction.java +++ b/src/main/java/org/rev317/min/callback/MenuAction.java @@ -9,11 +9,26 @@ import org.rev317.min.script.ScriptEngine; /** * @author Everel + * @author JKetelaar * @author Matt123337 */ public class MenuAction { + private static final String[][] outputs = { + { + "[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", + "[id: %d, action1: %d, action2: %d, action3: %d, action4: %d, index: %d]" + }, + { + "[index: %d, action1: %d, action2: %d, action3: %d, id: %d]", + "[id: %d, action1: %d, action2: %d, action3: %d, index: %d]" + } + }; + private static int currentOutputIndex = 0; + public static void intercept(int index) { + int outputIndex = 0; + Client client = Loader.getClient(); int action1 = client.getMenuAction1()[index]; int action2 = client.getMenuAction2()[index]; @@ -23,9 +38,9 @@ public class MenuAction { if (DActions.debugActions()) { if (Game.hasAction4()) { action4 = client.getMenuAction4()[index]; - System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", index, action1, action2, action3, action4, actionId)); + System.out.println(String.format(outputs[0][outputIndex], index, action1, action2, action3, action4, actionId)); } else { - System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, id: %d]", index, action1, action2, action3, actionId)); + System.out.println(String.format(outputs[1][outputIndex], index, action1, action2, action3, actionId)); } } @@ -33,4 +48,19 @@ public class MenuAction { ScriptEngine.getInstance().dispatch(actionEvent); } + /** + * Sets the current output index + * + * @param currentOutputIndex + */ + public static void setCurrentOutputIndex(int currentOutputIndex) { + if (currentOutputIndex > outputs.length - 1) { + currentOutputIndex = 0; + } + MenuAction.currentOutputIndex = currentOutputIndex; + } + + public static String[][] getOutputs() { + return outputs; + } } diff --git a/src/main/java/org/rev317/min/ui/BotMenu.java b/src/main/java/org/rev317/min/ui/BotMenu.java index b541dcf..0654f24 100644 --- a/src/main/java/org/rev317/min/ui/BotMenu.java +++ b/src/main/java/org/rev317/min/ui/BotMenu.java @@ -2,6 +2,7 @@ package org.rev317.min.ui; import org.parabot.core.Context; import org.parabot.core.paint.PaintDebugger; +import org.rev317.min.callback.MenuAction; import org.rev317.min.debug.*; import javax.swing.*; @@ -18,7 +19,9 @@ public class BotMenu implements ActionListener { JMenu debug = new JMenu("Debug"); - JMenuItem actions = newItem("Actions"); + JMenu actions = new JMenu("Actions"); + JMenuItem enableActions = newItem("Enable Actions"); + JMenuItem animation = newItem("Animation"); JMenuItem bank = newItem("Bank"); JMenuItem flags = newItem("Collision flags"); @@ -32,7 +35,7 @@ public class BotMenu implements ActionListener { JMenuItem objects = newItem("Objects"); JMenuItem players = newItem("Players"); - debugger.addDebugger("Actions", new DActions()); + debugger.addDebugger("Enable Actions", new DActions()); debugger.addDebugger("Animation", new DAnimation()); debugger.addDebugger("Bank", new DBank()); debugger.addDebugger("Collision flags", new DCollisionFlags()); @@ -47,6 +50,7 @@ public class BotMenu implements ActionListener { debugger.addDebugger("Players", new DPlayers()); debug.add(actions); + actions.add(enableActions); debug.add(animation); debug.add(bank); debug.add(flags); @@ -60,6 +64,22 @@ public class BotMenu implements ActionListener { debug.add(objects); debug.add(players); + actions.addSeparator(); + for (int i = 0; i < MenuAction.getOutputs().length; i++){ + final int index = i; + JMenuItem debugOutput = new JCheckBoxMenuItem("Output: " + index); + debugOutput.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + MenuAction.setCurrentOutputIndex(index); + } + }); + if (i == 0){ + debugOutput.setEnabled(true); + } + actions.add(debugOutput); + } + bar.add(debug); }