mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-06 16:50:40 +00:00
Added framework
This commit is contained in:
@@ -4,12 +4,18 @@ import java.applet.Applet;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.asm.ASMClassLoader;
|
import org.parabot.core.asm.ASMClassLoader;
|
||||||
|
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
||||||
|
import org.parabot.environment.scripts.Script;
|
||||||
import org.parabot.environment.servers.ServerManifest;
|
import org.parabot.environment.servers.ServerManifest;
|
||||||
import org.parabot.environment.servers.ServerProvider;
|
import org.parabot.environment.servers.ServerProvider;
|
||||||
import org.parabot.environment.servers.Type;
|
import org.parabot.environment.servers.Type;
|
||||||
import org.rev317.accessors.Client;
|
import org.rev317.accessors.Client;
|
||||||
|
import org.rev317.script.ScriptEngine;
|
||||||
|
import org.rev317.ui.BotMenu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -48,5 +54,27 @@ public class Loader extends ServerProvider {
|
|||||||
public static Client getClient() {
|
public static Client getClient() {
|
||||||
return (Client) Context.getInstance().getClient();
|
return (Client) Context.getInstance().getClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMenuItems(JMenuBar bar) {
|
||||||
|
new BotMenu(bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void injectHooks() {
|
||||||
|
AddInterfaceAdapter.setAccessorPackage("org/rev317/accessors/");
|
||||||
|
// default injection is done by bot, it basically parses the hooks file
|
||||||
|
super.injectHooks();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initScript(Script script) {
|
||||||
|
ScriptEngine.getInstance().setScript(script);
|
||||||
|
ScriptEngine.getInstance().init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unloadScript(Script script) {
|
||||||
|
ScriptEngine.getInstance().unload();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public interface Client {
|
|||||||
|
|
||||||
public int getBackDialogId();
|
public int getBackDialogId();
|
||||||
|
|
||||||
|
public int getPlane();
|
||||||
|
|
||||||
public CollisionMap[] getCollisionMap();
|
public CollisionMap[] getCollisionMap();
|
||||||
|
|
||||||
// args switched
|
// args switched
|
||||||
|
|||||||
@@ -54,7 +54,15 @@ public class Game {
|
|||||||
* @return collision flags
|
* @return collision flags
|
||||||
*/
|
*/
|
||||||
public static int[][] getCollisionFlags() {
|
public static int[][] getCollisionFlags() {
|
||||||
return Loader.getClient().getCollisionMap()[0].getFlags();
|
return Loader.getClient().getCollisionMap()[Game.getPlane()].getFlags();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets current plane
|
||||||
|
* @return current plane
|
||||||
|
*/
|
||||||
|
public static int getPlane() {
|
||||||
|
return Loader.getClient().getPlane();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.rev317.api.wrappers;
|
package org.rev317.api.wrappers;
|
||||||
|
|
||||||
|
import org.rev317.api.interfaces.Locatable;
|
||||||
import org.rev317.api.interfaces.TileFlags;
|
import org.rev317.api.interfaces.TileFlags;
|
||||||
import org.rev317.api.methods.Calculations;
|
import org.rev317.api.methods.Calculations;
|
||||||
import org.rev317.api.methods.Game;
|
import org.rev317.api.methods.Game;
|
||||||
@@ -13,7 +14,7 @@ import org.rev317.api.methods.Walking;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class Tile implements TileFlags {
|
public final class Tile implements TileFlags, Locatable {
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
private int z;
|
private int z;
|
||||||
@@ -47,10 +48,18 @@ public final class Tile implements TileFlags {
|
|||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets region x
|
||||||
|
* @return region x
|
||||||
|
*/
|
||||||
public final int getRegionX() {
|
public final int getRegionX() {
|
||||||
return x - Game.getBaseX();
|
return x - Game.getBaseX();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets region y
|
||||||
|
* @return region y
|
||||||
|
*/
|
||||||
public final int getRegionY() {
|
public final int getRegionY() {
|
||||||
return y - Game.getBaseY();
|
return y - Game.getBaseY();
|
||||||
}
|
}
|
||||||
@@ -64,6 +73,11 @@ public final class Tile implements TileFlags {
|
|||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public final int distanceTo() {
|
public final int distanceTo() {
|
||||||
return (int) Calculations.distanceTo(this);
|
return (int) Calculations.distanceTo(this);
|
||||||
}
|
}
|
||||||
@@ -114,28 +128,44 @@ public final class Tile implements TileFlags {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if this tile is walkable
|
* Determines if this tile is walkable
|
||||||
* @return <b>true</b> if this tile is walkable, otherwise <b>false</b>.
|
* @return <code>true</code> if this tile is walkable, otherwise <code>false</code>
|
||||||
*/
|
*/
|
||||||
public boolean isWalkable() {
|
public boolean isWalkable() {
|
||||||
return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & 256) == 0;
|
return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & 256) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Determines if this tile is reachable
|
||||||
* @param isObject
|
* @param isObject whether this tile is an object tile
|
||||||
* @return
|
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
|
||||||
*/
|
*/
|
||||||
public boolean isReachable(boolean isObject) {
|
public boolean isReachable(boolean isObject) {
|
||||||
Tile current = Players.getMyPlayer().getLocation();
|
Tile current = Players.getMyPlayer().getLocation();
|
||||||
return Calculations.dijkstraDist(current.getRegionX(), current.getRegionY(), getRegionX(), getRegionY(), isObjectTile()) > -1;
|
return Calculations.dijkstraDist(current.getRegionX(), current.getRegionY(), getRegionX(), getRegionY(), isObjectTile()) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if this tile is reachable
|
||||||
|
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
|
||||||
|
*/
|
||||||
public boolean isReachable() {
|
public boolean isReachable() {
|
||||||
return isReachable(isObjectTile());
|
return isReachable(isObjectTile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if this tile is an object tile
|
||||||
|
* @return <code>true</code> if this tile is an object tile, otherwise <code>false</code>
|
||||||
|
*/
|
||||||
public boolean isObjectTile() {
|
public boolean isObjectTile() {
|
||||||
return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & OBJECT_TILE) != 0;
|
return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & OBJECT_TILE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Tile getLocation() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package org.rev317.debug;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
|
|
||||||
|
public class DActions extends AbstractDebugger {
|
||||||
|
private static boolean enabled;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
enabled = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean debugActions() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.rev317.debug;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
|
import org.rev317.api.methods.Players;
|
||||||
|
|
||||||
|
public class DAnimation extends AbstractDebugger {
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
Context.getInstance().getPaintDebugger().addLine("Animation: " + Players.getMyPlayer().getAnimation());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
enabled = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package org.rev317.debug;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
|
import org.rev317.api.methods.Game;
|
||||||
|
import org.rev317.api.methods.Players;
|
||||||
|
import org.rev317.api.wrappers.Tile;
|
||||||
|
|
||||||
|
public class DCollisionFlags extends AbstractDebugger {
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
PaintDebugger p = Context.getInstance().getPaintDebugger();
|
||||||
|
Tile location = Players.getMyPlayer().getLocation();
|
||||||
|
Tile north = new Tile(location.getX(), location.getY() + 1);
|
||||||
|
Tile south = new Tile(location.getX(), location.getY() - 1);
|
||||||
|
Tile west = new Tile(location.getX() - 1, location.getY());
|
||||||
|
Tile east = new Tile(location.getX() + 1, location.getY());
|
||||||
|
int flag = Game.getCollisionFlags()[location.getRegionX()][location.getRegionY()];
|
||||||
|
p.addLine("Collision flag: 0x" + String.format("%X", flag));
|
||||||
|
p.addLine("Reachable: [ cur: " + location.isReachable() + ", north: " + north.isReachable() + ", south: " + south.isReachable() + ", east: " + east.isReachable() + ", west: " + west.isReachable() + " ]");
|
||||||
|
p.addLine("Walkable: [ cur: " + location.isWalkable() + ", north: " + north.isWalkable() + ", south: " + south.isWalkable() + ", east: " + east.isWalkable() + ", west: " + west.isWalkable() + " ]");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
enabled = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package org.rev317.debug;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
|
import org.rev317.api.methods.GroundItems;
|
||||||
|
import org.rev317.api.wrappers.GroundItem;
|
||||||
|
|
||||||
|
public class DGroundItems extends AbstractDebugger {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
GroundItem[] items = GroundItems.getNearest();
|
||||||
|
if(items == null || items.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(GroundItem item : items) {
|
||||||
|
System.out.println("ID: " + item.getId() + " Location: " + item.getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.rev317.debug;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
|
import org.rev317.api.methods.Game;
|
||||||
|
|
||||||
|
public class DInterfaces extends AbstractDebugger {
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
PaintDebugger p = Context.getInstance().getPaintDebugger();
|
||||||
|
p.addLine("Open interface: " + Game.getOpenInterfaceId());
|
||||||
|
p.addLine("Open back dialog: " + Game.getOpenBackDialogId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
enabled = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.rev317.debug;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
|
import org.rev317.api.methods.Game;
|
||||||
|
import org.rev317.api.methods.Players;
|
||||||
|
|
||||||
|
public class DMap extends AbstractDebugger {
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
PaintDebugger p = Context.getInstance().getPaintDebugger();
|
||||||
|
p.addLine("Location: " + Players.getMyPlayer().getLocation());
|
||||||
|
p.addLine("Plane: " + Game.getPlane());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
enabled = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.rev317.debug;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
|
import org.rev317.api.methods.Npcs;
|
||||||
|
import org.rev317.api.wrappers.Npc;
|
||||||
|
|
||||||
|
public class DNpcs extends AbstractDebugger {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
for(Npc n : Npcs.getNearest()) {
|
||||||
|
System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.rev317.debug;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
|
import org.rev317.api.methods.SceneObjects;
|
||||||
|
import org.rev317.api.wrappers.SceneObject;
|
||||||
|
|
||||||
|
public class DSceneObjects extends AbstractDebugger {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
SceneObject[] objects = SceneObjects.getNearest();
|
||||||
|
for(SceneObject object : objects) {
|
||||||
|
System.out.println("ID: " + object.getId() + " UID: " + object.getHash() + " Location: " + object.getLocation() + " Distance: " + object.distanceTo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
package org.rev317.script;
|
||||||
|
|
||||||
|
import java.awt.AWTEvent;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.environment.api.interfaces.Paintable;
|
||||||
|
import org.parabot.environment.scripts.Script;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Everel
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ScriptEngine {
|
||||||
|
private static HashMap<Context, ScriptEngine> instances = new HashMap<Context, ScriptEngine>();
|
||||||
|
private ArrayList<MouseListener> mouseListeners;
|
||||||
|
private ArrayList<MouseMotionListener> mouseMotionListeners;
|
||||||
|
//private ArrayList<MessageListener> messageListeners;
|
||||||
|
|
||||||
|
private Script script = null;
|
||||||
|
|
||||||
|
private ScriptEngine() {
|
||||||
|
this.mouseListeners = new ArrayList<MouseListener>();
|
||||||
|
this.mouseMotionListeners = new ArrayList<MouseMotionListener>();
|
||||||
|
//this.messageListeners = new ArrayList<MessageListener>();
|
||||||
|
instances.put(Context.getInstance(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ScriptEngine getInstance() {
|
||||||
|
final ScriptEngine engine = instances.get(Context.getInstance());
|
||||||
|
if(engine != null) {
|
||||||
|
return engine;
|
||||||
|
}
|
||||||
|
return new ScriptEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMouseListener(MouseListener mouseListener) {
|
||||||
|
mouseListeners.add(mouseListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMouseListener(MouseListener mouseListener) {
|
||||||
|
mouseListeners.remove(mouseListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearMouseListeners() {
|
||||||
|
mouseListeners.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMouseMotionListener(MouseMotionListener mouseMotionListener) {
|
||||||
|
mouseMotionListeners.add(mouseMotionListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMouseMotionListener(MouseMotionListener mouseMotionListener) {
|
||||||
|
mouseMotionListeners.remove(mouseMotionListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearMouseMotionListeners() {
|
||||||
|
mouseMotionListeners.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public void addMessageListener(MessageListener messageListener) {
|
||||||
|
messageListeners.add(messageListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMessageListener(MessageListener messageListener) {
|
||||||
|
messageListeners.remove(messageListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearMessageListeners() {
|
||||||
|
messageListeners.clear();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void setScript(final Script script) {
|
||||||
|
this.script = script;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unload() {
|
||||||
|
clearMouseListeners();
|
||||||
|
clearMouseMotionListeners();
|
||||||
|
//clearMessageListeners();
|
||||||
|
if(script instanceof Paintable) {
|
||||||
|
Context.getInstance().removePaintable((Paintable)script);
|
||||||
|
}
|
||||||
|
this.script = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
if(script == null) {
|
||||||
|
throw new RuntimeException("Script is null");
|
||||||
|
}
|
||||||
|
if(script instanceof MouseListener) {
|
||||||
|
addMouseListener((MouseListener)script);
|
||||||
|
}
|
||||||
|
if(script instanceof MouseMotionListener) {
|
||||||
|
addMouseMotionListener((MouseMotionListener)script);
|
||||||
|
}
|
||||||
|
/*if(script instanceof MessageListener) {
|
||||||
|
addMessageListener((MessageListener)script);
|
||||||
|
}*/
|
||||||
|
if(script instanceof Paintable) {
|
||||||
|
Context.getInstance().addPaintable((Paintable)script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispatch(AWTEvent event) {
|
||||||
|
if(this.script == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!(event instanceof MouseEvent)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final MouseEvent e = (MouseEvent) event;
|
||||||
|
for(final MouseListener m : mouseListeners) {
|
||||||
|
switch(e.getID()) {
|
||||||
|
case MouseEvent.MOUSE_CLICKED:
|
||||||
|
m.mouseClicked(e);
|
||||||
|
break;
|
||||||
|
case MouseEvent.MOUSE_ENTERED:
|
||||||
|
m.mouseEntered(e);
|
||||||
|
break;
|
||||||
|
case MouseEvent.MOUSE_EXITED:
|
||||||
|
m.mouseExited(e);
|
||||||
|
break;
|
||||||
|
case MouseEvent.MOUSE_PRESSED:
|
||||||
|
m.mousePressed(e);
|
||||||
|
break;
|
||||||
|
case MouseEvent.MOUSE_RELEASED:
|
||||||
|
m.mouseReleased(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(final MouseMotionListener m : mouseMotionListeners) {
|
||||||
|
switch(e.getID()) {
|
||||||
|
case MouseEvent.MOUSE_MOVED:
|
||||||
|
m.mouseMoved(e);
|
||||||
|
break;
|
||||||
|
case MouseEvent.MOUSE_DRAGGED:
|
||||||
|
m.mouseDragged(e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public void dispatch(MessageEvent event) {
|
||||||
|
for(final MessageListener messageListener : messageListeners) {
|
||||||
|
messageListener.messageReceived(event);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package org.rev317.ui;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
|
import org.rev317.debug.*;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
|
|
||||||
|
|
||||||
|
public class BotMenu implements ActionListener {
|
||||||
|
|
||||||
|
public BotMenu(JMenuBar bar) {
|
||||||
|
PaintDebugger debugger = Context.getInstance().getPaintDebugger();
|
||||||
|
|
||||||
|
JMenu debug = new JMenu("Debug");
|
||||||
|
|
||||||
|
JMenuItem map = newItem("Map");
|
||||||
|
JMenuItem animation = newItem("Animation");
|
||||||
|
JMenuItem objects = newItem("Objects");
|
||||||
|
JMenuItem npcs = newItem("Npcs");
|
||||||
|
JMenuItem items = newItem("GroundItems");
|
||||||
|
JMenuItem interfaces = newItem("Interfaces");
|
||||||
|
JMenuItem flags = newItem("Collision flags");
|
||||||
|
JMenuItem actions = newItem("Actions");
|
||||||
|
|
||||||
|
debugger.addDebugger("Actions", new DActions());
|
||||||
|
debugger.addDebugger("Animation", new DAnimation());
|
||||||
|
debugger.addDebugger("Map", new DMap());
|
||||||
|
debugger.addDebugger("Objects", new DSceneObjects());
|
||||||
|
debugger.addDebugger("Npcs", new DNpcs());
|
||||||
|
debugger.addDebugger("GroundItems", new DGroundItems());
|
||||||
|
debugger.addDebugger("Interfaces", new DInterfaces());
|
||||||
|
debugger.addDebugger("Collision flags", new DCollisionFlags());
|
||||||
|
|
||||||
|
debug.add(actions);
|
||||||
|
debug.add(map);
|
||||||
|
debug.add(animation);
|
||||||
|
debug.add(objects);
|
||||||
|
debug.add(npcs);
|
||||||
|
debug.add(items);
|
||||||
|
debug.add(interfaces);
|
||||||
|
debug.add(flags);
|
||||||
|
|
||||||
|
bar.add(debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JMenuItem newItem(String name) {
|
||||||
|
JMenuItem item = new JCheckBoxMenuItem(name);
|
||||||
|
item.addActionListener(this);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Context.getInstance().getPaintDebugger().toggle(e.getActionCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user