Haven't released anything here in a while so decided to release this and maybe a few people will use it.
Please note that your client may have different naming than mine.
Spoiler for How to add a hovered button with text over it with the original system, compared to my system:
What you are adding:
This is a new system for hover buttons for the interface system, there are a few problems with the original system.
Spoiler for Problems with the original system:
Step 1:
Open RSInterface.java and add this somewhere:
Code:public int messageOffsetX;
public int messageOffsetY;
public int fontType;
/**
* @param id - The ID of the Interface (Index in interfaceCache array)
* @param spriteLocation - The directory in the cache where the sprites are
* @param offSprite - The ID of the sprite when the mouse is not over the button
* @param hoverSprite - The ID of the sprite when the mouse is over the button
* @param hoverTooltip - The menu action text for the button (right click)
* @param font - The ID of the font for the text on the button (0 = small, 1 = regular, 2 = bold, 3 = fancy)
* @param color - The color of the text on top of the button
* @param buttonText - The text on top of the button
*/
public static void hoverButton(int id, String spriteLocation, int offSprite, int hoverSprite, String hoverTooltip, int font, int color, String buttonText) {
RSInterface tab = addInterface(id);
tab.tooltip = hoverTooltip;
tab.atActionType = 1;
tab.type = 42;
tab.sprite1 = imageLoader(offSprite, spriteLocation);
tab.sprite2 = imageLoader(hoverSprite, spriteLocation);
tab.width = tab.sprite1.myWidth;
tab.height = tab.sprite1.myHeight;
tab.messageOffsetX = tab.width / 2;
tab.messageOffsetY = (tab.height / 2) + 5;
tab.message = buttonText;
tab.fontType = font;
tab.textColor = color;
tab.centerText = true;
}
/**
* @param id - The ID of the Interface (Index in interfaceCache array)
* @param spriteLocation - The directory in the cache where the sprites are
* @param offSprite - The ID of the sprite when the mouse is not over the button
* @param hoverSprite - The ID of the sprite when the mouse is over the button
* @param hoverTooltip - The menu action text for the button (right click)
* @param font - The ID of the font for the text on the button (0 = small, 1 = regular, 2 = bold, 3 = fancy)
* @param color - The color of the text on top of the button
* @param buttonText - The text on top of the button
* @param msgX - The X position of the text on the button, relative to the position of the button
* @param msgY - The Y position of the text on the button, relative to the position of the button
*/
public static void hoverButton(int id, String spriteLocation, int offSprite, int hoverSprite, String hoverTooltip, int font, int color, String buttonText, int msgX, int msgY) {
RSInterface tab = addInterface(id);
tab.tooltip = hoverTooltip;
tab.atActionType = 1;
tab.type = 42;
tab.sprite1 = imageLoader(offSprite, spriteLocation);
tab.sprite2 = imageLoader(hoverSprite, spriteLocation);
tab.width = tab.sprite1.myWidth;
tab.height = tab.sprite1.myHeight;
tab.messageOffsetX = msgX;
tab.messageOffsetY = msgY;
tab.message = buttonText;
tab.fontType = font;
tab.textColor = color;
tab.centerText = false;
}
public RSFont getFont() {
switch (fontType) {
case 0: return Client.instance.newSmallFont;
case 1: return Client.instance.newRegularFont;
case 2: return Client.instance.bold;
case 3: return Client.instance.fancy;
}
return Client.instance.newSmallFont;
}
Step 2:
Open Client.java and add this somewhere
Code:private static RSInterface buttonHovered = null;
Step 3:
Still in Client.java go to void drawInterface(int j, int k, RSInterface class9, int l)
Search for this part:
Add this after it:Code:else if (class9_1.type == 6) {
int k3 = Rasterizer.textureInt1;
int j4 = Rasterizer.textureInt2;
Rasterizer.textureInt1 = k2 + class9_1.width / 2;
Rasterizer.textureInt2 = l2 + class9_1.height / 2;
int i5 = Rasterizer.anIntArray1470[class9_1.modelRotation1]
* class9_1.modelZoom >> 16;
int l5 = Rasterizer.anIntArray1471[class9_1.modelRotation1]
* class9_1.modelZoom >> 16;
boolean flag2 = interfaceIsSelected(class9_1);
int i7;
if (flag2)
i7 = class9_1.anInt258;
else
i7 = class9_1.anInt257;
Model model;
if (i7 == -1) {
model = class9_1.method209(-1, -1, flag2);
} else {
Animation animation = Animation.anims[i7];
model = class9_1.method209(
animation.anIntArray354[class9_1.anInt246],
animation.anIntArray353[class9_1.anInt246],
flag2);
}
if (model != null)
model.method482(class9_1.modelRotation2, 0,
class9_1.modelRotation1, 0, i5, l5);
Rasterizer.textureInt1 = k3;
Rasterizer.textureInt2 = j4;
}
Code:else if (class9_1.type == 42) {
if (buttonHovered == class9_1) {
class9_1.sprite2.drawSprite(k2, l2);
} else {
class9_1.sprite1.drawSprite(k2, l2);
}
if (class9_1.centerText)
class9_1.getFont().drawCenteredString(class9_1.message, k2 + class9_1.messageOffsetX, l2 + class9_1.messageOffsetY, class9_1.textColor, class9_1.shadowColor);
else
class9_1.getFont().drawString(class9_1.message, k2 + 5 + class9_1.messageOffsetX, l2 + class9_1.messageOffsetY, class9_1.textColor, class9_1.shadowColor);
}
Step 3:
(Still in Client.java) Now for the last part, we need to make the hovering of the buttons work.
Find this method:
And use your search bar to find this part:Code:private void buildInterfaceMenu(int i, RSInterface class9, int k, int l, int i1, int j1) {
You should see something like this:Code:.atActionType == 1
Code:if (class9_1.atActionType == 1) {
if (k >= i2 && i1 >= j2 && k < i2 + class9_1.width && i1 < j2 + class9_1.height) {
boolean flag = false;
add this in there
Code:if (class9_1.type == 42) {
buttonHovered = class9_1;
}
Now Search for:
and before the very last bracket at the end of the methodCode:private void draw3dScreen() {
add this:
Code:buttonHovered = null;
Result (Made a simple interface for testing purposes):
[Only registered and activated users can see links. Click Here To Register...]
Here's the RSInterface code & sprites for the interface in the gif, in case you want to see how it works.
Sprites:Code:public static void testButtons() {
RSInterface tab = addInterface(27000);
addSprite(27001, 0, "test/SPRITE");
tab.totalChildren(2);
tab.child(0, 27001, 10, 10);
tab.child(1, 27005, 127, 85);
RSInterface scroll = addInterface(27005);
hoverButton(27006, "test/SPRITE", 1, 2, "Confirm", 1, 0xffffff, "Hello xD");
hoverButton(27007, "test/SPRITE", 1, 2, "Confirm", 1, 0xffff00, "Text here");
hoverButton(27008, "test/SPRITE", 1, 2, "Confirm", 0, 0x00ffff, "Ima button");
hoverButton(27009, "test/SPRITE", 1, 2, "Confirm", 2, 0xffffff, "Kappa");
hoverButton(27010, "test/SPRITE", 1, 2, "Confirm", 3, 0xffffff, "Fancy");
scroll.totalChildren(5);
for (int i = 0; i < 5; ++i) {
scroll.child(i, 27006 + i, 6, 6 + (37 * i));
}
scroll.width = 120;
scroll.height = 145;
scroll.scrollMax = 300;
}
[Only registered and activated users can see links. Click Here To Register...]
