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:
-Difficult to understand
-Annoying to use
-Uses 3 indexes in interfaceCache (or 4 if you want a text over the button)
-Glitch when the button is in a scroll bar (hovering over it will make the hover part draw outside the scroll area)
See in the Gif below, when I place my mouse over one of the buttons at the bottom of the scrollbar, the hover button draws outside the scroll area.
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:
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;
}
Good job not a fan of it, looks better with normal button sprites. also mabye its better fixing the proper system in the client instead of creating a new type.
Good job not a fan of it, looks better with normal button sprites. also mabye its better fixing the proper system in the client instead of creating a new type.
U can use ur own sprites m8, those are just shits i made in 5 seconds on paint.
Plus the old system is shite, so might as well make a new type.