xp drop plugin: fix alignment of xpdrops when hiding skill icons
This commit is contained in:
@@ -47,7 +47,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
)
|
)
|
||||||
public class XpDropPlugin extends Plugin
|
public class XpDropPlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final int EXPERIENCE_DROP_SPRITE_WIDTH = 16;
|
private static final int XPDROP_PADDING = 2; // space between xp drop icons
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
@@ -87,9 +87,37 @@ public class XpDropPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
else if (!widget.getText().isEmpty())
|
else if (!widget.getText().isEmpty())
|
||||||
{
|
{
|
||||||
// Align text left accordingly to take up hidden skill icon space
|
// Align text accordingly to take up hidden skill icon space
|
||||||
|
int width = 0;
|
||||||
|
for (Widget w : widget.getParent().getDynamicChildren())
|
||||||
|
{
|
||||||
|
if (w.getSpriteId() != -1)
|
||||||
|
{
|
||||||
|
if (width > 0)
|
||||||
|
{
|
||||||
|
// Add in space between sprites
|
||||||
|
width += XPDROP_PADDING;
|
||||||
|
}
|
||||||
|
width += w.getWidth(); // width of sprite
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final int xpDropPosition = client.getVar(Varbits.EXPERIENCE_TRACKER_POSITION);
|
final int xpDropPosition = client.getVar(Varbits.EXPERIENCE_TRACKER_POSITION);
|
||||||
widget.setRelativeX(EXPERIENCE_DROP_SPRITE_WIDTH * xpDropPosition * -1 / 2);
|
switch (xpDropPosition)
|
||||||
|
{
|
||||||
|
case 2: // left
|
||||||
|
int cur = widget.getRelativeX();
|
||||||
|
cur -= width;
|
||||||
|
widget.setRelativeX(cur);
|
||||||
|
break;
|
||||||
|
case 0: // right
|
||||||
|
break;
|
||||||
|
case 1: // center
|
||||||
|
cur = widget.getRelativeX();
|
||||||
|
cur -= width / 2;
|
||||||
|
widget.setRelativeX(cur);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user