mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-10 10:20:44 -07:00
Interface debugging
This commit is contained in:
parent
8dfbcb9423
commit
d69ac42050
15 changed files with 149 additions and 31 deletions
|
|
@ -0,0 +1,91 @@
|
|||
package InterfaceDebugPlugin;
|
||||
|
||||
import plugin.Plugin;
|
||||
import plugin.api.*;
|
||||
import rt4.Component;
|
||||
import rt4.GameShell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class plugin extends Plugin {
|
||||
private boolean isEnabled;
|
||||
private boolean isVerbose;
|
||||
|
||||
private ArrayList<Integer> activeVarps = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void ComponentDraw(int componentIndex, Component component, int screenX, int screenY) {
|
||||
if (!isEnabled) return;
|
||||
|
||||
FontColor color = new FontColor((((component.type * 50) << 16) | 255 << 8 | Math.min(component.type * 50, 255)));
|
||||
|
||||
if (!isVerbose) {
|
||||
if
|
||||
(
|
||||
component.type != 0
|
||||
&& component.type != 9
|
||||
&& (component.type != 5
|
||||
|| (component.onOptionClick != null
|
||||
|| component.onMouseOver != null
|
||||
|| component.onHold != null
|
||||
|| component.varpTriggers != null
|
||||
|| component.onVarcstrTransmit != null
|
||||
|| component.onVarcTransmit != null
|
||||
|| component.cs1ComparisonOpcodes != null))
|
||||
|| component.hidden
|
||||
) return;
|
||||
}
|
||||
|
||||
API.DrawText(
|
||||
FontType.SMALL,
|
||||
color,
|
||||
TextModifier.LEFT,
|
||||
componentIndex + "",
|
||||
screenX,
|
||||
screenY
|
||||
);
|
||||
|
||||
if (component.varpTriggers != null) {
|
||||
Arrays.stream(component.varpTriggers).forEach(varp -> { if(!activeVarps.contains(varp)) activeVarps.add(varp); });
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Draw(long timeDelta) {
|
||||
if (!isEnabled) return;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Varps: [");
|
||||
|
||||
for (int varp : activeVarps) sb.append(varp).append(" ");
|
||||
|
||||
sb.append("]");
|
||||
|
||||
API.DrawText(
|
||||
FontType.SMALL,
|
||||
FontColor.YELLOW,
|
||||
TextModifier.CENTER,
|
||||
sb.toString(),
|
||||
GameShell.canvasWidth / 2 - 100,
|
||||
20
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ProcessCommand(String commandStr, String[] args) {
|
||||
if (!API.PlayerHasPrivilege(Privileges.JMOD)) return;
|
||||
|
||||
if (commandStr.equalsIgnoreCase("::debug_iface")){
|
||||
isEnabled = !isEnabled;
|
||||
}
|
||||
|
||||
if (commandStr.equalsIgnoreCase("::debug_iface_verbose")) {
|
||||
isVerbose = !isVerbose;
|
||||
}
|
||||
|
||||
if (commandStr.equalsIgnoreCase("::clear_iface_varps")) {
|
||||
activeVarps.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
AUTHOR='Me'
|
||||
DESCRIPTION='Make sure to rename both the MyPlugin folder and the package statement in plugin.java!
|
||||
VERSION=-1.1
|
||||
Loading…
Add table
Add a link
Reference in a new issue