api/client: various (MenuEntry api stuff, agility/translate plugin stuff to use that) (#1748)
* Standardize MenuEntry methods, make MenuEntry events extend MenuEntry * Make agility plugin only change entries it needs to * Clean up chat translator by a lot, also implement cloneable instead of just adding a ranodm copy method smh * actions: allow slash in PR title * devtools: Fix checkstyle * examineplugin: Fix tests
This commit is contained in:
@@ -1839,4 +1839,22 @@ public interface Client extends GameShell
|
||||
* @param oldWidth old width
|
||||
*/
|
||||
void scaleSprite(int[] canvas, int[] pixels, int color, int pixelX, int pixelY, int canvasIdx, int canvasOffset, int newWidth, int newHeight, int pixelWidth, int pixelHeight, int oldWidth);
|
||||
|
||||
/**
|
||||
* Get the MenuEntry at client.getMenuOptionCount() - 1
|
||||
*
|
||||
* This is useful so you don't have to use getMenuEntries,
|
||||
* which will create a big array, when you only want to change
|
||||
* the left click one.
|
||||
*/
|
||||
MenuEntry getLeftClickMenuEntry();
|
||||
|
||||
/**
|
||||
* Set the MenuEntry at client.getMenuOptionCount() - 1
|
||||
*
|
||||
* This is useful so you don't have to use setMenuEntries,
|
||||
* which will arraycopy a big array to several smaller arrays lol,
|
||||
* when you only want to change the left click one.
|
||||
*/
|
||||
void setLeftClickMenuEntry(MenuEntry entry);
|
||||
}
|
||||
@@ -24,17 +24,15 @@
|
||||
*/
|
||||
package net.runelite.api;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* A menu entry in a right-click menu.
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class MenuEntry
|
||||
public class MenuEntry implements Cloneable
|
||||
{
|
||||
/**
|
||||
* The option text added to the menu (ie. "Walk here", "Use").
|
||||
@@ -46,7 +44,6 @@ public class MenuEntry
|
||||
* If the option does not apply to any target, this field
|
||||
* will be set to empty string.
|
||||
*/
|
||||
@Setter(AccessLevel.NONE)
|
||||
private String target;
|
||||
/**
|
||||
* An identifier value for the target of the action.
|
||||
@@ -84,21 +81,24 @@ public class MenuEntry
|
||||
this.forceLeftClick = forceLeftClick;
|
||||
}
|
||||
|
||||
public static MenuEntry copy(MenuEntry src)
|
||||
@Override
|
||||
public MenuEntry clone()
|
||||
{
|
||||
return new MenuEntry(
|
||||
src.getOption(),
|
||||
src.getTarget(),
|
||||
src.getIdentifier(),
|
||||
src.getOpcode(),
|
||||
src.getParam0(),
|
||||
src.getParam1(),
|
||||
src.isForceLeftClick()
|
||||
);
|
||||
try
|
||||
{
|
||||
return (MenuEntry) super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException ex)
|
||||
{
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTarget(String target)
|
||||
/**
|
||||
* Get opcode, but as it's enum counterpart
|
||||
*/
|
||||
public MenuOpcode getMenuOpcode()
|
||||
{
|
||||
this.target = target;
|
||||
return MenuOpcode.of(getOpcode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,21 +24,18 @@
|
||||
*/
|
||||
package net.runelite.api.events;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.MenuEntry;
|
||||
|
||||
/**
|
||||
* An event when a new entry is added to a right-click menu.
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class MenuEntryAdded implements Event
|
||||
public class MenuEntryAdded extends MenuEntry implements Event
|
||||
{
|
||||
/**
|
||||
* The MenuEntry object that was actually added
|
||||
*/
|
||||
private final MenuEntry menuEntry;
|
||||
public MenuEntryAdded(String option, String target, int identifier, int opcode, int param0, int param1, boolean forceLeftClick)
|
||||
{
|
||||
super(option, target, identifier, opcode, param0, param1, forceLeftClick);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is set to true client mixin will update
|
||||
@@ -47,40 +44,11 @@ public class MenuEntryAdded implements Event
|
||||
* Checks if count is the same, but doesn't check if there's
|
||||
* been multiple changes
|
||||
*/
|
||||
private boolean wasModified;
|
||||
@Setter
|
||||
private boolean modified;
|
||||
|
||||
public String getOption()
|
||||
public boolean hasBeenModified()
|
||||
{
|
||||
return menuEntry.getOption();
|
||||
}
|
||||
|
||||
public String getTarget()
|
||||
{
|
||||
return menuEntry.getTarget();
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
return menuEntry.getOpcode();
|
||||
}
|
||||
|
||||
public int getIdentifier()
|
||||
{
|
||||
return menuEntry.getIdentifier();
|
||||
}
|
||||
|
||||
public int getActionParam0()
|
||||
{
|
||||
return menuEntry.getParam0();
|
||||
}
|
||||
|
||||
public int getActionParam1()
|
||||
{
|
||||
return menuEntry.getParam1();
|
||||
}
|
||||
|
||||
public boolean isForceLeftClick()
|
||||
{
|
||||
return menuEntry.isForceLeftClick();
|
||||
return modified;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
package net.runelite.api.events;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.MenuOpcode;
|
||||
import net.runelite.api.MenuEntry;
|
||||
|
||||
/**
|
||||
@@ -41,88 +41,23 @@ import net.runelite.api.MenuEntry;
|
||||
* By default, when there is no action performed when left-clicking,
|
||||
* it seems that this event still triggers with the "Cancel" action.
|
||||
*/
|
||||
@Data
|
||||
public class MenuOptionClicked implements Event
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MenuOptionClicked extends MenuEntry implements Event
|
||||
{
|
||||
public MenuOptionClicked(MenuEntry entry)
|
||||
public MenuOptionClicked(String option, String target, int identifier, int opcode, int param0, int param1, boolean forceLeftClick)
|
||||
{
|
||||
menuEntry = entry;
|
||||
super(option, target, identifier, opcode, param0, param1, forceLeftClick);
|
||||
authentic = true;
|
||||
}
|
||||
|
||||
public MenuOptionClicked(MenuEntry entry, boolean authentic, int mouseButton)
|
||||
public MenuOptionClicked(String option, String target, int identifier, int opcode, int param0, int param1, boolean forceLeftClick, boolean authentic, int mouseButton)
|
||||
{
|
||||
menuEntry = entry;
|
||||
super(option, target, identifier, opcode, param0, param1, forceLeftClick);
|
||||
this.authentic = authentic;
|
||||
this.mouseButton = mouseButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual MenuEntry object representing what was clicked
|
||||
*/
|
||||
private MenuEntry menuEntry;
|
||||
|
||||
/**
|
||||
* The option text added to the menu.
|
||||
*/
|
||||
public String getOption()
|
||||
{
|
||||
return menuEntry.getOption();
|
||||
}
|
||||
|
||||
/**
|
||||
* The target of the action.
|
||||
*/
|
||||
public String getTarget()
|
||||
{
|
||||
return menuEntry.getTarget();
|
||||
}
|
||||
|
||||
/**
|
||||
* MenuOpcode but int-ish
|
||||
*/
|
||||
public int getOpcode()
|
||||
{
|
||||
return menuEntry.getOpcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the object, actor, or item that the interaction targets.
|
||||
*/
|
||||
public int getIdentifier()
|
||||
{
|
||||
return menuEntry.getIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* The action parameter used in the click.
|
||||
*/
|
||||
public int getActionParam0()
|
||||
{
|
||||
return menuEntry.getParam0();
|
||||
}
|
||||
|
||||
/**
|
||||
* shit docs
|
||||
*/
|
||||
public int getActionParam1()
|
||||
{
|
||||
return menuEntry.getParam1();
|
||||
}
|
||||
|
||||
public boolean isForceLeftClick()
|
||||
{
|
||||
return menuEntry.isForceLeftClick();
|
||||
}
|
||||
|
||||
/**
|
||||
* The action performed.
|
||||
*/
|
||||
public MenuOpcode getMenuOpcode()
|
||||
{
|
||||
return MenuOpcode.of(getOpcode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the event has been consumed by a subscriber.
|
||||
*/
|
||||
@@ -148,6 +83,17 @@ public class MenuOptionClicked implements Event
|
||||
/**
|
||||
* Whether or not the event is authentic.
|
||||
*/
|
||||
@Setter(AccessLevel.PRIVATE)
|
||||
private boolean authentic;
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final boolean authentic;
|
||||
|
||||
public void setMenuEntry(MenuEntry e)
|
||||
{
|
||||
setOption(e.getOption());
|
||||
setTarget(e.getTarget());
|
||||
setIdentifier(e.getIdentifier());
|
||||
setOpcode(e.getOpcode());
|
||||
setParam0(e.getParam0());
|
||||
setParam1(e.getParam1());
|
||||
setForceLeftClick(e.isForceLeftClick());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user