From 6bf32768f19fdae990ae5edfc42b50052beec42f Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 16 Jul 2018 20:51:08 -0400 Subject: [PATCH] xp drop plugin: fix alignment of xpdrops when hiding skill icons --- .../plugins/experiencedrop/XpDropPlugin.java | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java index 78549803bc..8b343ff437 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java @@ -47,7 +47,7 @@ import net.runelite.client.plugins.PluginDescriptor; ) 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 private Client client; @@ -87,9 +87,37 @@ public class XpDropPlugin extends Plugin } 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); - 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; + } } }