mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
Added toggle resizeable SD plugin
This also fixes two CMEs, very cool.
This commit is contained in:
parent
1a62b1775a
commit
47df7bd3d3
3 changed files with 59 additions and 17 deletions
|
|
@ -12,10 +12,7 @@ import java.awt.event.MouseWheelListener;
|
|||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -133,7 +130,8 @@ public class PluginRepository {
|
|||
}
|
||||
|
||||
public static void Draw() {
|
||||
loadedPlugins.values().forEach(Plugin::_draw);
|
||||
List<Plugin> pluginsSnapshot = new ArrayList<>(loadedPlugins.values());
|
||||
pluginsSnapshot.forEach(Plugin::_draw);
|
||||
}
|
||||
|
||||
public static void NPCOverheadDraw(Npc npc, int screenX, int screenY) {
|
||||
|
|
@ -147,7 +145,9 @@ public class PluginRepository {
|
|||
public static void ProcessCommand(JagString commandStr) {
|
||||
String[] tokens = commandStr.toString().split(" ");
|
||||
String[] args = Arrays.copyOfRange(tokens, 1, tokens.length);
|
||||
loadedPlugins.values().forEach((plugin) -> plugin.ProcessCommand(tokens[0], args));
|
||||
List<Plugin> pluginsSnapshot = new ArrayList<>(loadedPlugins.values());
|
||||
|
||||
pluginsSnapshot.forEach((plugin) -> plugin.ProcessCommand(tokens[0], args));
|
||||
}
|
||||
|
||||
public static void ComponentDraw(int componentIndex, Component component, int screenX, int screenY) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ public class Cheat {
|
|||
@OriginalMember(owner = "client!jg", name = "e", descriptor = "Z")
|
||||
public static boolean qaOpTest = false;
|
||||
public static final JagString RELOADPLUGINS = JagString.parse("::reloadplugins");
|
||||
public static final JagString USERESIZABLESD = JagString.parse("::resizablesd");
|
||||
|
||||
@OriginalMember(owner = "client!en", name = "a", descriptor = "(IIIB)V")
|
||||
public static void teleport(@OriginalArg(0) int arg0, @OriginalArg(1) int arg1, @OriginalArg(2) int arg2) {
|
||||
|
|
@ -232,16 +231,6 @@ public class Cheat {
|
|||
shiftClick = true;
|
||||
}
|
||||
}
|
||||
if(arg0.equalsIgnoreCase(USERESIZABLESD)){
|
||||
DisplayMode.resizableSD = !DisplayMode.resizableSD;
|
||||
if(!DisplayMode.resizableSD){
|
||||
// Revert to fixed
|
||||
DisplayMode.setWindowMode(true, 0, -1, -1);
|
||||
} else {
|
||||
// use resizable
|
||||
DisplayMode.setWindowMode(true, 0, GameShell.frameWidth, GameShell.frameHeight);
|
||||
}
|
||||
}
|
||||
|
||||
if (arg0.equalsIgnoreCase(RELOADPLUGINS)) {
|
||||
PluginRepository.reloadPlugins();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
package ToggleResizableSD
|
||||
|
||||
import plugin.Plugin
|
||||
import plugin.annotations.PluginMeta
|
||||
import plugin.api.API
|
||||
import rt4.DisplayMode
|
||||
import rt4.GameShell
|
||||
import java.awt.event.KeyAdapter
|
||||
import java.awt.event.KeyEvent
|
||||
|
||||
@PluginMeta (
|
||||
author = "ipkpjersi",
|
||||
description = "Allows you to use F12 to toggle resizable SD.",
|
||||
version = 1.0
|
||||
)
|
||||
class plugin : Plugin() {
|
||||
var toggleResize = false
|
||||
override fun Init() {
|
||||
API.AddKeyboardListener(object : KeyAdapter() {
|
||||
override fun keyPressed(e: KeyEvent) {
|
||||
if (e.keyCode == KeyEvent.VK_F12) {
|
||||
toggleResize = true
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun ProcessCommand(commandStr: String, args: Array<out String>?) {
|
||||
when(commandStr.toLowerCase()) {
|
||||
"::resizablesd" -> {
|
||||
toggleResize = true //We could call toggleResizableSd() directly here, but it's not necessary.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun toggleResizableSd() {
|
||||
DisplayMode.resizableSD = !DisplayMode.resizableSD;
|
||||
if(!DisplayMode.resizableSD){
|
||||
//Revert to fixed
|
||||
DisplayMode.setWindowMode(true, 0, -1, -1)
|
||||
} else {
|
||||
//Use resizable
|
||||
DisplayMode.setWindowMode(true, 0, GameShell.frameWidth, GameShell.frameHeight)
|
||||
}
|
||||
}
|
||||
|
||||
override fun Draw(timeDelta: Long) {
|
||||
if (toggleResize) {
|
||||
toggleResizableSd()
|
||||
toggleResize = false
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue