diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java index 7576b9e423..73b6e0202b 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java @@ -25,6 +25,7 @@ package net.runelite.api.widgets; import java.awt.Rectangle; +import net.runelite.api.Point; public class WidgetItem { @@ -67,4 +68,9 @@ public class WidgetItem return canvasBounds; } + public Point getCanvasLocation() + { + return new Point((int) canvasBounds.getX(), (int) canvasBounds.getY()); + } + } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index 4ffccb7417..8c9b57d5ed 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -35,6 +35,7 @@ import net.runelite.client.plugins.fpsinfo.FPS; import net.runelite.client.plugins.hiscore.Hiscore; import net.runelite.client.plugins.idlenotifier.IdleNotifier; import net.runelite.client.plugins.opponentinfo.OpponentInfo; +import net.runelite.client.plugins.runecraft.Runecraft; import net.runelite.client.plugins.xtea.Xtea; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,6 +61,7 @@ public class PluginManager load(new BossTimers()); load(new Xtea()); load(new IdleNotifier()); + load(new Runecraft()); if (RuneLite.getOptions().has("developer-mode")) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/Runecraft.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/Runecraft.java new file mode 100644 index 0000000000..637f7e49c7 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/Runecraft.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.runecraft; + +import net.runelite.client.plugins.Plugin; +import net.runelite.client.ui.overlay.Overlay; + +public class Runecraft extends Plugin +{ + private static final RunecraftOverlay overlay = new RunecraftOverlay(); + + @Override + public Overlay getOverlay() + { + return overlay; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftOverlay.java new file mode 100644 index 0000000000..c8373dbd5b --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftOverlay.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2017, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.runecraft; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import net.runelite.api.Client; +import net.runelite.api.ItemID; +import net.runelite.api.Point; +import net.runelite.api.Varbits; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetID; +import net.runelite.api.widgets.WidgetItem; +import net.runelite.client.RuneLite; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; + +public class RunecraftOverlay extends Overlay +{ + private final Client client = RuneLite.getClient(); + + public RunecraftOverlay() + { + super(OverlayPosition.DYNAMIC); + } + + @Override + public Dimension render(Graphics2D graphics) + { + Widget inventoryWidget = client.getWidget(WidgetID.INVENTORY_GROUP_ID, WidgetID.INVENTORY_CHILD_ID); + if (inventoryWidget == null) + { + return null; + } + + for (WidgetItem item : inventoryWidget.getWidgetItems()) + { + Varbits varbits; + + switch (item.getId()) + { + case ItemID.SMALL_POUCH: + varbits = Varbits.POUCH_SMALL; + break; + case ItemID.MEDIUM_POUCH: + varbits = Varbits.POUCH_MEDIUM; + break; + case ItemID.LARGE_POUCH: + varbits = Varbits.POUCH_LARGE; + break; + case ItemID.GIANT_POUCH: + varbits = Varbits.POUCH_GIANT; + break; + default: + continue; + } + + Point location = item.getCanvasLocation(); + if (location == null) + { + continue; + } + + int value = client.getSetting(varbits); + graphics.drawString("" + value, location.getX(), location.getY()); + } + + return null; + } + +}