From 00624a8e133daa0f0f460bfcff127fd02cab6063 Mon Sep 17 00:00:00 2001 From: Mitchell Kovacs Date: Sun, 10 Jun 2018 09:48:22 -0400 Subject: [PATCH] Moved the watering can overlay from tithe farming plugin to item charge plugin. --- .../plugins/itemcharges/ItemChargeConfig.java | 15 +++- .../itemcharges/ItemChargeOverlay.java | 4 +- .../plugins/itemcharges/ItemChargeType.java | 1 + .../plugins/itemcharges/ItemWithCharge.java | 10 +++ .../tithefarm/TitheFarmInventoryOverlay.java | 86 ------------------- .../plugins/tithefarm/TitheFarmPlugin.java | 5 +- .../tithefarm/TitheFarmPluginConfig.java | 17 +--- .../client/plugins/tithefarm/WateringCan.java | 73 ---------------- 8 files changed, 31 insertions(+), 180 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmInventoryOverlay.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/WateringCan.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java index 2de4a7f912..738375df7f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java @@ -102,11 +102,22 @@ public interface ItemChargeConfig extends Config return true; } + @ConfigItem( + keyName = "showWateringCanCharges", + name = "Show Watering Can Charges", + description = "Configures if watering can item charge is shown", + position = 7 + ) + default boolean showWateringCanCharges() + { + return true; + } + @ConfigItem( keyName = "showWaterskinCharges", name = "Show Waterskin Charges", description = "Configures if waterskin item charge is shown", - position = 7 + position = 8 ) default boolean showWaterskinCharges() { @@ -117,7 +128,7 @@ public interface ItemChargeConfig extends Config keyName = "recoilNotification", name = "Ring of Recoil Notification", description = "Configures if the ring of recoil breaking notification is shown", - position = 8 + position = 9 ) default boolean recoilNotification() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java index 95e904d591..3246a0ae22 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java @@ -40,6 +40,7 @@ import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetItem; 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; @@ -65,7 +66,7 @@ class ItemChargeOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.showTeleportCharges() && !config.showImpCharges() && !config.showWaterskinCharges()) + if (!config.showTeleportCharges() && !config.showImpCharges() && !config.showWateringCanCharges() && !config.showWaterskinCharges()) { return null; } @@ -83,6 +84,7 @@ class ItemChargeOverlay extends Overlay ItemChargeType type = chargeItem.getType(); if ((type == TELEPORT && !config.showTeleportCharges()) || (type == IMPBOX && !config.showImpCharges()) + || (type == WATERCAN && !config.showWateringCanCharges()) || (type == WATERSKIN && !config.showWaterskinCharges())) { continue; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java index 6cc0eec441..4d18e5c903 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java @@ -28,5 +28,6 @@ enum ItemChargeType { IMPBOX, TELEPORT, + WATERCAN, WATERSKIN } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java index a4991d24e4..eee8e7d2d2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java @@ -32,6 +32,7 @@ import lombok.Getter; import static net.runelite.api.ItemID.*; 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; @AllArgsConstructor @@ -131,6 +132,15 @@ enum ItemWithCharge TCRYSTAL3(TELEPORT, TELEPORT_CRYSTAL_3, 3), TCRYSTAL4(TELEPORT, TELEPORT_CRYSTAL_4, 4), TCRYSTAL5(TELEPORT, TELEPORT_CRYSTAL_5, 5), + WCAN0(WATERCAN, WATERING_CAN, 0), + WCAN1(WATERCAN, WATERING_CAN1, 1), + WCAN2(WATERCAN, WATERING_CAN2, 2), + WCAN3(WATERCAN, WATERING_CAN3, 3), + WCAN4(WATERCAN, WATERING_CAN4, 4), + WCAN5(WATERCAN, WATERING_CAN5, 5), + WCAN6(WATERCAN, WATERING_CAN6, 6), + WCAN7(WATERCAN, WATERING_CAN7, 7), + WCAN8(WATERCAN, WATERING_CAN8, 8), WSKIN0(WATERSKIN, WATERSKIN0, 0), WSKIN1(WATERSKIN, WATERSKIN1, 1), WSKIN2(WATERSKIN, WATERSKIN2, 2), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmInventoryOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmInventoryOverlay.java deleted file mode 100644 index 2b3178d9d1..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmInventoryOverlay.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2018, Unmoon - * 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.tithefarm; - -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -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.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.components.TextComponent; -import net.runelite.client.util.QueryRunner; - -class TitheFarmInventoryOverlay extends Overlay -{ - private final QueryRunner queryRunner; - private final TitheFarmPluginConfig config; - - private final TextComponent textComponent = new TextComponent(); - - @Inject - TitheFarmInventoryOverlay(QueryRunner queryRunner, TitheFarmPluginConfig config) - { - setPosition(OverlayPosition.DYNAMIC); - setLayer(OverlayLayer.ABOVE_WIDGETS); - this.queryRunner = queryRunner; - this.config = config; - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (!config.showWateringCanOverlay()) - { - return null; - } - graphics.setFont(FontManager.getRunescapeSmallFont()); - - Query inventoryQuery = new InventoryWidgetItemQuery(); - WidgetItem[] inventoryItems = queryRunner.runQuery(inventoryQuery); - - for (WidgetItem item : inventoryItems) - { - WateringCan wateringCan = WateringCan.getWateringCan(item.getId()); - if (wateringCan == null) - { - continue; - } - - final Rectangle bounds = item.getCanvasBounds(); - textComponent.setPosition(new Point(bounds.x, bounds.y + 16)); - textComponent.setColor(wateringCan.getColor()); - textComponent.setText(String.valueOf(wateringCan.getCharges())); - textComponent.render(graphics); - } - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlugin.java index ef793c04fa..9dfa4cc990 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlugin.java @@ -55,9 +55,6 @@ public class TitheFarmPlugin extends Plugin @Inject private TitheFarmSackOverlay titheFarmSackOverlay; - @Inject - private TitheFarmInventoryOverlay titheFarmInventoryOverlay; - @Getter private final Set plants = new HashSet<>(); @@ -70,7 +67,7 @@ public class TitheFarmPlugin extends Plugin @Override public Collection getOverlays() { - return Arrays.asList(titheFarmOverlay, titheFarmSackOverlay, titheFarmInventoryOverlay); + return Arrays.asList(titheFarmOverlay, titheFarmSackOverlay); } @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPluginConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPluginConfig.java index 84ce84af0c..de41ca4f36 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPluginConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPluginConfig.java @@ -38,17 +38,6 @@ public interface TitheFarmPluginConfig extends Config { @ConfigItem( position = 0, - keyName = "showWateringCanOverlay", - name = "Show watering can doses", - description = "Configures whether or not the watering can doses are displayed" - ) - default boolean showWateringCanOverlay() - { - return true; - } - - @ConfigItem( - position = 1, keyName = "showSack", name = "Show fruit sack", description = "Configures whether or not the fruit sack is displayed" @@ -59,7 +48,7 @@ public interface TitheFarmPluginConfig extends Config } @ConfigItem( - position = 2, + position = 1, keyName = "hexColorUnwatered", name = "Unwatered plant", description = "Color of unwatered plant timer" @@ -70,7 +59,7 @@ public interface TitheFarmPluginConfig extends Config } @ConfigItem( - position = 3, + position = 2, keyName = "hexColorWatered", name = "Watered plant", description = "Color of watered plant timer" @@ -81,7 +70,7 @@ public interface TitheFarmPluginConfig extends Config } @ConfigItem( - position = 4, + position = 3, keyName = "hexColorGrown", name = "Grown plant", description = "Color of grown plant timer" diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/WateringCan.java b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/WateringCan.java deleted file mode 100644 index aa18b546e9..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/WateringCan.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2018, Unmoon - * 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.tithefarm; - -import java.awt.Color; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; -import net.runelite.api.ItemID; - -enum WateringCan -{ - WATERING_CAN0(ItemID.WATERING_CAN, 0, Color.RED), - WATERING_CAN1(ItemID.WATERING_CAN1, 1, Color.ORANGE), - WATERING_CAN2(ItemID.WATERING_CAN2, 2, Color.YELLOW), - WATERING_CAN3(ItemID.WATERING_CAN3, 3, Color.WHITE), - WATERING_CAN4(ItemID.WATERING_CAN4, 4, Color.WHITE), - WATERING_CAN5(ItemID.WATERING_CAN5, 5, Color.WHITE), - WATERING_CAN6(ItemID.WATERING_CAN6, 6, Color.WHITE), - WATERING_CAN7(ItemID.WATERING_CAN7, 7, Color.WHITE), - WATERING_CAN8(ItemID.WATERING_CAN8, 8, Color.WHITE); - - @Getter - private final int id; - @Getter - private final int charges; - @Getter - private final Color color; - - private static final Map wateringCans = new HashMap<>(); - - static - { - for (WateringCan can : values()) - { - wateringCans.put(can.getId(), can); - } - } - - WateringCan(int id, int charges, Color color) - { - this.id = id; - this.charges = charges; - this.color = color; - } - - public static WateringCan getWateringCan(int itemId) - { - return wateringCans.get(itemId); - } -}