diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 001a616259..9218958dd1 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -22,7 +22,6 @@ * (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.api; import java.awt.Canvas; @@ -40,7 +39,9 @@ public class Client public Player getLocalPlayer() { if (client.getLocalPlayer() == null) + { return null; + } return new Player(this, client.getLocalPlayer()); } @@ -48,15 +49,15 @@ public class Client public NPC[] getNpcs() { return Arrays.stream(client.getCachedNPCs()) - .map(npc -> npc != null ? new NPC(this, npc) : null) - .toArray(size -> new NPC[size]); + .map(npc -> npc != null ? new NPC(this, npc) : null) + .toArray(size -> new NPC[size]); } public Player[] getPlayers() { return Arrays.stream(client.getCachedPlayers()) - .map(player -> player != null ? new Player(this, player) : null) - .toArray(size -> new Player[size]); + .map(player -> player != null ? new Player(this, player) : null) + .toArray(size -> new Player[size]); } public int[] getBoostedSkillLevels() @@ -158,4 +159,19 @@ public class Client { return client.getPlane(); } + + public Region getRegion() + { + return new Region(this, client.getRegion()); + } + + public int getBaseX() + { + return client.getBaseX(); + } + + public int getBaseY() + { + return client.getBaseY(); + } } diff --git a/runelite-api/src/main/java/net/runelite/api/DecorativeObject.java b/runelite-api/src/main/java/net/runelite/api/DecorativeObject.java new file mode 100644 index 0000000000..e79e014745 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/DecorativeObject.java @@ -0,0 +1,59 @@ +/* + * 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.api; + +/** + * Decorative object, such as objects on walls + * + * @author Adam + */ +public class DecorativeObject extends TileObject +{ + private final net.runelite.rs.api.DecorativeObject decorativeObject; + + public DecorativeObject(Client client, net.runelite.rs.api.DecorativeObject decorativeObject) + { + super(client); + this.decorativeObject = decorativeObject; + } + + @Override + protected int getHash() + { + return decorativeObject.getHash(); + } + + @Override + protected int getLocalX() + { + return decorativeObject.getX(); + } + + @Override + protected int getLocalY() + { + return decorativeObject.getY(); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/GameObject.java b/runelite-api/src/main/java/net/runelite/api/GameObject.java new file mode 100644 index 0000000000..12c9fef56b --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/GameObject.java @@ -0,0 +1,58 @@ +/* + * 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.api; + +/** + * + * @author Adam + */ +public class GameObject extends TileObject +{ + private final net.runelite.rs.api.GameObject gameObject; + + public GameObject(Client client, net.runelite.rs.api.GameObject gameObject) + { + super(client); + this.gameObject = gameObject; + } + + @Override + protected int getHash() + { + return gameObject.getHash(); + } + + @Override + protected int getLocalX() + { + return gameObject.getX(); + } + + @Override + protected int getLocalY() + { + return gameObject.getY(); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/GroundObject.java b/runelite-api/src/main/java/net/runelite/api/GroundObject.java new file mode 100644 index 0000000000..6646e65893 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/GroundObject.java @@ -0,0 +1,54 @@ +/* + * 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.api; + +public class GroundObject extends TileObject +{ + private final net.runelite.rs.api.GroundObject groundObject; + + public GroundObject(Client client, net.runelite.rs.api.GroundObject groundObject) + { + super(client); + this.groundObject = groundObject; + } + + @Override + protected int getHash() + { + return groundObject.getHash(); + } + + @Override + protected int getLocalX() + { + return groundObject.getX(); + } + + @Override + protected int getLocalY() + { + return groundObject.getY(); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/Item.java b/runelite-api/src/main/java/net/runelite/api/Item.java new file mode 100644 index 0000000000..6d2ef3fb8b --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/Item.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016-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.api; + +public class Item extends Renderable +{ + private final net.runelite.rs.api.Item item; + + public Item(net.runelite.rs.api.Item item) + { + super(item); + this.item = item; + } + + public int getId() + { + return item.getId(); + } + + public int getQuantity() + { + return item.getQuantity(); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/ItemLayer.java b/runelite-api/src/main/java/net/runelite/api/ItemLayer.java new file mode 100644 index 0000000000..094349e093 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/ItemLayer.java @@ -0,0 +1,69 @@ +/* + * 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.api; + +public class ItemLayer extends TileObject +{ + private final net.runelite.rs.api.ItemLayer itemLayer; + + public ItemLayer(Client client, net.runelite.rs.api.ItemLayer itemLayer) + { + super(client); + this.itemLayer = itemLayer; + } + + @Override + protected int getHash() + { + return itemLayer.getHash(); + } + + @Override + protected int getLocalX() + { + return itemLayer.getX(); + } + + @Override + protected int getLocalY() + { + return itemLayer.getY(); + } + + public Renderable getBottom() + { + return Renderable.of(itemLayer.getBottom()); + } + + public Renderable getMiddle() + { + return Renderable.of(itemLayer.getMiddle()); + } + + public Renderable getTop() + { + return Renderable.of(itemLayer.getTop()); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/Node.java b/runelite-api/src/main/java/net/runelite/api/Node.java new file mode 100644 index 0000000000..9c9986d641 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/Node.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016-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.api; + +public class Node +{ + private final net.runelite.rs.api.Node node; + + public Node(net.runelite.rs.api.Node node) + { + this.node = node; + } + + @Override + public String toString() + { + return "Node{" + "node=" + node + '}'; + } + + public Node getNext() + { + return of(node.getNext()); + } + + public Node getPrev() + { + return of(node.getPrevious()); + } + + public static final Node of(net.runelite.rs.api.Node node) + { + if (node == null) + { + return null; + } + + if (node instanceof net.runelite.rs.api.Item) + { + return new Item((net.runelite.rs.api.Item) node); + } + + if (node instanceof net.runelite.rs.api.Renderable) + { + return new Renderable((net.runelite.rs.api.Renderable) node); + } + + return new Node(node); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/Perspective.java b/runelite-api/src/main/java/net/runelite/api/Perspective.java index 559d5b9835..78278d7bb0 100644 --- a/runelite-api/src/main/java/net/runelite/api/Perspective.java +++ b/runelite-api/src/main/java/net/runelite/api/Perspective.java @@ -27,6 +27,10 @@ package net.runelite.api; public class Perspective { private static final double UNIT = Math.PI / 1024d; // How much of the circle each unit of SINE/COSINE is + + private static final int LOCAL_COORD_BITS = 7; + private static final int LOCAL_TILE_SIZE = 1 << LOCAL_COORD_BITS; // 128 - size of a tile in local coordinates + public static final int[] SINE = new int[2048]; // sine angles for each of the 2048 units, * 65536 and stored as an int public static final int[] COSINE = new int[2048]; // cosine @@ -119,4 +123,22 @@ public class Perspective return 0; } + public static Point worldToLocal(Client client, Point point) + { + int baseX = client.getBaseX(); + int baseY = client.getBaseY(); + + int x = (point.getX() - baseX) << LOCAL_COORD_BITS; + int y = (point.getY() - baseY) << LOCAL_COORD_BITS; + + return new Point(x, y); + } + + public static Point localToWorld(Client client, Point point) + { + int x = (point.getX() >>> LOCAL_COORD_BITS) + client.getBaseX(); + int y = (point.getY() >>> LOCAL_COORD_BITS) + client.getBaseY(); + return new Point(x, y); + } + } diff --git a/runelite-api/src/main/java/net/runelite/api/Point.java b/runelite-api/src/main/java/net/runelite/api/Point.java index 83f8d4e660..fa92f88d33 100644 --- a/runelite-api/src/main/java/net/runelite/api/Point.java +++ b/runelite-api/src/main/java/net/runelite/api/Point.java @@ -51,6 +51,19 @@ public class Point return y; } + /** + * Find the distance from this point to another point + * + * @param other + * @return + */ + public int distanceTo(Point other) + { + int dx = x - other.x; + int dy = y - other.y; + return (int) Math.sqrt(dx * dx + dy * dy); + } + @Override public int hashCode() { diff --git a/runelite-api/src/main/java/net/runelite/api/Region.java b/runelite-api/src/main/java/net/runelite/api/Region.java new file mode 100644 index 0000000000..ffb3cd8306 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/Region.java @@ -0,0 +1,51 @@ +/* + * 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.api; + +import java.util.Arrays; + +public class Region +{ + private final Client client; + private final net.runelite.rs.api.Region region; + + public Region(Client client, net.runelite.rs.api.Region region) + { + this.client = client; + this.region = region; + } + + public Tile[][][] getTiles() + { + return Arrays.stream(region.getTiles()) + .map(tile1 -> Arrays.stream(tile1) + .map(tile2 -> Arrays.stream(tile2) + .map(tile3 -> new Tile(client, tile3)) + .toArray(i -> new Tile[i]) + ) + .toArray(i -> new Tile[i][]) + ).toArray(i -> new Tile[i][][]); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/Renderable.java b/runelite-api/src/main/java/net/runelite/api/Renderable.java index 50a76281d2..74ca7c218a 100644 --- a/runelite-api/src/main/java/net/runelite/api/Renderable.java +++ b/runelite-api/src/main/java/net/runelite/api/Renderable.java @@ -22,15 +22,20 @@ * (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.api; -public class Renderable +public class Renderable extends Node { - private net.runelite.rs.api.Renderable renderable; + private final net.runelite.rs.api.Renderable renderable; public Renderable(net.runelite.rs.api.Renderable renderable) { + super(renderable); this.renderable = renderable; } + + public static Renderable of(net.runelite.rs.api.Renderable renderable) + { + return (Renderable) Node.of(renderable); + } } diff --git a/runelite-api/src/main/java/net/runelite/api/Tile.java b/runelite-api/src/main/java/net/runelite/api/Tile.java new file mode 100644 index 0000000000..5eba540ad8 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/Tile.java @@ -0,0 +1,106 @@ +/* + * 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.api; + +import java.util.Arrays; + +public class Tile +{ + private final Client client; + private final net.runelite.rs.api.Tile tile; + + public Tile(Client client, net.runelite.rs.api.Tile tile) + { + this.client = client; + this.tile = tile; + } + + /** + * Get the decorative object for this tile. + * + * @return + */ + public DecorativeObject getDecorativeObject() + { + net.runelite.rs.api.DecorativeObject decorativeObject = tile.getDecorativeObject(); + + if (decorativeObject == null) + { + return null; + } + + return new DecorativeObject(client, decorativeObject); + } + + public GameObject[] getGameObjects() + { + net.runelite.rs.api.GameObject[] objects = tile.getObjects(); + + if (objects == null) + { + return null; + } + + return Arrays.stream(tile.getObjects()) + .map(go -> go != null ? new GameObject(client, go) : null) + .toArray(i -> new GameObject[i]); + } + + public ItemLayer getItemLayer() + { + net.runelite.rs.api.ItemLayer itemLayer = tile.getItemLayer(); + + if (itemLayer == null) + { + return null; + } + + return new ItemLayer(client, itemLayer); + } + + public GroundObject getGroundObject() + { + net.runelite.rs.api.GroundObject groundObject = tile.getGroundObject(); + + if (groundObject == null) + { + return null; + } + + return new GroundObject(client, groundObject); + } + + public WallObject getWallObject() + { + net.runelite.rs.api.WallObject wallObject = tile.getWallObject(); + + if (wallObject == null) + { + return null; + } + + return new WallObject(client, wallObject); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/TileObject.java b/runelite-api/src/main/java/net/runelite/api/TileObject.java new file mode 100644 index 0000000000..c2b6b4077a --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/TileObject.java @@ -0,0 +1,64 @@ +/* + * 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.api; + +public abstract class TileObject +{ + protected final Client client; + + public TileObject(Client client) + { + this.client = client; + } + + protected abstract int getHash(); + + protected abstract int getLocalX(); + + protected abstract int getLocalY(); + + public int getId() + { + int hash = getHash(); + return hash >> 14 & 32767; + } + + public Point getWorldLocation() + { + Point localLocation = getLocalLocation(); + return Perspective.localToWorld(client, localLocation); + } + + public Point getLocalLocation() + { + return new Point(getLocalX(), getLocalY()); + } + + public Point getCanvasLocation() + { + Point locaLocation = getLocalLocation(); + return Perspective.worldToCanvas(client, locaLocation.getX(), locaLocation.getY(), 0); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/WallObject.java b/runelite-api/src/main/java/net/runelite/api/WallObject.java new file mode 100644 index 0000000000..244b3292c5 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/WallObject.java @@ -0,0 +1,59 @@ +/* + * 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.api; + +/** + * A wall object, which is a boundary you can't walk through. + * + * @author Adam + */ +public class WallObject extends TileObject +{ + private final net.runelite.rs.api.WallObject wallObject; + + public WallObject(Client client, net.runelite.rs.api.WallObject wallObject) + { + super(client); + this.wallObject = wallObject; + } + + @Override + protected int getHash() + { + return wallObject.getHash(); + } + + @Override + protected int getLocalX() + { + return wallObject.getX(); + } + + @Override + protected int getLocalY() + { + return wallObject.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 d52c17a018..011443e1f6 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 @@ -22,7 +22,6 @@ * (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; import java.util.ArrayList; @@ -31,12 +30,18 @@ import java.util.List; import net.runelite.client.RuneLite; import net.runelite.client.plugins.boosts.Boosts; import net.runelite.client.plugins.bosstimer.BossTimers; +import net.runelite.client.plugins.debug.Debug; import net.runelite.client.plugins.fpsinfo.FPS; +import net.runelite.client.plugins.gronditems.GroundItems; import net.runelite.client.plugins.hiscore.Hiscore; import net.runelite.client.plugins.opponentinfo.OpponentInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PluginManager { + private static final Logger logger = LoggerFactory.getLogger(PluginManager.class); + private final RuneLite runelite; private final List plugins = new ArrayList<>(); @@ -52,6 +57,14 @@ public class PluginManager load(new FPS()); load(new Hiscore()); load(new BossTimers()); + + if (RuneLite.getOptions().has("developer-mode")) + { + logger.info("Loading developer plugins"); + + load(new Debug()); + load(new GroundItems()); + } } private void load(Plugin plugin) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/debug/Debug.java b/runelite-client/src/main/java/net/runelite/client/plugins/debug/Debug.java new file mode 100644 index 0000000000..f67a382734 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/debug/Debug.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.debug; + +import net.runelite.client.plugins.Plugin; +import net.runelite.client.ui.overlay.Overlay; + +public class Debug extends Plugin +{ + private final DebugOverlay debugOverlay = new DebugOverlay(); + + @Override + public Overlay getOverlay() + { + return debugOverlay; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/debug/DebugOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/debug/DebugOverlay.java new file mode 100644 index 0000000000..481983426c --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/debug/DebugOverlay.java @@ -0,0 +1,163 @@ +/* + * 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.debug; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import net.runelite.api.Client; +import net.runelite.api.DecorativeObject; +import net.runelite.api.GameObject; +import net.runelite.api.GameState; +import net.runelite.api.GroundObject; +import net.runelite.api.Point; +import net.runelite.api.Region; +import net.runelite.api.Tile; +import net.runelite.api.TileObject; +import net.runelite.api.WallObject; +import net.runelite.client.RuneLite; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; + +public class DebugOverlay extends Overlay +{ + private static final Client client = RuneLite.getClient(); + + private static final int REGION_SIZE = 104; + + public DebugOverlay() + { + super(OverlayPosition.DYNAMIC); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (client.getGameState() != GameState.LOGGED_IN) + { + return null; + } + + Region region = client.getRegion(); + Tile[][][] tiles = region.getTiles(); + + int z = client.getPlane(); + + for (int x = 0; x < REGION_SIZE; ++x) + { + for (int y = 0; y < REGION_SIZE; ++y) + { + Tile tile = tiles[z][x][y]; + + if (tile == null) + { + continue; + } + + render(graphics, tile); + } + } + + return null; + } + + private void render(Graphics2D graphics, Tile tile) + { + renderDecorativeObject(graphics, tile); + renderWallObject(graphics, tile); + renderGroundObject(graphics, tile); + renderGameObjects(graphics, tile); + } + + private void renderDecorativeObject(Graphics2D graphics, Tile tile) + { + DecorativeObject decorativeObject = tile.getDecorativeObject(); + if (decorativeObject == null) + { + return; + } + + int id = decorativeObject.getId(); + renderTileObject(graphics, decorativeObject, Color.RED, "D" + id); + } + + private void renderWallObject(Graphics2D graphics, Tile tile) + { + WallObject wallObject = tile.getWallObject(); + if (wallObject == null) + { + return; + + } + + int id = wallObject.getId(); + renderTileObject(graphics, wallObject, Color.GREEN, "W" + id); + } + + private void renderGroundObject(Graphics2D graphics, Tile tile) + { + GroundObject groundObject = tile.getGroundObject(); + if (groundObject == null) + { + return; + + } + + int id = groundObject.getId(); + renderTileObject(graphics, groundObject, Color.BLUE, "G" + id); + } + + private void renderGameObjects(Graphics2D graphics, Tile tile) + { + GameObject[] gameObjects = tile.getGameObjects(); + if (gameObjects == null) + { + return; + } + + for (GameObject gameObject : gameObjects) + { + if (gameObject == null) + { + continue; + } + + renderTileObject(graphics, gameObject, Color.YELLOW, "GA" + gameObject.getId()); + } + } + + private void renderTileObject(Graphics2D graphics, TileObject tileObject, Color color, String text) + { + Point canvasLocation = tileObject.getCanvasLocation(); + + if (canvasLocation == null) + { + return; + } + + graphics.setColor(color); + graphics.drawString(text, canvasLocation.getX(), canvasLocation.getY()); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gronditems/GroundItems.java b/runelite-client/src/main/java/net/runelite/client/plugins/gronditems/GroundItems.java new file mode 100644 index 0000000000..1cd013c6fc --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gronditems/GroundItems.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.gronditems; + +import net.runelite.client.plugins.Plugin; +import net.runelite.client.ui.overlay.Overlay; + +public class GroundItems extends Plugin +{ + private final GroundItemsOverlay groundItemsOverlay = new GroundItemsOverlay(); + + @Override + public Overlay getOverlay() + { + return groundItemsOverlay; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gronditems/GroundItemsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/gronditems/GroundItemsOverlay.java new file mode 100644 index 0000000000..ae69f47a7b --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gronditems/GroundItemsOverlay.java @@ -0,0 +1,114 @@ +/* + * 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.gronditems; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.Item; +import net.runelite.api.ItemLayer; +import net.runelite.api.Node; +import net.runelite.api.Point; +import net.runelite.api.Region; +import net.runelite.api.Tile; +import net.runelite.client.RuneLite; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; + +public class GroundItemsOverlay extends Overlay +{ + private static final Client client = RuneLite.getClient(); + + private static final int REGION_SIZE = 104; + + public GroundItemsOverlay() + { + super(OverlayPosition.DYNAMIC); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (client.getGameState() != GameState.LOGGED_IN) + { + return null; + } + + Region region = client.getRegion(); + Tile[][][] tiles = region.getTiles(); + + int z = client.getPlane(); + + for (int x = 0; x < REGION_SIZE; ++x) + { + for (int y = 0; y < REGION_SIZE; ++y) + { + Tile tile = tiles[z][x][y]; + + if (tile == null) + { + continue; + } + + render(graphics, tile); + } + } + + return null; + } + + private void render(Graphics2D graphics, Tile tile) + { + ItemLayer itemLayer = tile.getItemLayer(); + + if (itemLayer == null) + { + return; + } + + Point canvasLocation = itemLayer.getCanvasLocation(); + if (canvasLocation == null) + { + return; + } + + Node current = itemLayer.getBottom(); + + while (current instanceof Item) + { + Item item = (Item) current; + render(graphics, canvasLocation, item); + current = current.getNext(); + } + } + + private void render(Graphics2D graphics, Point canvasLocation, Item item) + { + graphics.setColor(Color.ORANGE); + graphics.drawString("I" + item.getId(), canvasLocation.getX(), canvasLocation.getY()); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/DynamicRenderer.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/DynamicRenderer.java new file mode 100644 index 0000000000..6c5d708e80 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/DynamicRenderer.java @@ -0,0 +1,52 @@ +/* + * 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.ui.overlay; + +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; + +public class DynamicRenderer implements Renderer +{ + private final List overlays = new ArrayList<>(); + + public void add(Overlay overlay) + { + overlays.add(overlay); + } + + @Override + public void render(BufferedImage clientBuffer) + { + for (Overlay overlay : overlays) + { + Graphics2D graphics = clientBuffer.createGraphics(); + overlay.render(graphics); + graphics.dispose(); + } + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/Overlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/Overlay.java index 4fb7cc7cac..391c04baf0 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/Overlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/Overlay.java @@ -33,6 +33,11 @@ public abstract class Overlay private OverlayPosition position; // where to draw it private OverlayPriority priority; // if multiple overlays exist in the same position, who wins + public Overlay(OverlayPosition position) + { + this(position, OverlayPriority.NONE); + } + public Overlay(OverlayPosition position, OverlayPriority priority) { this.position = position; diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayPosition.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayPosition.java index e1d1a49735..300ef3507d 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayPosition.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayPosition.java @@ -22,11 +22,20 @@ * (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.ui.overlay; public enum OverlayPosition { + /** + * Place overlay in the top left most area possible + */ TOP_LEFT, - TOP_RIGHT; + /** + * Place overlay in the top right most area possible + */ + TOP_RIGHT, + /** + * Overlay places itself where it wants + */ + DYNAMIC; } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayPriority.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayPriority.java index 8cec3541f2..fecaa01c20 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayPriority.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayPriority.java @@ -27,6 +27,7 @@ package net.runelite.client.ui.overlay; public enum OverlayPriority { + NONE, LOW, MED, HIGH; diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java index 906c13ec4c..98f9eb322e 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java @@ -36,6 +36,7 @@ public class OverlayRenderer { TopDownRendererLeft tdl = new TopDownRendererLeft(); TopDownRendererRight tdr = new TopDownRendererRight(); + DynamicRenderer dr = new DynamicRenderer(); for (Plugin plugin : RuneLite.getRunelite().getPluginManager().getPlugins()) { @@ -54,10 +55,14 @@ public class OverlayRenderer case TOP_LEFT: tdl.add(overlay); break; + case DYNAMIC: + dr.add(overlay); + break; } } tdl.render(clientBuffer); tdr.render(clientBuffer); + dr.render(clientBuffer); } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/Renderer.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/Renderer.java new file mode 100644 index 0000000000..2cd6450e59 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/Renderer.java @@ -0,0 +1,32 @@ +/* + * 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.ui.overlay; + +import java.awt.image.BufferedImage; + +public interface Renderer +{ + void render(BufferedImage clientBuffer); +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/TopDownRendererLeft.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/TopDownRendererLeft.java index 03d77874d6..87f3ed5e6d 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/TopDownRendererLeft.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/TopDownRendererLeft.java @@ -31,7 +31,7 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; -public class TopDownRendererLeft +public class TopDownRendererLeft implements Renderer { private static final int BORDER_TOP = 25; private static final int BORDER_LEFT = 10; @@ -44,6 +44,7 @@ public class TopDownRendererLeft overlays.add(overlay); } + @Override public void render(BufferedImage clientBuffer) { overlays.sort((o1, o2) -> o2.getPriority().compareTo(o1.getPriority())); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/TopDownRendererRight.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/TopDownRendererRight.java index ab807cfb8d..2dfb6e5177 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/TopDownRendererRight.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/TopDownRendererRight.java @@ -25,15 +25,15 @@ package net.runelite.client.ui.overlay; -import net.runelite.api.Client; -import net.runelite.client.RuneLite; - -import java.awt.*; +import java.awt.Dimension; +import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; +import net.runelite.api.Client; +import net.runelite.client.RuneLite; -public class TopDownRendererRight +public class TopDownRendererRight implements Renderer { private static final int BORDER_TOP = 0; private static final int BORDER_RIGHT = 0; @@ -46,6 +46,7 @@ public class TopDownRendererRight overlays.add(overlay); } + @Override public void render(BufferedImage clientBuffer) { Client client = RuneLite.getClient(); diff --git a/runescape-api/src/main/java/net/runelite/rs/api/DecorativeObject.java b/runescape-api/src/main/java/net/runelite/rs/api/DecorativeObject.java new file mode 100644 index 0000000000..4c225f879d --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/DecorativeObject.java @@ -0,0 +1,39 @@ +/* + * 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.rs.api; + +import net.runelite.mapping.Import; + +public interface DecorativeObject +{ + @Import("hash") + int getHash(); + + @Import("x") + int getX(); + + @Import("y") + int getY(); +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/GroundObject.java b/runescape-api/src/main/java/net/runelite/rs/api/GroundObject.java new file mode 100644 index 0000000000..03ae0de2e5 --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/GroundObject.java @@ -0,0 +1,39 @@ +/* + * 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.rs.api; + +import net.runelite.mapping.Import; + +public interface GroundObject +{ + @Import("hash") + int getHash(); + + @Import("x") + int getX(); + + @Import("y") + int getY(); +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/Tile.java b/runescape-api/src/main/java/net/runelite/rs/api/Tile.java index c3b67299e0..029bfbfb29 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/Tile.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/Tile.java @@ -22,7 +22,6 @@ * (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.rs.api; import net.runelite.mapping.Import; @@ -35,6 +34,15 @@ public interface Tile @Import("itemLayer") ItemLayer getItemLayer(); + @Import("decorativeObject") + DecorativeObject getDecorativeObject(); + + @Import("groundObject") + GroundObject getGroundObject(); + + @Import("wallObject") + WallObject getWallObject(); + @Import("x") int getX(); diff --git a/runescape-api/src/main/java/net/runelite/rs/api/WallObject.java b/runescape-api/src/main/java/net/runelite/rs/api/WallObject.java new file mode 100644 index 0000000000..48c0a59708 --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/WallObject.java @@ -0,0 +1,39 @@ +/* + * 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.rs.api; + +import net.runelite.mapping.Import; + +public interface WallObject +{ + @Import("hash") + int getHash(); + + @Import("x") + int getX(); + + @Import("y") + int getY(); +}