Moved the watering can overlay from tithe farming plugin to item charge plugin.

This commit is contained in:
Mitchell Kovacs
2018-06-10 09:48:22 -04:00
committed by Adam
parent 525a0d8577
commit 00624a8e13
8 changed files with 31 additions and 180 deletions

View File

@@ -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()
{

View File

@@ -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;

View File

@@ -28,5 +28,6 @@ enum ItemChargeType
{
IMPBOX,
TELEPORT,
WATERCAN,
WATERSKIN
}

View File

@@ -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),

View File

@@ -1,86 +0,0 @@
/*
* Copyright (c) 2018, Unmoon <https://github.com/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;
}
}

View File

@@ -55,9 +55,6 @@ public class TitheFarmPlugin extends Plugin
@Inject
private TitheFarmSackOverlay titheFarmSackOverlay;
@Inject
private TitheFarmInventoryOverlay titheFarmInventoryOverlay;
@Getter
private final Set<TitheFarmPlant> plants = new HashSet<>();
@@ -70,7 +67,7 @@ public class TitheFarmPlugin extends Plugin
@Override
public Collection<Overlay> getOverlays()
{
return Arrays.asList(titheFarmOverlay, titheFarmSackOverlay, titheFarmInventoryOverlay);
return Arrays.asList(titheFarmOverlay, titheFarmSackOverlay);
}
@Override

View File

@@ -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"

View File

@@ -1,73 +0,0 @@
/*
* Copyright (c) 2018, Unmoon <https://github.com/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<Integer, WateringCan> 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);
}
}