runelite-api: Add some more documentation

This commit is contained in:
Max Weber
2019-10-10 05:49:14 -06:00
parent 019ed814ea
commit 5acdcae75d
16 changed files with 88 additions and 201 deletions

View File

@@ -25,119 +25,39 @@
package net.runelite.api; package net.runelite.api;
/** /**
* Represents an indexed sprite. * Represents an paletted sprite.
*/ */
public interface IndexedSprite public interface IndexedSprite
{ {
/** /**
* Gets the pixels contained by the sprite. * The bitmap of this sprite. Each value is an index into {@link #getPalette()}.
* * 0 is transparent
* @return the sprite pixels
*/ */
byte[] getPixels(); byte[] getPixels();
/**
* Sets the pixels contained by the sprite.
*
* @param pixels the new sprite pixels
*/
void setPixels(byte[] pixels); void setPixels(byte[] pixels);
/** /**
* Gets the color palette for the sprites pixels. * The color palette in RGB. The zero index is unused.
*
* @return the color palette
*/ */
int[] getPalette(); int[] getPalette();
/**
* Sets the color palette for the sprites pixels.
*
* @param palette the new color palette
*/
void setPalette(int[] palette); void setPalette(int[] palette);
/**
* Gets the offset of the sprite along the x-axis.
*
* @return the x-axis offset
*/
int getOffsetX(); int getOffsetX();
/**
* Sets the offset of the sprite along the x-axis.
*
* @param offsetX new x-axis offset
*/
void setOffsetX(int offsetX); void setOffsetX(int offsetX);
/**
* Gets the offset of the sprite along the y-axis.
*
* @return the y-axis offset
*/
int getOffsetY(); int getOffsetY();
/**
* Sets the offset of the sprite along the y-axis.
*
* @param offsetY new y-axis offset
*/
void setOffsetY(int offsetY); void setOffsetY(int offsetY);
/**
* Gets the width of the sprite.
*
* @return the width
*/
int getWidth(); int getWidth();
/**
* Sets the width of the sprite.
*
* @param width the new width
*/
void setWidth(int width); void setWidth(int width);
/**
* Gets the original width of the sprite.
*
* @return the width
*/
int getOriginalWidth();
/** int getHeight();
* Sets the original width of the sprite. void setHeight(int height);
*
* @param originalWidth the width int getOriginalWidth();
*/
void setOriginalWidth(int originalWidth); void setOriginalWidth(int originalWidth);
/**
* Gets the height of the sprite.
*
* @return the height
*/
int getHeight();
/**
* Sets the height of the sprite.
*
* @param height the height
*/
void setHeight(int height);
/**
* Gets the original height of the sprite.
*
* @return the height
*/
int getOriginalHeight(); int getOriginalHeight();
/**
* Sets the original height of the sprite.
*
* @param originalHeight the height
*/
void setOriginalHeight(int originalHeight); void setOriginalHeight(int originalHeight);
} }

View File

@@ -25,93 +25,69 @@
package net.runelite.api; package net.runelite.api;
/** /**
* Represents the template of a specific NPC type. * Information about a specific {@link NpcID}
*/ */
public interface NPCComposition public interface NPCComposition
{ {
/** /**
* Gets the name of the NPC. * Gets the name of the NPC.
*
* @return the name
*/ */
String getName(); String getName();
/** /**
* Gets the model IDs that compose this NPC. * Gets the model IDs that compose this NPC.
*
* @return the NPCs model IDs
*/ */
int[] getModels(); int[] getModels();
/** /**
* Gets an array of possible right-click menu actions that can be * The 5 menuops this NPC has when in world. Index 0 corresponds to
* performed on the NPC. * {@link MenuAction#NPC_FIRST_OPTION}, Index 2 to
* * {@link MenuAction#NPC_SECOND_OPTION} and so on.
* @return the menu actions
*/ */
String[] getActions(); String[] getActions();
/**
* Gets whether the NPC can be clicked.
*
* @return true if the NPC can be clicked, false otherwise
*/
boolean isClickable(); boolean isClickable();
/** /**
* Gets whether the NPC is visible on the mini-map. * Gets whether the NPC is visible on the mini-map.
*
* @return the mini-map visible state
*/ */
boolean isMinimapVisible(); boolean isMinimapVisible();
/**
* Gets whether the NPC is visible.
*
* @return the visible state
*/
boolean isVisible(); boolean isVisible();
/** /**
* Gets the ID of the NPC. * Gets the ID of the NPC.
* *
* @return the ID of the NPC
* @see NpcID * @see NpcID
*/ */
int getId(); int getId();
/** /**
* Gets the combat level of the NPC.
*
* @return the combat level, -1 if none * @return the combat level, -1 if none
*/ */
int getCombatLevel(); int getCombatLevel();
/** /**
* Gets the configuration data for the NPC. * Get the {@link NpcID}s of NPCs this can transform into, depending
* * on a {@link Varbits} or {@link VarPlayer}
* @return the configuration data
*/ */
int[] getConfigs(); int[] getConfigs();
/** /**
* Transforms this NPC into a new state, which may have a different ID. * Get the NPC composition the player's state says this NPC should
* transmogrify into.
* *
* @return the transformed composition * @throws NullPointerException if {@link #getConfigs()} is null
*/ */
NPCComposition transform(); NPCComposition transform();
/** /**
* Gets the size of the NPC. * How many tiles wide this NPC is
*
* @return the NPCs size
*/ */
int getSize(); int getSize();
/** /**
* Gets the displayed overhead icon of the NPC. * Gets the displayed overhead icon of the NPC.
*
* @return the overhead icon
*/ */
HeadIcon getOverheadIcon(); HeadIcon getOverheadIcon();
} }

View File

@@ -25,58 +25,52 @@
package net.runelite.api; package net.runelite.api;
/** /**
* Represents the template of a specific object. * Information about a specific {@link ObjectID}
*/ */
public interface ObjectComposition public interface ObjectComposition
{ {
/** /**
* Gets ID for the object. * Gets ID for the object.
* *
* @return the object ID * @see ObjectID
*/ */
int getId(); int getId();
/** /**
* Gets the name of the object. * Gets the name of the object.
*
* @return the object name
*/ */
String getName(); String getName();
/** /**
* Gets an array of possible right-click menu actions that can be * The 5 menuops this object has when in world. Index 0 corresponds to
* performed on the object. * {@link MenuAction#GAME_OBJECT_FIRST_OPTION}, Index 2 to
* * {@link MenuAction#GAME_OBJECT_SECOND_OPTION} and so on.
* @return the menu actions
*/ */
String[] getActions(); String[] getActions();
/** /**
* Gets the map scene ID for the object. * Gets the index of this object in the {@link Client#getMapScene()}
* * array, or -1 if it has no map scene icon
* @return the scene ID
*/ */
int getMapSceneId(); int getMapSceneId();
/** /**
* Gets the map icon ID for the object. * Gets the index of this object in the {@link Client#getMapIcons()}
* * array, or -1 if it has no full map icon
* @return the map icon ID
*/ */
int getMapIconId(); int getMapIconId();
/** /**
* Gets IDs for objects that are considered fakes of this object, * Get the {@link ObjectID}s of objects this can transform into, depending
* such as barrows walls. * on a {@link Varbits} or {@link VarPlayer}
*
* @return the impostor IDs
*/ */
int[] getImpostorIds(); int[] getImpostorIds();
/** /**
* Gets the impostor composition for this object. * Get the object composition the player's state says this object should
* transmogrify into.
* *
* @return the impostor * @throws NullPointerException if {@link #getImpostorIds()} is null
*/ */
ObjectComposition getImpostor(); ObjectComposition getImpostor();
} }

View File

@@ -30,21 +30,19 @@ public interface TextureProvider
/** /**
* Set the brightness for textures, clearing the texture cache. * Set the brightness for textures, clearing the texture cache.
* @param brightness *
* .9 is the darkest value available in the standard options
* .6 is the brightest value
*/ */
void setBrightness(double brightness); void setBrightness(double brightness);
/** /**
* Get all textures * Get all textures
*
* @return
*/ */
Texture[] getTextures(); Texture[] getTextures();
/** /**
* Get the pixels for a texture * Get the pixels for a texture
* @param textureId
* @return
*/ */
int[] load(int textureId); int[] load(int textureId);
} }

View File

@@ -30,17 +30,10 @@ package net.runelite.api;
public interface TileItem extends Renderable public interface TileItem extends Renderable
{ {
/** /**
* Gets the items ID.
*
* @return the ID of the item * @return the ID of the item
* @see ItemID * @see ItemID
*/ */
int getId(); int getId();
/**
* Gets the items quantity.
*
* @return the items quantity
*/
int getQuantity(); int getQuantity();
} }

View File

@@ -32,88 +32,65 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
/** /**
* Represents an object that a tile holds. * Represents an object on a Tile
*/ */
public interface TileObject public interface TileObject
{ {
/**
* Gets the hashed value of this object.
*
* @return the object hash
*/
long getHash(); long getHash();
/** /**
* Gets the x-axis coordinate of the object in local context. * Gets the x-axis coordinate of the object in local context.
* *
* @return the x-axis coordinate * @see LocalPoint
*/ */
int getX(); int getX();
/** /**
* Gets the y-axis coordinate of the object in local context. * Gets the y-axis coordinate of the object in local context.
* *
* @return the y-axis coordinate * @see LocalPoint
*/ */
int getY(); int getY();
/** /**
* Gets the plane of the tile that the object is on. * Gets the plane of the tile that the object is on.
*
* @return the tile plane
*/ */
int getPlane(); int getPlane();
/** /**
* Gets the ID of the object. * Gets the ID of the object.
* *
* @return the object ID * @see ObjectID
* @see NullObjectID
*/ */
int getId(); int getId();
/**
* Gets the location coordinate of the object in the world.
*
* @return the world location
*/
WorldPoint getWorldLocation(); WorldPoint getWorldLocation();
/**
* Gets the local location of the object.
*
* @return the local location
*/
LocalPoint getLocalLocation(); LocalPoint getLocalLocation();
/** /**
* Gets the upper-left canvas point where this object is drawn. * Calculates the position of the center of this tile on the canvas
*
* @return the canvas location
*/ */
Point getCanvasLocation(); Point getCanvasLocation();
/** /**
* Gets the upper-left canvas point where this object is drawn, * Calculates the position of the center of this tile on the canvas
* offset by the passed value.
* *
* @param zOffset the z-axis offset * @param zOffset Vertical offset to apply before projection
* @return the canvas location
*/ */
Point getCanvasLocation(int zOffset); Point getCanvasLocation(int zOffset);
/** /**
* Gets the polygon of the objects model as drawn on the canvas. * Creates a polygon outlining the tile this object is on
*
* @return the canvas polygon
*/ */
Polygon getCanvasTilePoly(); Polygon getCanvasTilePoly();
/** /**
* Gets the text position on the canvas. * Calculates the canvas point to center {@code text} above the tile this object is on.
* *
* @param graphics the client graphics * @param graphics the graphics to use for font size calculation
* @param text the text to draw * @param zOffset Vertical offset to apply before projection
* @param zOffset the offset from ground plane
* @return the canvas point to draw the text at * @return the canvas point to draw the text at
*/ */
Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset); Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset);
@@ -127,9 +104,7 @@ public interface TileObject
Point getMinimapLocation(); Point getMinimapLocation();
/** /**
* Get the on-screen clickable area of the object. * Calculate the on-screen clickable area of the object.
*
* @return the clickable area
*/ */
@Nullable @Nullable
Shape getClickbox(); Shape getClickbox();

View File

@@ -28,7 +28,11 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
/** /**
* An enumeration of integer local variables. * Client side only, content-developer integers
*
* VarCInts are stored entirely in memory, or locally on a user's
* machine in the preferences2.dat file depending on how Jagex
* configured the variable
*/ */
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter

View File

@@ -28,7 +28,11 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
/** /**
* An enumeration of string local variables. * Client side only, content-developer strings
*
* VarCInts are stored entirely in memory, or locally on a user's
* machine in the preferences2.dat file depending on how Jagex
* configured the variable
*/ */
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter

View File

@@ -28,7 +28,12 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
/** /**
* An enumeration of local player variables. * Server controlled "content-developer" integers.
*
* VarPlayers are stored per RuneScape player save, and synchronized
* from the server to the client. The client can change them preemptively
* if it thinks they will change the next tick as a lag-hiding measure.
* The client CANNOT directly make the server change a varbit.
*/ */
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter

View File

@@ -28,7 +28,15 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
/** /**
* An enumeration of local client variables. * Server controlled "content-developer" integers.
*
* @see VarPlayer
*
* These differ from a {@link VarPlayer} in that VarBits can be
* less than 32 bits. One or more VarBits can be assigned to a
* backing VarPlayer, each with a static range of bits that it is
* allowed to access. This allows a more compact representation
* of small values, like booleans
*/ */
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter

View File

@@ -34,11 +34,12 @@ import net.runelite.api.Script;
public class ScriptCallbackEvent public class ScriptCallbackEvent
{ {
/** /**
* The script being called. * The script that is currently being executed
*/ */
private Script script; private Script script;
/** /**
* The name of the event that triggered script execution. * The name passed to runelite_callback
*/ */
private String eventName; private String eventName;
} }

View File

@@ -28,7 +28,7 @@ package net.runelite.api.events;
import lombok.Value; import lombok.Value;
/** /**
* An event where a varbit integer has changed. * @see net.runelite.api.VarClientInt
*/ */
@Value @Value
public class VarClientIntChanged public class VarClientIntChanged

View File

@@ -28,7 +28,7 @@ package net.runelite.api.events;
import lombok.Value; import lombok.Value;
/** /**
* An event where a varbit string has changed. * @see net.runelite.api.VarClientStr
*/ */
@Value @Value
public class VarClientStrChanged public class VarClientStrChanged

View File

@@ -30,6 +30,11 @@ import lombok.Data;
/** /**
* An event when a varbit or varplayer has changed. * An event when a varbit or varplayer has changed.
*
* If the client preemptively changes a varp and the server agrees
* the next tick, VarbitChanged will only be posted when the client
* changes the value, not the server. This can cause unintended effects
* if the VarPlayer has special engine behavior assigned to it.
*/ */
@Data @Data
public class VarbitChanged public class VarbitChanged

View File

@@ -28,7 +28,7 @@ import lombok.Data;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
/** /**
* An event where an option has been clicked in a {@link net.runelite.api.widgets.Widget}s menu. * A MenuManager widget menu was clicked. This event is NOT fired for non-MenuManager menu options
*/ */
@Data @Data
public class WidgetMenuOptionClicked public class WidgetMenuOptionClicked

View File

@@ -26,6 +26,10 @@ package net.runelite.api.widgets;
import net.runelite.api.ScriptEvent; import net.runelite.api.ScriptEvent;
/**
* An object that can be set as the first argument to a {@link Widget} listener
* to handle ScriptEvents with Java code, rather than cs2.
*/
@FunctionalInterface @FunctionalInterface
public interface JavaScriptCallback public interface JavaScriptCallback
{ {