Change api for dev tools var inspector
This commit is contained in:
@@ -407,6 +407,11 @@ public interface Client extends GameShell
|
||||
*/
|
||||
IndexDataBase getIndexScripts();
|
||||
|
||||
/**
|
||||
* Gets the config archive, containing Varplayer and Varbit definitions
|
||||
*/
|
||||
IndexDataBase getConfigArchive();
|
||||
|
||||
/**
|
||||
* Gets the config index.
|
||||
*/
|
||||
@@ -774,16 +779,6 @@ public interface Client extends GameShell
|
||||
*/
|
||||
void setVarbit(Varbits varbit, int value);
|
||||
|
||||
/**
|
||||
* Gets the varbit composition for a given varbit id
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@VisibleForDevtools
|
||||
@Nullable
|
||||
VarbitComposition getVarbit(int id);
|
||||
|
||||
/**
|
||||
* Gets the value of a given variable.
|
||||
*
|
||||
@@ -825,9 +820,10 @@ public interface Client extends GameShell
|
||||
void setVarbitValue(int[] varps, int varbit, int value);
|
||||
|
||||
/**
|
||||
* @return the total number of VarbitDefinition
|
||||
* Gets the varbit composition for a given varbit id
|
||||
*/
|
||||
int getVarbitCount();
|
||||
@Nullable
|
||||
VarbitDefinition getVarbitDefinition(int id);
|
||||
|
||||
/**
|
||||
* Gets the widget flags table.
|
||||
|
||||
@@ -11,9 +11,7 @@ public interface IndexDataBase
|
||||
boolean isOverlayOutdated();
|
||||
|
||||
/**
|
||||
* Get the child file ids for a given archive
|
||||
* @param archiveId
|
||||
* @return
|
||||
* Get the child file ids for a given group
|
||||
*/
|
||||
int[] getFileIds(int archiveId);
|
||||
int[] getFileIds(int group);
|
||||
}
|
||||
|
||||
@@ -24,26 +24,20 @@
|
||||
*/
|
||||
package net.runelite.api;
|
||||
|
||||
public interface VarbitComposition
|
||||
public interface VarbitDefinition
|
||||
{
|
||||
/**
|
||||
* The varp index for this varbit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getIndex();
|
||||
|
||||
/**
|
||||
* The least significant bit of the varbit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getLeastSignificantBit();
|
||||
|
||||
/**
|
||||
* The most significant bit of the varbit (inclusive)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getMostSignificantBit();
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.api.mixins.Shadow;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSEvictingDualNodeHashTable;
|
||||
import net.runelite.rs.api.RSVarbitDefinition;
|
||||
|
||||
@Mixin(RSClient.class)
|
||||
@@ -54,25 +53,44 @@ public abstract class VarbitMixin implements RSClient
|
||||
setVarbitValue(getVarps(), varbitId, value);
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public RSVarbitDefinition getVarbitDefinition(int id)
|
||||
{
|
||||
assert isClientThread();
|
||||
|
||||
RSVarbitDefinition varbit;
|
||||
varbit = varbitCache.getIfPresent(id);
|
||||
if (varbit != null)
|
||||
{
|
||||
return varbit;
|
||||
}
|
||||
varbit = (RSVarbitDefinition) getVarbitCache().get(id);
|
||||
if (varbit != null && !(varbit.getIndex() == 0 && varbit.getMostSignificantBit() == 0 && varbit.getLeastSignificantBit() == 0))
|
||||
{
|
||||
return varbit;
|
||||
}
|
||||
|
||||
byte[] fileData = getConfigArchive().getConfigData(VARBITS_GROUP, id);
|
||||
if (fileData == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
varbit = newVarbitDefinition();
|
||||
varbit.decode(newBuffer(fileData));
|
||||
return varbit;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public int getVarbitValue(int[] varps, int varbitId)
|
||||
{
|
||||
assert client.isClientThread();
|
||||
|
||||
RSVarbitDefinition v = varbitCache.getIfPresent(varbitId);
|
||||
RSVarbitDefinition v = getVarbitDefinition(varbitId);
|
||||
if (v == null)
|
||||
{
|
||||
client.getVarbit(varbitId); // load varbit into cache
|
||||
RSEvictingDualNodeHashTable varbits = client.getVarbitCache();
|
||||
v = (RSVarbitDefinition) varbits.get(varbitId); // get from cache
|
||||
varbitCache.put(varbitId, v);
|
||||
}
|
||||
|
||||
if (v.getIndex() == 0 && v.getLeastSignificantBit() == 0 && v.getMostSignificantBit() == 0)
|
||||
{
|
||||
getLogger().debug("Varbit {} doesn't exist!", varbitId);
|
||||
return 0;
|
||||
throw new IndexOutOfBoundsException(String.format("Varbit %d does not exist!", varbitId)); // oob for "backwards compatibility lol"
|
||||
}
|
||||
|
||||
int value = varps[v.getIndex()];
|
||||
@@ -86,13 +104,10 @@ public abstract class VarbitMixin implements RSClient
|
||||
@Override
|
||||
public void setVarbitValue(int[] varps, int varbitId, int value)
|
||||
{
|
||||
RSVarbitDefinition v = varbitCache.getIfPresent(varbitId);
|
||||
RSVarbitDefinition v = getVarbitDefinition(varbitId);
|
||||
if (v == null)
|
||||
{
|
||||
client.getVarbit(varbitId); // load varbit into cache
|
||||
RSEvictingDualNodeHashTable varbits = client.getVarbitCache();
|
||||
v = (RSVarbitDefinition) varbits.get(varbitId); // get from cache
|
||||
varbitCache.put(varbitId, v);
|
||||
throw new IndexOutOfBoundsException(String.format("Varbit %d does not exist!", varbitId)); // oob for "backwards compatibility lol"
|
||||
}
|
||||
|
||||
int lsb = v.getLeastSignificantBit();
|
||||
@@ -155,11 +170,4 @@ public abstract class VarbitMixin implements RSClient
|
||||
{
|
||||
return getVarcs().getVarcMap();
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public int getVarbitCount()
|
||||
{
|
||||
return getConfigArchive().getGroupFileCount(VARBITS_GROUP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public interface RSAbstractArchive extends IndexDataBase
|
||||
@Import("takeFile")
|
||||
byte[] getConfigData(int archiveId, int fileId);
|
||||
|
||||
@Import("getGroupFileCount")
|
||||
int getGroupFileCount(int group);
|
||||
@Import("getGroupFileIds")
|
||||
@Override
|
||||
int[] getFileIds(int group);
|
||||
}
|
||||
|
||||
@@ -458,6 +458,7 @@ public interface RSClient extends RSGameShell, Client
|
||||
void setIndexedSpritePalette(int[] indexedSpritePalette);
|
||||
|
||||
@Import("archive2")
|
||||
@Override
|
||||
RSArchive getConfigArchive();
|
||||
|
||||
@Import("archive6")
|
||||
@@ -1275,4 +1276,10 @@ public interface RSClient extends RSGameShell, Client
|
||||
|
||||
@Import("rightTitleSprite")
|
||||
void setRightTitleSprite(Sprite background);
|
||||
|
||||
@Construct
|
||||
RSBuffer newBuffer(byte[] bytes);
|
||||
|
||||
@Construct
|
||||
RSVarbitDefinition newVarbitDefinition();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package net.runelite.rs.api;
|
||||
|
||||
import net.runelite.api.VarbitDefinition;
|
||||
import net.runelite.mapping.Import;
|
||||
|
||||
public interface RSVarbitDefinition extends RSDualNode
|
||||
public interface RSVarbitDefinition extends VarbitDefinition, RSDualNode
|
||||
{
|
||||
@Import("baseVar")
|
||||
int getIndex();
|
||||
@@ -12,4 +13,7 @@ public interface RSVarbitDefinition extends RSDualNode
|
||||
|
||||
@Import("endBit")
|
||||
int getMostSignificantBit();
|
||||
|
||||
@Import("decode")
|
||||
void decode(RSBuffer buffer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user