mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
Merge pull request #20 from Ceikry/plugin-reload-on-mode-change
Plugin reload on mode change
This commit is contained in:
commit
dab7533f29
4 changed files with 27 additions and 2 deletions
|
|
@ -5,6 +5,10 @@ import plugin.api.MiniMenuEntry;
|
||||||
import plugin.api.MiniMenuType;
|
import plugin.api.MiniMenuType;
|
||||||
import rt4.*;
|
import rt4.*;
|
||||||
|
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseWheelListener;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
|
@ -29,6 +33,19 @@ public class PluginRepository {
|
||||||
public static int lastMiniMenu;
|
public static int lastMiniMenu;
|
||||||
|
|
||||||
public static void reloadPlugins() {
|
public static void reloadPlugins() {
|
||||||
|
for (KeyAdapter k : API.registeredKeyListeners) {
|
||||||
|
GameShell.canvas.removeKeyListener(k);
|
||||||
|
}
|
||||||
|
for (MouseAdapter m : API.registeredMouseListeners) {
|
||||||
|
GameShell.canvas.removeMouseListener(m);
|
||||||
|
GameShell.canvas.removeMouseMotionListener(m);
|
||||||
|
}
|
||||||
|
for (MouseWheelListener mw : API.registeredWheelListeners) {
|
||||||
|
GameShell.canvas.removeMouseWheelListener(mw);
|
||||||
|
}
|
||||||
|
API.registeredWheelListeners.clear();
|
||||||
|
API.registeredMouseListeners.clear();
|
||||||
|
API.registeredKeyListeners.clear();
|
||||||
loadedPlugins.clear();
|
loadedPlugins.clear();
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ import static rt4.MathUtils.clamp;
|
||||||
public class API {
|
public class API {
|
||||||
public static Runnable[] miniMenuCustomActions = new Runnable[10];
|
public static Runnable[] miniMenuCustomActions = new Runnable[10];
|
||||||
public static int customMiniMenuIndex = 0;
|
public static int customMiniMenuIndex = 0;
|
||||||
|
public static ArrayList<KeyAdapter> registeredKeyListeners = new ArrayList<>();
|
||||||
|
public static ArrayList<MouseAdapter> registeredMouseListeners = new ArrayList<>();
|
||||||
|
public static ArrayList<MouseWheelListener> registeredWheelListeners = new ArrayList<>();
|
||||||
|
|
||||||
public static void DrawText(FontType fontType, FontColor color, TextModifier mod, String text, int screenX, int screenY) {
|
public static void DrawText(FontType fontType, FontColor color, TextModifier mod, String text, int screenX, int screenY) {
|
||||||
JagString js = JagString.of(text);
|
JagString js = JagString.of(text);
|
||||||
|
|
@ -127,14 +130,17 @@ public class API {
|
||||||
public static void AddMouseListener(MouseAdapter m) {
|
public static void AddMouseListener(MouseAdapter m) {
|
||||||
GameShell.canvas.addMouseListener(m);
|
GameShell.canvas.addMouseListener(m);
|
||||||
GameShell.canvas.addMouseMotionListener(m);
|
GameShell.canvas.addMouseMotionListener(m);
|
||||||
|
registeredMouseListeners.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddMouseWheelListener(MouseWheelListener mw) {
|
public static void AddMouseWheelListener(MouseWheelListener mw) {
|
||||||
GameShell.canvas.addMouseWheelListener(mw);
|
GameShell.canvas.addMouseWheelListener(mw);
|
||||||
|
registeredWheelListeners.add(mw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddKeyboardListener(KeyAdapter k) {
|
public static void AddKeyboardListener(KeyAdapter k) {
|
||||||
GameShell.canvas.addKeyListener(k);
|
GameShell.canvas.addKeyListener(k);
|
||||||
|
registeredKeyListeners.add(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetCameraYaw(double targetYaw) {
|
public static void SetCameraYaw(double targetYaw) {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import org.openrs2.deob.annotation.OriginalArg;
|
||||||
import org.openrs2.deob.annotation.OriginalClass;
|
import org.openrs2.deob.annotation.OriginalClass;
|
||||||
import org.openrs2.deob.annotation.OriginalMember;
|
import org.openrs2.deob.annotation.OriginalMember;
|
||||||
import org.openrs2.deob.annotation.Pc;
|
import org.openrs2.deob.annotation.Pc;
|
||||||
|
import plugin.PluginRepository;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
|
@ -235,6 +236,7 @@ public final class DisplayMode {
|
||||||
InterfaceList.aBooleanArray100[local466] = true;
|
InterfaceList.aBooleanArray100[local466] = true;
|
||||||
}
|
}
|
||||||
GameShell.fullRedraw = true;
|
GameShell.fullRedraw = true;
|
||||||
|
PluginRepository.reloadPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
@OriginalMember(owner = "client!ab", name = "c", descriptor = "(B)[Lclient!od;")
|
@OriginalMember(owner = "client!ab", name = "c", descriptor = "(B)[Lclient!od;")
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ class plugin : Plugin() {
|
||||||
override fun mouseClicked(e: MouseEvent?) {
|
override fun mouseClicked(e: MouseEvent?) {
|
||||||
e ?: return
|
e ?: return
|
||||||
|
|
||||||
val width = API.GetWindowDimensions().width;
|
/* val width = API.GetWindowDimensions().width;
|
||||||
val compassBordersX = intArrayOf(width - 165, width - 125)
|
val compassBordersX = intArrayOf(width - 165, width - 125)
|
||||||
val compassBordersY = intArrayOf(0, 45)
|
val compassBordersY = intArrayOf(0, 45)
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ class plugin : Plugin() {
|
||||||
{
|
{
|
||||||
API.SetCameraPitch(defaultCameraPYZ.first)
|
API.SetCameraPitch(defaultCameraPYZ.first)
|
||||||
API.SetCameraYaw(defaultCameraPYZ.second)
|
API.SetCameraYaw(defaultCameraPYZ.second)
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mousePressed(e: MouseEvent?) {
|
override fun mousePressed(e: MouseEvent?) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue