@@ -29,6 +29,7 @@ import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import net.runelite.api.MainBufferProvider;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
|
||||
/**
|
||||
* Interface of callbacks the injected client uses to send events
|
||||
@@ -79,6 +80,11 @@ public interface Callbacks
|
||||
*/
|
||||
void draw(MainBufferProvider mainBufferProvider, Graphics graphics, int x, int y);
|
||||
|
||||
/**
|
||||
* Called before the client will render an item widget.
|
||||
*/
|
||||
void drawItem(int itemId, WidgetItem widgetItem);
|
||||
|
||||
/**
|
||||
* Mouse pressed event. If this event will be consumed it will not be propagated further to client.
|
||||
*
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
||||
* 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.queries;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BankItemQuery extends WidgetItemQuery
|
||||
{
|
||||
private static final int ITEM_EMPTY = 6512;
|
||||
|
||||
@Override
|
||||
public WidgetItem[] result(Client client)
|
||||
{
|
||||
Collection<WidgetItem> widgetItems = getBankItems(client);
|
||||
if (widgetItems != null)
|
||||
{
|
||||
return widgetItems.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(predicate)
|
||||
.toArray(WidgetItem[]::new);
|
||||
}
|
||||
return new WidgetItem[0];
|
||||
}
|
||||
|
||||
private Collection<WidgetItem> getBankItems(Client client)
|
||||
{
|
||||
Collection<WidgetItem> widgetItems = new ArrayList<>();
|
||||
Widget bank = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
|
||||
if (bank != null && !bank.isHidden())
|
||||
{
|
||||
Widget[] children = bank.getDynamicChildren();
|
||||
for (int i = 0; i < children.length; i++)
|
||||
{
|
||||
Widget child = children[i];
|
||||
if (child.getItemId() == ITEM_EMPTY || child.isSelfHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// set bounds to same size as default inventory
|
||||
Rectangle bounds = child.getBounds();
|
||||
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
|
||||
// Index is set to 0 because the widget's index does not correlate to the order in the bank
|
||||
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), 0, bounds));
|
||||
}
|
||||
}
|
||||
return widgetItems;
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
||||
* 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.queries;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
public class EquipmentItemQuery extends WidgetItemQuery
|
||||
{
|
||||
private static final WidgetInfo[] ALL_EQUIPMENT_WIDGET_INFOS =
|
||||
{
|
||||
WidgetInfo.EQUIPMENT_HELMET,
|
||||
WidgetInfo.EQUIPMENT_CAPE,
|
||||
WidgetInfo.EQUIPMENT_AMULET,
|
||||
WidgetInfo.EQUIPMENT_WEAPON,
|
||||
WidgetInfo.EQUIPMENT_BODY,
|
||||
WidgetInfo.EQUIPMENT_SHIELD,
|
||||
WidgetInfo.EQUIPMENT_LEGS,
|
||||
WidgetInfo.EQUIPMENT_GLOVES,
|
||||
WidgetInfo.EQUIPMENT_BOOTS,
|
||||
WidgetInfo.EQUIPMENT_RING,
|
||||
WidgetInfo.EQUIPMENT_AMMO,
|
||||
};
|
||||
|
||||
private final Collection<WidgetInfo> slots = new ArrayList<>();
|
||||
|
||||
public EquipmentItemQuery slotEquals(WidgetInfo... slotWidgetInfo)
|
||||
{
|
||||
slots.addAll(Arrays.asList(slotWidgetInfo));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WidgetItem[] result(Client client)
|
||||
{
|
||||
Collection<WidgetItem> widgetItems = getEquippedItems(client);
|
||||
if (widgetItems != null)
|
||||
{
|
||||
return widgetItems.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(predicate)
|
||||
.toArray(WidgetItem[]::new);
|
||||
}
|
||||
return new WidgetItem[0];
|
||||
}
|
||||
|
||||
private Collection<WidgetItem> getEquippedItems(Client client)
|
||||
{
|
||||
Collection<WidgetItem> widgetItems = new ArrayList<>();
|
||||
Widget equipment = client.getWidget(WidgetInfo.EQUIPMENT);
|
||||
if (equipment != null && !equipment.isHidden())
|
||||
{
|
||||
if (slots.isEmpty())
|
||||
{
|
||||
slots.addAll(Arrays.asList(ALL_EQUIPMENT_WIDGET_INFOS));
|
||||
}
|
||||
for (WidgetInfo slot : slots)
|
||||
{
|
||||
Widget parentWidget = client.getWidget(slot);
|
||||
Widget itemWidget = parentWidget.getChild(1);
|
||||
// Check if background icon is hidden. if hidden, item is equipped.
|
||||
boolean equipped = parentWidget.getChild(2).isSelfHidden();
|
||||
// set bounds to same size as default inventory
|
||||
Rectangle bounds = itemWidget.getBounds();
|
||||
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
|
||||
// Index is set to 0 because there is no set in stone order of equipment slots
|
||||
widgetItems.add(new WidgetItem(equipped ? itemWidget.getItemId() : -1, itemWidget.getItemQuantity(), 0, bounds));
|
||||
}
|
||||
}
|
||||
return widgetItems;
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
||||
* 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.queries;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
public class InventoryWidgetItemQuery extends WidgetItemQuery
|
||||
{
|
||||
private static final WidgetInfo[] INVENTORY_WIDGET_INFOS =
|
||||
{
|
||||
WidgetInfo.DEPOSIT_BOX_INVENTORY_ITEMS_CONTAINER,
|
||||
WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER,
|
||||
WidgetInfo.SHOP_INVENTORY_ITEMS_CONTAINER,
|
||||
WidgetInfo.GRAND_EXCHANGE_INVENTORY_ITEMS_CONTAINER,
|
||||
WidgetInfo.GUIDE_PRICES_INVENTORY_ITEMS_CONTAINER,
|
||||
WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER,
|
||||
WidgetInfo.INVENTORY
|
||||
};
|
||||
|
||||
@Override
|
||||
public WidgetItem[] result(Client client)
|
||||
{
|
||||
Collection<WidgetItem> widgetItems = getInventoryItems(client);
|
||||
if (widgetItems != null)
|
||||
{
|
||||
return widgetItems.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(predicate)
|
||||
.toArray(WidgetItem[]::new);
|
||||
}
|
||||
return new WidgetItem[0];
|
||||
}
|
||||
|
||||
private Collection<WidgetItem> getInventoryItems(Client client)
|
||||
{
|
||||
Collection<WidgetItem> widgetItems = new ArrayList<>();
|
||||
for (WidgetInfo widgetInfo : INVENTORY_WIDGET_INFOS)
|
||||
{
|
||||
Widget inventory = client.getWidget(widgetInfo);
|
||||
if (inventory == null || inventory.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (widgetInfo == WidgetInfo.INVENTORY)
|
||||
{
|
||||
widgetItems.addAll(inventory.getWidgetItems());
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Widget[] children = inventory.getDynamicChildren();
|
||||
for (int i = 0; i < children.length; i++)
|
||||
{
|
||||
Widget child = children[i];
|
||||
// set bounds to same size as default inventory
|
||||
Rectangle bounds = child.getBounds();
|
||||
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
|
||||
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i, bounds));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return widgetItems;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
||||
* 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.queries;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ShopItemQuery extends WidgetItemQuery
|
||||
{
|
||||
@Override
|
||||
public WidgetItem[] result(Client client)
|
||||
{
|
||||
Collection<WidgetItem> widgetItems = getShopItems(client);
|
||||
if (widgetItems != null)
|
||||
{
|
||||
return widgetItems.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(predicate)
|
||||
.toArray(WidgetItem[]::new);
|
||||
}
|
||||
return new WidgetItem[0];
|
||||
}
|
||||
|
||||
private Collection<WidgetItem> getShopItems(Client client)
|
||||
{
|
||||
Collection<WidgetItem> widgetItems = new ArrayList<>();
|
||||
Widget shop = client.getWidget(WidgetInfo.SHOP_ITEMS_CONTAINER);
|
||||
if (shop != null && !shop.isHidden())
|
||||
{
|
||||
Widget[] children = shop.getDynamicChildren();
|
||||
for (int i = 1; i < children.length; i++)
|
||||
{
|
||||
Widget child = children[i];
|
||||
// set bounds to same size as default inventory
|
||||
Rectangle bounds = child.getBounds();
|
||||
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
|
||||
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i - 1, bounds));
|
||||
}
|
||||
}
|
||||
return widgetItems;
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,7 @@ public class WidgetID
|
||||
public static final int SKILLS_GROUP_ID = 320;
|
||||
public static final int QUESTTAB_GROUP_ID = 629;
|
||||
public static final int MUSIC_GROUP_ID = 239;
|
||||
public static final int BARROWS_PUZZLE_GROUP_ID = 25;
|
||||
|
||||
static class WorldMap
|
||||
{
|
||||
@@ -577,7 +578,7 @@ public class WidgetID
|
||||
{
|
||||
static final int POINTS_INFOBOX = 6;
|
||||
}
|
||||
|
||||
|
||||
static class ExperienceDrop
|
||||
{
|
||||
static final int DROP_1 = 15;
|
||||
@@ -771,4 +772,26 @@ public class WidgetID
|
||||
static final int CONTAINER = 0;
|
||||
static final int LIST = 3;
|
||||
}
|
||||
|
||||
static class Barrows_Puzzle
|
||||
{
|
||||
static final int PARENT = 0;
|
||||
static final int CONTAINER = 1;
|
||||
static final int TOP_ROW_PUZZLE = 2;
|
||||
static final int SEQUENCE_1 = 3;
|
||||
static final int SEQUENCE_1_TEXT = 4;
|
||||
static final int SEQUENCE_2 = 5;
|
||||
static final int SEQUENCE_2_TEXT = 6;
|
||||
static final int SEQUENCE_3 = 7;
|
||||
static final int SEQUENCE_3_TEXT = 8;
|
||||
static final int SEQUENCE_4 = 9;
|
||||
static final int SEQUENCE_4_TEXT = 10;
|
||||
static final int NEXT_SHAPE_TEXT = 11;
|
||||
static final int ANSWER1_CONTAINER = 12;
|
||||
static final int ANSWER1 = 13;
|
||||
static final int ANSWER2_CONTAINER = 14;
|
||||
static final int ANSWER2 = 15;
|
||||
static final int ANSWER3_CONTAINER = 16;
|
||||
static final int ANSWER3 = 17;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,6 +410,14 @@ public enum WidgetInfo
|
||||
BARROWS_BROTHERS(WidgetID.BARROWS_GROUP_ID, WidgetID.Barrows.BARROWS_BROTHERS),
|
||||
BARROWS_POTENTIAL(WidgetID.BARROWS_GROUP_ID, WidgetID.Barrows.BARROWS_POTENTIAL),
|
||||
BARROWS_REWARD_INVENTORY(WidgetID.BARROWS_REWARD_GROUP_ID, WidgetID.Barrows.BARROWS_REWARD_INVENTORY),
|
||||
BARROWS_PUZZLE_PARENT(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.PARENT),
|
||||
BARROWS_PUZZLE_ANSWER1(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER1),
|
||||
BARROWS_PUZZLE_ANSWER1_CONTAINER(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER1_CONTAINER),
|
||||
BARROWS_PUZZLE_ANSWER2(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER2),
|
||||
BARROWS_PUZZLE_ANSWER2_CONTAINER(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER2_CONTAINER),
|
||||
BARROWS_PUZZLE_ANSWER3(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER3),
|
||||
BARROWS_PUZZLE_ANSWER3_CONTAINER(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER3_CONTAINER),
|
||||
BARROWS_FIRST_PUZZLE(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.SEQUENCE_1),
|
||||
|
||||
BLAST_MINE(WidgetID.BLAST_MINE_GROUP_ID, 2),
|
||||
|
||||
|
||||
@@ -25,11 +25,15 @@
|
||||
package net.runelite.api.widgets;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import net.runelite.api.Point;
|
||||
|
||||
/**
|
||||
* An item that is being represented in a {@link Widget}.
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class WidgetItem
|
||||
{
|
||||
private final int id;
|
||||
@@ -37,20 +41,6 @@ public class WidgetItem
|
||||
private final int index;
|
||||
private final Rectangle canvasBounds;
|
||||
|
||||
public WidgetItem(int id, int quantity, int index, Rectangle canvasBounds)
|
||||
{
|
||||
this.id = id;
|
||||
this.quantity = quantity;
|
||||
this.index = index;
|
||||
this.canvasBounds = canvasBounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "WidgetItem{" + "id=" + id + ", quantity=" + quantity + ", index=" + index + ", canvasBounds=" + canvasBounds + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID of the item represented.
|
||||
*
|
||||
|
||||
@@ -50,7 +50,6 @@ import net.runelite.client.rs.ClientUpdateCheckMode;
|
||||
import net.runelite.client.task.Scheduler;
|
||||
import net.runelite.client.util.DeferredEventBus;
|
||||
import net.runelite.client.util.ExecutorServiceExceptionLogger;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.slf4j.Logger;
|
||||
@@ -75,7 +74,6 @@ public class RuneLiteModule extends AbstractModule
|
||||
bindConstant().annotatedWith(Names.named("developerMode")).to(developerMode);
|
||||
bind(ScheduledExecutorService.class).toInstance(new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor()));
|
||||
bind(OkHttpClient.class).toInstance(RuneLiteAPI.CLIENT);
|
||||
bind(QueryRunner.class);
|
||||
bind(MenuManager.class);
|
||||
bind(ChatMessageManager.class);
|
||||
bind(ItemManager.class);
|
||||
|
||||
@@ -43,6 +43,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.BufferProvider;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MainBufferProvider;
|
||||
import net.runelite.api.NullItemID;
|
||||
import net.runelite.api.RenderOverview;
|
||||
import net.runelite.api.Renderable;
|
||||
import net.runelite.api.WorldMapManager;
|
||||
@@ -52,6 +53,7 @@ import net.runelite.api.hooks.Callbacks;
|
||||
import net.runelite.api.hooks.DrawCallbacks;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP_VIEW;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
@@ -62,6 +64,7 @@ import net.runelite.client.task.Scheduler;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.DrawManager;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.util.DeferredEventBus;
|
||||
@@ -80,6 +83,7 @@ public class Hooks implements Callbacks
|
||||
private static final Injector injector = RuneLite.getInjector();
|
||||
private static final Client client = injector.getInstance(Client.class);
|
||||
private static final OverlayRenderer renderer = injector.getInstance(OverlayRenderer.class);
|
||||
private static final OverlayManager overlayManager = injector.getInstance(OverlayManager.class);
|
||||
|
||||
private static final GameTick GAME_TICK = new GameTick();
|
||||
private static final BeforeRender BEFORE_RENDER = new BeforeRender();
|
||||
@@ -443,6 +447,10 @@ public class Hooks implements Callbacks
|
||||
{
|
||||
graphics2d.dispose();
|
||||
}
|
||||
|
||||
// WidgetItemOverlays render at ABOVE_WIDGETS, reset widget item
|
||||
// list for next frame.
|
||||
overlayManager.getItemWidgets().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -490,4 +498,14 @@ public class Hooks implements Callbacks
|
||||
pixelPos += pixelJump;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawItem(int itemId, WidgetItem widgetItem)
|
||||
{
|
||||
// Empty bank item
|
||||
if (widgetItem.getId() != NullItemID.NULL_6512)
|
||||
{
|
||||
overlayManager.getItemWidgets().add(widgetItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public enum AgilityShortcut
|
||||
CORSAIR_COVE_DUNGEON_PILLAR(15, "Pillar Jump", new WorldPoint(1980, 8996, 0), PILLAR_31809),
|
||||
EDGEVILLE_DUNGEON_MONKEYBARS(15, "Monkey Bars", null, MONKEYBARS_23566),
|
||||
TROLLHEIM_ROCKS(15, "Rocks", null, new WorldPoint(2838, 3614, 0), ROCKS_3748), // No fixed world map location, but rocks near death plateau have a requirement of 15
|
||||
YANILLE_UNDERWALL_TUNNEL(16, "Underwall Tunnel", new WorldPoint(2574, 3109, 0), HOLE_16520, WALL_17047),
|
||||
YANILLE_UNDERWALL_TUNNEL(16, "Underwall Tunnel", new WorldPoint(2574, 3109, 0), HOLE_16520, CASTLE_WALL),
|
||||
YANILLE_WATCHTOWER_TRELLIS(18, "Trellis", null, TRELLIS_20056),
|
||||
COAL_TRUCKS_LOG_BALANCE(20, "Log Balance", new WorldPoint(2598, 3475, 0), LOG_BALANCE_23274),
|
||||
GRAND_EXCHANGE_UNDERWALL_TUNNEL(21, "Underwall Tunnel", new WorldPoint(3139, 3515, 0), UNDERWALL_TUNNEL_16529, UNDERWALL_TUNNEL_16530),
|
||||
@@ -106,7 +106,7 @@ public enum AgilityShortcut
|
||||
CATHERBY_OBELISK_GRAPPLE(36, "Grapple Rock", new WorldPoint(2841, 3434, 0), CROSSBOW_TREE_17062),
|
||||
GNOME_STRONGHOLD_ROCKS(37, "Rocks", new WorldPoint(2485, 3515, 0), ROCKS_16534, ROCKS_16535),
|
||||
AL_KHARID_MINING_PITCLIFF_SCRAMBLE(38, "Rocks", new WorldPoint(3305, 3315, 0), ROCKS_16549, ROCKS_16550),
|
||||
YANILLE_WALL_GRAPPLE(39, "Grapple Wall", new WorldPoint(2552, 3072, 0), CASTLE_WALL),
|
||||
YANILLE_WALL_GRAPPLE(39, "Grapple Wall", new WorldPoint(2552, 3072, 0), WALL_17047),
|
||||
NEITIZNOT_BRIDGE_REPAIR(40, "Bridge Repair - Quest", new WorldPoint(2315, 3828, 0), ROPE_BRIDGE_21306, ROPE_BRIDGE_21307),
|
||||
KOUREND_LAKE_JUMP_EAST(40, "Stepping Stones", new WorldPoint(1612, 3570, 0), STEPPING_STONE_29729, STEPPING_STONE_29730),
|
||||
KOUREND_LAKE_JUMP_WEST(40, "Stepping Stones", new WorldPoint(1604, 3572, 0), STEPPING_STONE_29729, STEPPING_STONE_29730),
|
||||
|
||||
@@ -86,4 +86,15 @@ public interface BarrowsConfig extends Config
|
||||
{
|
||||
return Color.RED;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showPuzzleAnswer",
|
||||
name = "Show Puzzle Answer",
|
||||
description = "Configures if the puzzle answer should be shown.",
|
||||
position = 5
|
||||
)
|
||||
default boolean showPuzzleAnswer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.barrows;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
@@ -38,6 +39,7 @@ import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.WallObject;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
@@ -66,6 +68,7 @@ class BarrowsOverlay extends Overlay
|
||||
Player local = client.getLocalPlayer();
|
||||
final Color npcColor = getMinimapDotColor(1);
|
||||
final Color playerColor = getMinimapDotColor(2);
|
||||
Widget puzzleAnswer = plugin.getPuzzleAnswer();
|
||||
|
||||
// tunnels are only on z=0
|
||||
if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && config.showMinimap())
|
||||
@@ -119,6 +122,13 @@ class BarrowsOverlay extends Overlay
|
||||
renderBarrowsBrothers(graphics);
|
||||
}
|
||||
|
||||
if (puzzleAnswer != null && config.showPuzzleAnswer() && !puzzleAnswer.isHidden())
|
||||
{
|
||||
Rectangle answerRect = puzzleAnswer.getBounds();
|
||||
graphics.setColor(Color.GREEN);
|
||||
graphics.draw(answerRect);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.barrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Provides;
|
||||
import java.util.HashSet;
|
||||
@@ -82,6 +83,11 @@ public class BarrowsPlugin extends Plugin
|
||||
);
|
||||
|
||||
private static final Set<Integer> BARROWS_LADDERS = Sets.newHashSet(NullObjectID.NULL_20675, NullObjectID.NULL_20676, NullObjectID.NULL_20677);
|
||||
private static final ImmutableList<WidgetInfo> POSSIBLE_SOLUTIONS = ImmutableList.of(
|
||||
WidgetInfo.BARROWS_PUZZLE_ANSWER1,
|
||||
WidgetInfo.BARROWS_PUZZLE_ANSWER2,
|
||||
WidgetInfo.BARROWS_PUZZLE_ANSWER3
|
||||
);
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final Set<WallObject> walls = new HashSet<>();
|
||||
@@ -89,6 +95,9 @@ public class BarrowsPlugin extends Plugin
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final Set<GameObject> ladders = new HashSet<>();
|
||||
|
||||
@Getter
|
||||
private Widget puzzleAnswer;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@@ -130,6 +139,7 @@ public class BarrowsPlugin extends Plugin
|
||||
overlayManager.remove(brotherOverlay);
|
||||
walls.clear();
|
||||
ladders.clear();
|
||||
puzzleAnswer = null;
|
||||
|
||||
// Restore widgets
|
||||
final Widget potential = client.getWidget(WidgetInfo.BARROWS_POTENTIAL);
|
||||
@@ -213,6 +223,7 @@ public class BarrowsPlugin extends Plugin
|
||||
// on region changes the tiles get set to null
|
||||
walls.clear();
|
||||
ladders.clear();
|
||||
puzzleAnswer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,5 +254,21 @@ public class BarrowsPlugin extends Plugin
|
||||
.runeLiteFormattedMessage(message.build())
|
||||
.build());
|
||||
}
|
||||
else if (event.getGroupId() == WidgetID.BARROWS_PUZZLE_GROUP_ID)
|
||||
{
|
||||
final int answer = client.getWidget(WidgetInfo.BARROWS_FIRST_PUZZLE).getModelId() - 3;
|
||||
puzzleAnswer = null;
|
||||
|
||||
for (WidgetInfo puzzleNode : POSSIBLE_SOLUTIONS)
|
||||
{
|
||||
final Widget widgetToCheck = client.getWidget(puzzleNode);
|
||||
|
||||
if (widgetToCheck != null && widgetToCheck.getModelId() == answer)
|
||||
{
|
||||
puzzleAnswer = client.getWidget(puzzleNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,65 +25,39 @@
|
||||
package net.runelite.client.plugins.inventorytags;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||
|
||||
public class InventoryTagsOverlay extends Overlay
|
||||
public class InventoryTagsOverlay extends WidgetItemOverlay
|
||||
{
|
||||
private final QueryRunner queryRunner;
|
||||
private final ItemManager itemManager;
|
||||
private final InventoryTagsPlugin plugin;
|
||||
|
||||
@Inject
|
||||
private InventoryTagsOverlay(QueryRunner queryRunner, ItemManager itemManager, InventoryTagsPlugin plugin)
|
||||
private InventoryTagsOverlay(ItemManager itemManager, InventoryTagsPlugin plugin)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setPriority(OverlayPriority.LOW);
|
||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
this.queryRunner = queryRunner;
|
||||
this.itemManager = itemManager;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||
{
|
||||
if (!plugin.isHasTaggedItems())
|
||||
final String group = plugin.getTag(itemId);
|
||||
if (group != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Now query the inventory for the tagged item ids
|
||||
final Query query = new InventoryWidgetItemQuery();
|
||||
final WidgetItem[] widgetItems = queryRunner.runQuery(query);
|
||||
|
||||
// Iterate through all found items and draw the outlines
|
||||
for (final WidgetItem item : widgetItems)
|
||||
{
|
||||
final String group = plugin.getTag(item.getId());
|
||||
|
||||
if (group != null)
|
||||
final Color color = plugin.getGroupNameColor(group);
|
||||
if (color != null)
|
||||
{
|
||||
final Color color = plugin.getGroupNameColor(group);
|
||||
if (color != null)
|
||||
{
|
||||
final BufferedImage outline = itemManager.getItemOutline(item.getId(), item.getQuantity(), color);
|
||||
graphics.drawImage(outline, item.getCanvasLocation().getX() + 1, item.getCanvasLocation().getY() + 1, null);
|
||||
}
|
||||
Rectangle bounds = itemWidget.getCanvasBounds();
|
||||
final BufferedImage outline = itemManager.getItemOutline(itemId, itemWidget.getQuantity(), color);
|
||||
graphics.drawImage(outline, (int) bounds.getX() + 1, (int) bounds.getY() + 1, null);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,15 +30,9 @@ import com.google.inject.Provides;
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.MenuOpened;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
||||
@@ -107,9 +101,6 @@ public class InventoryTagsPlugin extends Plugin
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean hasTaggedItems;
|
||||
|
||||
private boolean editorMode;
|
||||
|
||||
@Provides
|
||||
@@ -151,7 +142,7 @@ public class InventoryTagsPlugin extends Plugin
|
||||
{
|
||||
removeInventoryMenuOptions();
|
||||
overlayManager.remove(overlay);
|
||||
hasTaggedItems = editorMode = false;
|
||||
editorMode = false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -179,14 +170,10 @@ public class InventoryTagsPlugin extends Plugin
|
||||
if (event.getMenuOption().equals(MENU_SET))
|
||||
{
|
||||
setTag(event.getId(), selectedMenu);
|
||||
|
||||
hasTaggedItems = true;
|
||||
}
|
||||
else if (event.getMenuOption().equals(MENU_REMOVE))
|
||||
{
|
||||
unsetTag(event.getId());
|
||||
|
||||
checkForTags(client.getItemContainer(InventoryID.INVENTORY));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,47 +222,6 @@ public class InventoryTagsPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onItemContainerChanged(ItemContainerChanged itemContainerChanged)
|
||||
{
|
||||
ItemContainer itemContainer = itemContainerChanged.getItemContainer();
|
||||
if (itemContainer == client.getItemContainer(InventoryID.INVENTORY))
|
||||
{
|
||||
checkForTags(itemContainer);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForTags(ItemContainer itemContainer)
|
||||
{
|
||||
hasTaggedItems = false;
|
||||
|
||||
if (itemContainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Item[] items = itemContainer.getItems();
|
||||
if (items != null)
|
||||
{
|
||||
for (Item item : items)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String tag = getTag(item.getId());
|
||||
if (tag == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
hasTaggedItems = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Color getGroupNameColor(final String name)
|
||||
{
|
||||
switch (name)
|
||||
|
||||
@@ -24,125 +24,93 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.itemcharges;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.EquipmentItemQuery;
|
||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.*;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRACELET;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.FUNGICIDE_SPRAY;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
class ItemChargeOverlay extends Overlay
|
||||
class ItemChargeOverlay extends WidgetItemOverlay
|
||||
{
|
||||
private final QueryRunner queryRunner;
|
||||
private final ItemChargePlugin itemChargePlugin;
|
||||
private final ItemChargeConfig config;
|
||||
|
||||
@Inject
|
||||
ItemChargeOverlay(QueryRunner queryRunner, ItemChargePlugin itemChargePlugin, ItemChargeConfig config)
|
||||
ItemChargeOverlay(ItemChargePlugin itemChargePlugin, ItemChargeConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
this.queryRunner = queryRunner;
|
||||
this.itemChargePlugin = itemChargePlugin;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||
{
|
||||
if (!displayOverlay())
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
for (WidgetItem item : getChargeWidgetItems())
|
||||
int charges;
|
||||
if (itemId == ItemID.DODGY_NECKLACE)
|
||||
{
|
||||
int charges;
|
||||
if (item.getId() == ItemID.DODGY_NECKLACE)
|
||||
if (!config.showDodgyCount())
|
||||
{
|
||||
if (!config.showDodgyCount())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
charges = config.dodgyNecklace();
|
||||
}
|
||||
else if (item.getId() == ItemID.BINDING_NECKLACE)
|
||||
{
|
||||
if (!config.showBindingNecklaceCharges())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
charges = config.bindingNecklace();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemWithCharge chargeItem = ItemWithCharge.findItem(item.getId());
|
||||
if (chargeItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemChargeType type = chargeItem.getType();
|
||||
if ((type == TELEPORT && !config.showTeleportCharges())
|
||||
|| (type == FUNGICIDE_SPRAY && !config.showFungicideCharges())
|
||||
|| (type == IMPBOX && !config.showImpCharges())
|
||||
|| (type == WATERCAN && !config.showWateringCanCharges())
|
||||
|| (type == WATERSKIN && !config.showWaterskinCharges())
|
||||
|| (type == BELLOWS && !config.showBellowCharges())
|
||||
|| (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
charges = chargeItem.getCharges();
|
||||
return;
|
||||
}
|
||||
|
||||
final Rectangle bounds = item.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
|
||||
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
|
||||
textComponent.setColor(itemChargePlugin.getColor(charges));
|
||||
textComponent.render(graphics);
|
||||
charges = config.dodgyNecklace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else if (itemId == ItemID.BINDING_NECKLACE)
|
||||
{
|
||||
if (!config.showBindingNecklaceCharges())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
private Collection<WidgetItem> getChargeWidgetItems()
|
||||
{
|
||||
Query inventoryQuery = new InventoryWidgetItemQuery();
|
||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||
charges = config.bindingNecklace();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId);
|
||||
if (chargeItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(
|
||||
WidgetInfo.EQUIPMENT_AMULET,
|
||||
WidgetInfo.EQUIPMENT_RING,
|
||||
WidgetInfo.EQUIPMENT_GLOVES,
|
||||
WidgetInfo.EQUIPMENT_WEAPON
|
||||
);
|
||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||
ItemChargeType type = chargeItem.getType();
|
||||
if ((type == TELEPORT && !config.showTeleportCharges())
|
||||
|| (type == FUNGICIDE_SPRAY && !config.showFungicideCharges())
|
||||
|| (type == IMPBOX && !config.showImpCharges())
|
||||
|| (type == WATERCAN && !config.showWateringCanCharges())
|
||||
|| (type == WATERSKIN && !config.showWaterskinCharges())
|
||||
|| (type == BELLOWS && !config.showBellowCharges())
|
||||
|| (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<WidgetItem> jewellery = new ArrayList<>();
|
||||
jewellery.addAll(Arrays.asList(inventoryWidgetItems));
|
||||
jewellery.addAll(Arrays.asList(equipmentWidgetItems));
|
||||
return jewellery;
|
||||
charges = chargeItem.getCharges();
|
||||
}
|
||||
|
||||
final Rectangle bounds = itemWidget.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
|
||||
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
|
||||
textComponent.setColor(itemChargePlugin.getColor(charges));
|
||||
textComponent.render(graphics);
|
||||
}
|
||||
|
||||
private boolean displayOverlay()
|
||||
|
||||
@@ -32,24 +32,19 @@ import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import static net.runelite.client.plugins.runepouch.config.RunePouchOverlayMode.BOTH;
|
||||
import static net.runelite.client.plugins.runepouch.config.RunePouchOverlayMode.MOUSE_HOVER;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||
import net.runelite.client.ui.overlay.tooltip.Tooltip;
|
||||
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
public class RunepouchOverlay extends Overlay
|
||||
public class RunepouchOverlay extends WidgetItemOverlay
|
||||
{
|
||||
private static final Varbits[] AMOUNT_VARBITS =
|
||||
{
|
||||
@@ -61,8 +56,6 @@ public class RunepouchOverlay extends Overlay
|
||||
};
|
||||
private static final Dimension IMAGE_SIZE = new Dimension(11, 11);
|
||||
|
||||
|
||||
private final QueryRunner queryRunner;
|
||||
private final Client client;
|
||||
private final RunepouchConfig config;
|
||||
private final TooltipManager tooltipManager;
|
||||
@@ -71,37 +64,26 @@ public class RunepouchOverlay extends Overlay
|
||||
private ItemManager itemManager;
|
||||
|
||||
@Inject
|
||||
RunepouchOverlay(QueryRunner queryRunner, Client client, RunepouchConfig config, TooltipManager tooltipManager)
|
||||
RunepouchOverlay(Client client, RunepouchConfig config, TooltipManager tooltipManager)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
this.tooltipManager = tooltipManager;
|
||||
this.queryRunner = queryRunner;
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||
{
|
||||
Query query = new InventoryWidgetItemQuery().idEquals(ItemID.RUNE_POUCH);
|
||||
WidgetItem[] items = queryRunner.runQuery(query);
|
||||
if (items.length == 0)
|
||||
if (itemId != ItemID.RUNE_POUCH)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
WidgetItem runePouch = items[0];
|
||||
Point location = runePouch.getCanvasLocation();
|
||||
if (location == null)
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
assert AMOUNT_VARBITS.length == RUNE_VARBITS.length;
|
||||
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
Point location = itemWidget.getCanvasLocation();
|
||||
StringBuilder tooltipBuilder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < AMOUNT_VARBITS.length; i++)
|
||||
@@ -158,12 +140,11 @@ public class RunepouchOverlay extends Overlay
|
||||
String tooltip = tooltipBuilder.toString();
|
||||
|
||||
if (!tooltip.isEmpty()
|
||||
&& runePouch.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())
|
||||
&& itemWidget.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())
|
||||
&& (config.runePouchOverlayMode() == MOUSE_HOVER || config.runePouchOverlayMode() == BOTH))
|
||||
{
|
||||
tooltipManager.add(new Tooltip(tooltip));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BufferedImage getRuneImage(Runes rune)
|
||||
|
||||
@@ -24,111 +24,88 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import static com.google.common.collect.ObjectArrays.concat;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import com.google.common.primitives.ImmutableIntArray;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.EquipmentItemQuery;
|
||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
class SlayerOverlay extends Overlay
|
||||
class SlayerOverlay extends WidgetItemOverlay
|
||||
{
|
||||
private final static Set<Integer> SLAYER_JEWELRY = ImmutableSet.of(
|
||||
ItemID.SLAYER_RING_1,
|
||||
ItemID.SLAYER_RING_2,
|
||||
ItemID.SLAYER_RING_3,
|
||||
ItemID.SLAYER_RING_4,
|
||||
ItemID.SLAYER_RING_5,
|
||||
ItemID.SLAYER_RING_6,
|
||||
ItemID.SLAYER_RING_7,
|
||||
ItemID.SLAYER_RING_8
|
||||
ItemID.SLAYER_RING_1,
|
||||
ItemID.SLAYER_RING_2,
|
||||
ItemID.SLAYER_RING_3,
|
||||
ItemID.SLAYER_RING_4,
|
||||
ItemID.SLAYER_RING_5,
|
||||
ItemID.SLAYER_RING_6,
|
||||
ItemID.SLAYER_RING_7,
|
||||
ItemID.SLAYER_RING_8
|
||||
);
|
||||
|
||||
private final static ImmutableIntArray ALL_SLAYER_ITEMS = ImmutableIntArray.of(
|
||||
ItemID.SLAYER_HELMET,
|
||||
ItemID.SLAYER_HELMET_I,
|
||||
ItemID.BLACK_SLAYER_HELMET,
|
||||
ItemID.BLACK_SLAYER_HELMET_I,
|
||||
ItemID.GREEN_SLAYER_HELMET,
|
||||
ItemID.GREEN_SLAYER_HELMET_I,
|
||||
ItemID.PURPLE_SLAYER_HELMET,
|
||||
ItemID.PURPLE_SLAYER_HELMET_I,
|
||||
ItemID.RED_SLAYER_HELMET,
|
||||
ItemID.RED_SLAYER_HELMET_I,
|
||||
ItemID.TURQUOISE_SLAYER_HELMET,
|
||||
ItemID.TURQUOISE_SLAYER_HELMET_I,
|
||||
ItemID.HYDRA_SLAYER_HELMET,
|
||||
ItemID.HYDRA_SLAYER_HELMET_I,
|
||||
ItemID.SLAYER_RING_ETERNAL,
|
||||
ItemID.ENCHANTED_GEM,
|
||||
ItemID.ETERNAL_GEM,
|
||||
ItemID.BRACELET_OF_SLAUGHTER,
|
||||
ItemID.EXPEDITIOUS_BRACELET,
|
||||
ItemID.SLAYER_RING_1,
|
||||
ItemID.SLAYER_RING_2,
|
||||
ItemID.SLAYER_RING_3,
|
||||
ItemID.SLAYER_RING_4,
|
||||
ItemID.SLAYER_RING_5,
|
||||
ItemID.SLAYER_RING_6,
|
||||
ItemID.SLAYER_RING_7,
|
||||
ItemID.SLAYER_RING_8
|
||||
private final static Set<Integer> ALL_SLAYER_ITEMS = ImmutableSet.of(
|
||||
ItemID.SLAYER_HELMET,
|
||||
ItemID.SLAYER_HELMET_I,
|
||||
ItemID.BLACK_SLAYER_HELMET,
|
||||
ItemID.BLACK_SLAYER_HELMET_I,
|
||||
ItemID.GREEN_SLAYER_HELMET,
|
||||
ItemID.GREEN_SLAYER_HELMET_I,
|
||||
ItemID.PURPLE_SLAYER_HELMET,
|
||||
ItemID.PURPLE_SLAYER_HELMET_I,
|
||||
ItemID.RED_SLAYER_HELMET,
|
||||
ItemID.RED_SLAYER_HELMET_I,
|
||||
ItemID.TURQUOISE_SLAYER_HELMET,
|
||||
ItemID.TURQUOISE_SLAYER_HELMET_I,
|
||||
ItemID.HYDRA_SLAYER_HELMET,
|
||||
ItemID.HYDRA_SLAYER_HELMET_I,
|
||||
ItemID.SLAYER_RING_ETERNAL,
|
||||
ItemID.ENCHANTED_GEM,
|
||||
ItemID.ETERNAL_GEM,
|
||||
ItemID.BRACELET_OF_SLAUGHTER,
|
||||
ItemID.EXPEDITIOUS_BRACELET,
|
||||
ItemID.SLAYER_RING_1,
|
||||
ItemID.SLAYER_RING_2,
|
||||
ItemID.SLAYER_RING_3,
|
||||
ItemID.SLAYER_RING_4,
|
||||
ItemID.SLAYER_RING_5,
|
||||
ItemID.SLAYER_RING_6,
|
||||
ItemID.SLAYER_RING_7,
|
||||
ItemID.SLAYER_RING_8
|
||||
);
|
||||
|
||||
private final SlayerConfig config;
|
||||
private final SlayerPlugin plugin;
|
||||
private final QueryRunner queryRunner;
|
||||
|
||||
@Inject
|
||||
private SlayerOverlay(SlayerPlugin plugin, SlayerConfig config, QueryRunner queryRunner)
|
||||
private SlayerOverlay(SlayerPlugin plugin, SlayerConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.queryRunner = queryRunner;
|
||||
}
|
||||
|
||||
private ImmutableList<WidgetItem> getSlayerItems()
|
||||
{
|
||||
int[] slayerItems = ALL_SLAYER_ITEMS.toArray();
|
||||
Query inventoryQuery = new InventoryWidgetItemQuery().idEquals(slayerItems);
|
||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||
|
||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_HELMET, WidgetInfo.EQUIPMENT_RING, WidgetInfo.EQUIPMENT_GLOVES).idEquals(slayerItems);
|
||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||
|
||||
WidgetItem[] items = concat(inventoryWidgetItems, equipmentWidgetItems, WidgetItem.class);
|
||||
return ImmutableList.copyOf(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||
{
|
||||
if (!ALL_SLAYER_ITEMS.contains(itemId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.showItemOverlay())
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
int amount = plugin.getAmount();
|
||||
if (amount <= 0)
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
int slaughterCount = plugin.getSlaughterChargeCount();
|
||||
@@ -136,33 +113,26 @@ class SlayerOverlay extends Overlay
|
||||
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
for (WidgetItem item : getSlayerItems())
|
||||
final Rectangle bounds = itemWidget.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
|
||||
switch (itemId)
|
||||
{
|
||||
int itemId = item.getId();
|
||||
|
||||
final Rectangle bounds = item.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
|
||||
switch (item.getId())
|
||||
{
|
||||
case ItemID.EXPEDITIOUS_BRACELET:
|
||||
textComponent.setText(String.valueOf(expeditiousCount));
|
||||
break;
|
||||
case ItemID.BRACELET_OF_SLAUGHTER:
|
||||
textComponent.setText(String.valueOf(slaughterCount));
|
||||
break;
|
||||
default:
|
||||
textComponent.setText(String.valueOf(amount));
|
||||
break;
|
||||
}
|
||||
|
||||
// Draw the counter in the bottom left for equipment, and top left for jewelry
|
||||
textComponent.setPosition(new Point(bounds.x, bounds.y + (SLAYER_JEWELRY.contains(itemId)
|
||||
? bounds.height
|
||||
: graphics.getFontMetrics().getHeight())));
|
||||
textComponent.render(graphics);
|
||||
case ItemID.EXPEDITIOUS_BRACELET:
|
||||
textComponent.setText(String.valueOf(expeditiousCount));
|
||||
break;
|
||||
case ItemID.BRACELET_OF_SLAUGHTER:
|
||||
textComponent.setText(String.valueOf(slaughterCount));
|
||||
break;
|
||||
default:
|
||||
textComponent.setText(String.valueOf(amount));
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
// Draw the counter in the bottom left for equipment, and top left for jewelry
|
||||
textComponent.setPosition(new Point(bounds.x, bounds.y + (SLAYER_JEWELRY.contains(itemId)
|
||||
? bounds.height
|
||||
: graphics.getFontMetrics().getHeight())));
|
||||
textComponent.render(graphics);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ enum Task
|
||||
ABERRANT_SPECTRES("Aberrant spectres", ItemID.ABERRANT_SPECTRE, "Spectre"),
|
||||
ABYSSAL_DEMONS("Abyssal demons", ItemID.ABYSSAL_DEMON),
|
||||
ABYSSAL_SIRE("Abyssal Sire", ItemID.ABYSSAL_ORPHAN),
|
||||
ADAMANT_DRAGONS("Adamant dragons", ItemID.ADAMANTITE_BAR),
|
||||
ADAMANT_DRAGONS("Adamant dragons", ItemID.ADAMANT_DRAGON_MASK),
|
||||
ALCHEMICAL_HYDRA("Alchemical Hydra", ItemID.IKKLE_HYDRA),
|
||||
ANKOU("Ankou", ItemID.ANKOU_MASK),
|
||||
AVIANSIES("Aviansies", ItemID.ENSOULED_AVIANSIE_HEAD),
|
||||
@@ -137,7 +137,7 @@ enum Task
|
||||
RATS("Rats", ItemID.RATS_TAIL),
|
||||
RED_DRAGONS("Red dragons", ItemID.BABY_RED_DRAGON),
|
||||
ROCKSLUGS("Rockslugs", ItemID.ROCKSLUG, 4, ItemID.BAG_OF_SALT),
|
||||
RUNE_DRAGONS("Rune dragons", ItemID.RUNITE_BAR),
|
||||
RUNE_DRAGONS("Rune dragons", ItemID.RUNE_DRAGON_MASK),
|
||||
SCORPIA("Scorpia", ItemID.SCORPIAS_OFFSPRING),
|
||||
CHAOS_DRUIDS("Chaos druids", ItemID.ELDER_CHAOS_HOOD, "Elder Chaos druid", "Chaos druid"),
|
||||
BANDITS("Bandits", ItemID.BANDIT, "Bandit"),
|
||||
|
||||
@@ -41,6 +41,7 @@ import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
@@ -96,6 +97,8 @@ public class OverlayManager
|
||||
*/
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final List<Overlay> overlays = new ArrayList<>();
|
||||
@Getter
|
||||
private final List<WidgetItem> itemWidgets = new ArrayList<>();
|
||||
|
||||
private final Map<OverlayLayer, List<Overlay>> overlayLayers = new EnumMap<>(OverlayLayer.class);
|
||||
|
||||
@@ -168,6 +171,12 @@ public class OverlayManager
|
||||
// Add is always true
|
||||
overlays.add(overlay);
|
||||
loadOverlay(overlay);
|
||||
// WidgetItemOverlays have a reference to the overlay manager in order to get the WidgetItems
|
||||
// for each frame.
|
||||
if (overlay instanceof WidgetItemOverlay)
|
||||
{
|
||||
((WidgetItemOverlay) overlay).setOverlayManager(this);
|
||||
}
|
||||
rebuildOverlayLayers();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
||||
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -22,53 +22,57 @@
|
||||
* (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.queries;
|
||||
package net.runelite.client.ui.overlay;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Query;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.List;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
|
||||
public abstract class WidgetItemQuery extends Query<WidgetItem, WidgetItemQuery>
|
||||
public abstract class WidgetItemOverlay extends Overlay
|
||||
{
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
public WidgetItemQuery idEquals(int... ids)
|
||||
protected WidgetItemOverlay()
|
||||
{
|
||||
predicate = and(item ->
|
||||
{
|
||||
for (int id : ids)
|
||||
{
|
||||
if (item.getId() == id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return this;
|
||||
super.setPosition(OverlayPosition.DYNAMIC);
|
||||
super.setPriority(OverlayPriority.LOW);
|
||||
super.setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
}
|
||||
|
||||
public WidgetItemQuery indexEquals(int... indexes)
|
||||
public abstract void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget);
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
predicate = and(item ->
|
||||
final List<WidgetItem> itemWidgets = overlayManager.getItemWidgets();
|
||||
for (WidgetItem widget : itemWidgets)
|
||||
{
|
||||
for (int index : indexes)
|
||||
{
|
||||
if (item.getIndex() == index)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return this;
|
||||
renderItemOverlay(graphics, widget.getId(), widget);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public WidgetItemQuery quantityEquals(int quantity)
|
||||
// Don't allow setting position, priority, or layer
|
||||
|
||||
@Override
|
||||
public void setPosition(OverlayPosition position)
|
||||
{
|
||||
predicate = and(item -> item.getQuantity() == quantity);
|
||||
return this;
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract WidgetItem[] result(Client client);
|
||||
public void setPriority(OverlayPriority priority)
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayer(OverlayLayer layer)
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Tomas Slusny <slusnucky@gmail.com>
|
||||
* 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.util;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Query;
|
||||
|
||||
@Singleton
|
||||
public class QueryRunner
|
||||
{
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] runQuery(Query query)
|
||||
{
|
||||
return (T[]) query.result(client);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -108,6 +109,8 @@ import net.runelite.api.mixins.Shadow;
|
||||
import net.runelite.api.vars.AccountType;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.api.widgets.WidgetType;
|
||||
import net.runelite.rs.api.RSChatLineBuffer;
|
||||
import net.runelite.rs.api.RSClanMemberManager;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
@@ -1324,8 +1327,11 @@ public abstract class RSClientMixin implements RSClient
|
||||
|
||||
@MethodHook("renderWidgetLayer")
|
||||
@Inject
|
||||
public static void renderWidgetLayer(Widget[] widgets, int parentId, int var2, int var3, int var4, int var5, int x, int y, int var8)
|
||||
public static void renderWidgetLayer(Widget[] widgets, int parentId, int minX, int minY, int maxX, int maxY, int x, int y, int var8)
|
||||
{
|
||||
Callbacks callbacks = client.getCallbacks();
|
||||
HashTable<WidgetNode> componentTable = client.getComponentTable();
|
||||
|
||||
for (Widget rlWidget : widgets)
|
||||
{
|
||||
RSWidget widget = (RSWidget) rlWidget;
|
||||
@@ -1338,10 +1344,30 @@ public abstract class RSClientMixin implements RSClient
|
||||
{
|
||||
widget.setRenderParentId(parentId);
|
||||
}
|
||||
widget.setRenderX(x + widget.getRelativeX());
|
||||
widget.setRenderY(y + widget.getRelativeY());
|
||||
|
||||
HashTable<WidgetNode> componentTable = client.getComponentTable();
|
||||
final int renderX = x + widget.getRelativeX();
|
||||
final int renderY = y + widget.getRelativeY();
|
||||
widget.setRenderX(renderX);
|
||||
widget.setRenderY(renderY);
|
||||
|
||||
final int widgetType = widget.getType();
|
||||
if (widgetType == WidgetType.GRAPHIC && widget.getItemId() != -1)
|
||||
{
|
||||
if (renderX >= minX && renderX <= maxX && renderY >= minY && renderY <= maxY)
|
||||
{
|
||||
WidgetItem widgetItem = new WidgetItem(widget.getItemId(), widget.getItemQuantity(), -1, widget.getBounds());
|
||||
callbacks.drawItem(widget.getItemId(), widgetItem);
|
||||
}
|
||||
}
|
||||
else if (widgetType == WidgetType.INVENTORY)
|
||||
{
|
||||
Collection<WidgetItem> widgetItems = widget.getWidgetItems();
|
||||
for (WidgetItem widgetItem : widgetItems)
|
||||
{
|
||||
callbacks.drawItem(widgetItem.getId(), widgetItem);
|
||||
}
|
||||
}
|
||||
|
||||
WidgetNode childNode = componentTable.get(widget.getId());
|
||||
if (childNode != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user