[UNFINISHED] Base for converting all interfaces to original format (even hardcoded)
Well, i wrote this months ago and noticed it, since this ive wrote a fully functioning one which actually just reads the source code instead of having to load it, but ill give you this one as no one else has had a go.
Right, basically what this does;
___
When you load the interfaces into the "interfaceCache" array it's all stored as original data ofcourse, so all you have to do is redump that data into the same data used in loading from the "data" data.
Ive edited the RSInterface class slightly to dump values which go with type 6 as i didn't know if it's possible to reverse the data and if it is for the sake of this it's not even worth it.
Now, this is NOT finished, it will dump a file but it's not correct yet, so you need to edit it yourself to get it to work.
Right, to get it to dump you have to load it after your interfaces have been loaded, so just before the "loading game engine" text basically.
To load it use;
Code:
new RSInterface_config().dump();
Now, the 2 classes.
RSInterface_config.java
Code:
public class RSInterface_config {
public void dump() throws java.io.IOException
{
int currentParent = -1;
Stream out = new Stream(new byte[999999]);
for (RSInterface inter : RSInterface.interfaceCache)
{
if(inter == null)
continue;
int parent = inter.parentID;
if(parent != currentParent)
{
currentParent = parent;
out.writeWord(65535);
out.writeWord(parent);
out.writeWord(inter.id);
} else
out.writeWord(inter.id);
out.writeByte(inter.type);
out.writeByte(inter.atActionType);
out.writeWord(inter.anInt214);
out.writeWord(inter.width);
out.writeWord(inter.height);
out.writeByte((int) inter.aByte254);
out.writeByte(0);
if(inter.anIntArray245 != null)
{
out.writeByte(inter.anIntArray245.length);
for (int index = 0; index < inter.anIntArray245.length; index++)
{
out.writeByte(inter.anIntArray245[index]);
out.writeWord(inter.anIntArray212[index]);
}
} else
out.writeByte(0);
if(inter.valueIndexArray != null)
{
out.writeByte(inter.valueIndexArray.length);
for (int index = 0; index < inter.valueIndexArray.length; index++)
{
out.writeWord(inter.valueIndexArray[index].length);
for (int value : inter.valueIndexArray[index])
out.writeWord(value);
}
} else
out.writeByte(0);
switch (inter.type)
{
case 0:
out.writeWord(inter.scrollMax);
out.writeByte(inter.aBoolean266 ? 1 : 0);
out.writeWord(inter.children.length);
for (int index = 0; index < inter.children.length; index++)
{
out.writeWord(inter.children[index]);
out.writeWord(inter.childX[index]);
out.writeWord(inter.childY[index]);
}
break;
case 1:
out.writeWord(-1);
out.writeByte(-1);
out.writeByte(inter.aBoolean223 ? 1 : 0);
out.writeByte(inter.textDrawingAreas.textId);
out.writeByte(inter.aBoolean268 ? 1 : 0);
out.writeDWord(inter.textColor);
break;
case 2:
out.writeByte(inter.aBoolean259 ? 1 : 0);
out.writeByte(inter.isInventoryInterface ? 1 : 0);
out.writeByte(inter.usableItemInterface ? 1 : 0);
out.writeByte(inter.aBoolean235 ? 1 : 0);
out.writeByte(inter.invSpritePadX);
out.writeByte(inter.invSpritePadY);
for (int index = 0; index < 20; index++)
{
if(inter.sprites[index] != null)
{
out.writeByte(1);
out.writeWord(inter.spritesX[index]);
out.writeWord(inter.spritesY[index]);
out.writeString(inter.sprites[index].spriteName + "," + inter.sprites[index].spriteIndex);
}
}
for (int index = 0; index < 5; index++)
{
if(inter.actions[index] == null)
out.writeString("");
else
out.writeString(inter.actions[index]);
}
break;
case 3:
out.writeByte(inter.aBoolean227 ? 1 : 0);
out.writeDWord(inter.textColor);
break;
case 4:
out.writeByte(inter.aBoolean223 ? 1 : 0);
out.writeByte(inter.textDrawingAreas.textId);
out.writeByte(inter.aBoolean268 ? 1 : 0);
out.writeString(inter.message);
out.writeString(inter.aString228);
out.writeDWord(inter.textColor);
out.writeWord(inter.anInt219);
out.writeWord(inter.anInt216);
out.writeWord(inter.anInt239);
break;
case 5:
if(inter.sprite1 != null)
out.writeString(inter.sprite1.spriteName + "," + inter.sprite1.spriteIndex);
else
out.writeString("");
if(inter.sprite2 != null)
out.writeString(inter.sprite2.spriteName + "," + inter.sprite2.spriteIndex);
else
out.writeString("");
break;
case 6:
out.writeByte(inter.l);
if(inter.l != 0)
out.writeByte(inter.addTo);
out.writeByte(inter.l2);
if(inter.l2 != 0)
out.writeByte(inter.addTo1);
out.writeByte(inter.l3);
if(inter.l3 != 0)
out.writeByte(inter.addTo2);
out.writeByte(inter.l4);
if(inter.l4 != 0)
out.writeByte(inter.addTo3);
out.writeWord(inter.anInt269);
out.writeWord(inter.anInt270);
out.writeWord(inter.anInt271);
break;
case 7:
out.writeByte(inter.aBoolean223 ? 1 : 0);
out.writeByte(inter.textDrawingAreas.textId);
out.writeByte(inter.aBoolean268 ? 1 : 0);
out.writeDWord(inter.textColor);
out.writeByte(inter.invSpritePadX);
out.writeByte(inter.invSpritePadY);
out.writeByte(inter.isInventoryInterface ? 1 : 0);
for (int index = 0; index < 5; index++)
{
if(inter.actions[index] == null)
out.writeString("");
else
out.writeString(inter.actions[index]);
}
break;
}
if(inter.type == 2 || inter.atActionType == 2)
{
out.writeString(inter.selectedActionName);
out.writeString(inter.spellName);
out.writeWord(inter.spellUsableOn);
}
if(inter.type == 8)
out.writeString(inter.message);
if(inter.atActionType == 1 || inter.atActionType == 4 || inter.atActionType == 5 || inter.atActionType == 6)
out.writeString(inter.tooltip);
}
java.io.DataOutputStream dos = new java.io.DataOutputStream(new java.io.FileOutputStream("./interface.dat"));
dos.write(out.buffer, 0, out.currentOffset);
dos.close();
}
}
RSInterface.java
Code:
// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
public final class RSInterface
{
public void swapInventoryItems(int i, int j)
{
int k = inv[i];
inv[i] = inv[j];
inv[j] = k;
k = invStackSizes[i];
invStackSizes[i] = invStackSizes[j];
invStackSizes[j] = k;
}
public static void unpack(StreamLoader streamLoader, TextDrawingArea textDrawingAreas[], StreamLoader streamLoader_1)
{
aMRUNodes_238 = new MRUNodes(50000);
Stream stream = new Stream(streamLoader.getDataForName("data"));
int i = -1;
int j = stream.readUnsignedWord();
interfaceCache = new RSInterface[j];
while(stream.currentOffset < stream.buffer.length)
{
int k = stream.readUnsignedWord();
if(k == 65535)
{
i = stream.readUnsignedWord();
k = stream.readUnsignedWord();
}
RSInterface rsInterface = interfaceCache[k] = new RSInterface();
rsInterface.id = k;
rsInterface.parentID = i;
rsInterface.type = stream.readUnsignedByte();
rsInterface.atActionType = stream.readUnsignedByte();
rsInterface.anInt214 = stream.readUnsignedWord();
rsInterface.width = stream.readUnsignedWord();
rsInterface.height = stream.readUnsignedWord();
rsInterface.aByte254 = (byte) stream.readUnsignedByte();
rsInterface.anInt230 = stream.readUnsignedByte();
if(rsInterface.anInt230 != 0)
rsInterface.anInt230 = (rsInterface.anInt230 - 1 << 8) + stream.readUnsignedByte();
else
rsInterface.anInt230 = -1;
int i1 = stream.readUnsignedByte();
if(i1 > 0)
{
rsInterface.anIntArray245 = new int[i1];
rsInterface.anIntArray212 = new int[i1];
for(int j1 = 0; j1 < i1; j1++)
{
rsInterface.anIntArray245[j1] = stream.readUnsignedByte();
rsInterface.anIntArray212[j1] = stream.readUnsignedWord();
}
}
int k1 = stream.readUnsignedByte();
if(k1 > 0)
{
rsInterface.valueIndexArray = new int[k1][];
for(int l1 = 0; l1 < k1; l1++)
{
int i3 = stream.readUnsignedWord();
rsInterface.valueIndexArray[l1] = new int[i3];
for(int l4 = 0; l4 < i3; l4++)
rsInterface.valueIndexArray[l1][l4] = stream.readUnsignedWord();
}
}
if(rsInterface.type == 0)
{
rsInterface.scrollMax = stream.readUnsignedWord();
rsInterface.aBoolean266 = stream.readUnsignedByte() == 1;
int i2 = stream.readUnsignedWord();
rsInterface.children = new int[i2];
rsInterface.childX = new int[i2];
rsInterface.childY = new int[i2];
for(int j3 = 0; j3 < i2; j3++)
{
rsInterface.children[j3] = stream.readUnsignedWord();
rsInterface.childX[j3] = stream.readSignedWord();
rsInterface.childY[j3] = stream.readSignedWord();
}
}
if(rsInterface.type == 1)
{
stream.readUnsignedWord();
stream.readUnsignedByte();
}
if(rsInterface.type == 2)
{
rsInterface.inv = new int[rsInterface.width * rsInterface.height];
rsInterface.invStackSizes = new int[rsInterface.width * rsInterface.height];
rsInterface.aBoolean259 = stream.readUnsignedByte() == 1;
rsInterface.isInventoryInterface = stream.readUnsignedByte() == 1;
rsInterface.usableItemInterface = stream.readUnsignedByte() == 1;
rsInterface.aBoolean235 = stream.readUnsignedByte() == 1;
rsInterface.invSpritePadX = stream.readUnsignedByte();
rsInterface.invSpritePadY = stream.readUnsignedByte();
rsInterface.spritesX = new int[20];
rsInterface.spritesY = new int[20];
rsInterface.sprites = new Sprite[20];
for(int j2 = 0; j2 < 20; j2++)
{
int k3 = stream.readUnsignedByte();
if(k3 == 1)
{
rsInterface.spritesX[j2] = stream.readSignedWord();
rsInterface.spritesY[j2] = stream.readSignedWord();
String s1 = stream.readString();
if(streamLoader_1 != null && s1.length() > 0)
{
int i5 = s1.lastIndexOf(",");
rsInterface.sprites[j2] = method207(Integer.parseInt(s1.substring(i5 + 1)), streamLoader_1, s1.substring(0, i5));
}
}
}
rsInterface.actions = new String[5];
for(int l3 = 0; l3 < 5; l3++)
{
rsInterface.actions[l3] = stream.readString();
if(rsInterface.actions[l3].length() == 0)
rsInterface.actions[l3] = null;
}
}
if(rsInterface.type == 3)
rsInterface.aBoolean227 = stream.readUnsignedByte() == 1;
if(rsInterface.type == 4 || rsInterface.type == 1)
{
rsInterface.aBoolean223 = stream.readUnsignedByte() == 1;
int k2 = stream.readUnsignedByte();
if(textDrawingAreas != null)
rsInterface.textDrawingAreas = textDrawingAreas[k2];
rsInterface.aBoolean268 = stream.readUnsignedByte() == 1;
}
if(rsInterface.type == 4)
{
rsInterface.message = stream.readString();
rsInterface.aString228 = stream.readString();
}
if(rsInterface.type == 1 || rsInterface.type == 3 || rsInterface.type == 4)
rsInterface.textColor = stream.readDWord();
if(rsInterface.type == 3 || rsInterface.type == 4)
{
rsInterface.anInt219 = stream.readDWord();
rsInterface.anInt216 = stream.readDWord();
rsInterface.anInt239 = stream.readDWord();
}
if(rsInterface.type == 5)
{
String s = stream.readString();
if(streamLoader_1 != null && s.length() > 0)
{
int i4 = s.lastIndexOf(",");
rsInterface.sprite1 = method207(Integer.parseInt(s.substring(i4 + 1)), streamLoader_1, s.substring(0, i4));
}
s = stream.readString();
if(streamLoader_1 != null && s.length() > 0)
{
int j4 = s.lastIndexOf(",");
rsInterface.sprite2 = method207(Integer.parseInt(s.substring(j4 + 1)), streamLoader_1, s.substring(0, j4));
}
}
if(rsInterface.type == 6)
{
int l = stream.readUnsignedByte();
rsInterface.l = l;
if(l != 0)
{
rsInterface.anInt233 = 1;
rsInterface.addTo = stream.readUnsignedByte();
rsInterface.mediaID = (l - 1 << 8) + rsInterface.addTo;
}
l = stream.readUnsignedByte();
rsInterface.l2 = l;
if(l != 0)
{
rsInterface.anInt255 = 1;
rsInterface.addTo1 = stream.readUnsignedByte();
rsInterface.anInt256 = (l - 1 << 8) + rsInterface.addTo1;
}
l = stream.readUnsignedByte();
rsInterface.l3 = l;
if(l != 0)
{
rsInterface.addTo2 = stream.readUnsignedByte();
rsInterface.anInt257 = (l - 1 << 8) + rsInterface.addTo2;
} else
rsInterface.anInt257 = -1;
l = stream.readUnsignedByte();
rsInterface.l4 = l;
if(l != 0)
{
rsInterface.addTo3 = stream.readUnsignedByte();
rsInterface.anInt258 = (l - 1 << 8) + rsInterface.addTo3;
} else
rsInterface.anInt258 = -1;
rsInterface.anInt269 = stream.readUnsignedWord();
rsInterface.anInt270 = stream.readUnsignedWord();
rsInterface.anInt271 = stream.readUnsignedWord();
}
if(rsInterface.type == 7)
{
rsInterface.inv = new int[rsInterface.width * rsInterface.height];
rsInterface.invStackSizes = new int[rsInterface.width * rsInterface.height];
rsInterface.aBoolean223 = stream.readUnsignedByte() == 1;
int l2 = stream.readUnsignedByte();
if(textDrawingAreas != null)
rsInterface.textDrawingAreas = textDrawingAreas[l2];
rsInterface.aBoolean268 = stream.readUnsignedByte() == 1;
rsInterface.textColor = stream.readDWord();
rsInterface.invSpritePadX = stream.readSignedWord();
rsInterface.invSpritePadY = stream.readSignedWord();
rsInterface.isInventoryInterface = stream.readUnsignedByte() == 1;
rsInterface.actions = new String[5];
for(int k4 = 0; k4 < 5; k4++)
{
rsInterface.actions[k4] = stream.readString();
if(rsInterface.actions[k4].length() == 0)
rsInterface.actions[k4] = null;
}
}
if(rsInterface.atActionType == 2 || rsInterface.type == 2)
{
rsInterface.selectedActionName = stream.readString();
rsInterface.spellName = stream.readString();
rsInterface.spellUsableOn = stream.readUnsignedWord();
}
if(rsInterface.type == 8)
rsInterface.message = stream.readString();
if(rsInterface.atActionType == 1 || rsInterface.atActionType == 4 || rsInterface.atActionType == 5 || rsInterface.atActionType == 6)
{
rsInterface.tooltip = stream.readString();
if(rsInterface.tooltip.length() == 0)
{
if(rsInterface.atActionType == 1)
rsInterface.tooltip = "Ok";
if(rsInterface.atActionType == 4)
rsInterface.tooltip = "Select";
if(rsInterface.atActionType == 5)
rsInterface.tooltip = "Select";
if(rsInterface.atActionType == 6)
rsInterface.tooltip = "Continue";
}
}
//aryan Bot.notifyInterface(rsInterface);
}
aMRUNodes_238 = null;
}
public Model method206(int i, int j)
{
Model model = (Model) aMRUNodes_264.insertFromCache((i << 16) + j);
if(model != null)
return model;
if(i == 1)
model = Model.method462(j);
if(i == 2)
model = EntityDef.forID(j).method160();
if(i == 3)
model = client.myPlayer.method453();
if(i == 4)
model = ItemDef.forID(j).method202(50);
if(i == 5)
model = null;
if(model != null)
aMRUNodes_264.removeFromCache(model, (i << 16) + j);
return model;
}
public static Sprite method207(int i, StreamLoader streamLoader, String s)
{
long l = (TextClass.method585(s) << 8) + (long)i;
Sprite sprite = (Sprite) aMRUNodes_238.insertFromCache(l);
if(sprite != null)
return sprite;
try
{
sprite = new Sprite(streamLoader, s, i);
aMRUNodes_238.removeFromCache(sprite, l);
}
catch(Exception _ex)
{
return null;
}
return sprite;
}
public static void method208(boolean flag, Model model)
{
int i = 0;//was parameter
int j = 5;//was parameter
if(flag)
return;
aMRUNodes_264.unlinkAll();
if(model != null && j != 4)
aMRUNodes_264.removeFromCache(model, (j << 16) + i);
}
public Model method209(int j, int k, boolean flag)
{
Model model;
if(flag)
model = method206(anInt255, anInt256);
else
model = method206(anInt233, mediaID);
if(model == null)
return null;
if(k == -1 && j == -1 && model.anIntArray1640 == null)
return model;
Model model_1 = new Model(true, Class36.method532(k) & Class36.method532(j), false, model);
if(k != -1 || j != -1)
model_1.method469();
if(k != -1)
model_1.method470(k);
if(j != -1)
model_1.method470(j);
model_1.method479(64, 768, -50, -10, -50, true);
return model_1;
}
public RSInterface()
{
}
public Sprite sprite1;
public int anInt208;
public Sprite sprites[];
public static RSInterface interfaceCache[];
public int anIntArray212[];
public int anInt214;
public int spritesX[];
public int anInt216;
public int atActionType;
public String spellName;
public int anInt219;
public int width;
public String tooltip;
public String selectedActionName;
public boolean aBoolean223;
public int scrollPosition;
public String actions[];
public int valueIndexArray[][];
public boolean aBoolean227;
public String aString228;
public int anInt230;
public int invSpritePadX;
public int textColor;
public int anInt233;
public int mediaID;
public boolean aBoolean235;
public int parentID;
public int spellUsableOn;
public static MRUNodes aMRUNodes_238;
public int anInt239;
public int children[];
public int childX[];
public boolean usableItemInterface;
public TextDrawingArea textDrawingAreas;
public int invSpritePadY;
public int anIntArray245[];
public int anInt246;
public int spritesY[];
public String message;
public boolean isInventoryInterface;
public int id;
public int invStackSizes[];
public int inv[];
public byte aByte254;
public int anInt255;
public int anInt256;
public int anInt257;
public int anInt258;
public boolean aBoolean259;
public Sprite sprite2;
public int scrollMax;
public int type;
public int anInt263;
public static final MRUNodes aMRUNodes_264 = new MRUNodes(30);
public int anInt265;
public boolean aBoolean266;
public int height;
public boolean aBoolean268;
public int anInt269;
public int anInt270;
public int anInt271;
public int childY[];
public int l;
public int l2;
public int l3;
public int l4;
public int addTo;
public int addTo1;
public int addTo2;
public int addTo3;
}