mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-02 16:49:09 +00:00
[FEATURE] Added ability to change debug output - issue #46
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user