itemcharges: Add explorer's ring alchemy charge overlay. (#8867)

This commit is contained in:
aleios
2019-05-22 04:30:41 +10:00
committed by Tomas Slusny
parent e4d9845928
commit b89d535fcb
6 changed files with 103 additions and 4 deletions

View File

@@ -487,7 +487,15 @@ public enum Varbits
/**
* The active tab within the quest interface
*/
QUEST_TAB(8168);
QUEST_TAB(8168),
/**
* Explorer ring
*/
EXPLORER_RING_ALCHTYPE(5398),
EXPLORER_RING_TELEPORTS(4552),
EXPLORER_RING_ALCHS(4554),
EXPLORER_RING_RUNENERGY(4553);
/**
* The raw varbit ID.

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* Copyright (c) 2019, Aleios <https://github.com/aleios>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -244,11 +245,40 @@ public interface ItemChargeConfig extends Config
return true;
}
@ConfigItem(
keyName = "showExplorerRingCharges",
name = "Show Explorer's Ring Alch Charges",
description = "Configures if explorer's ring alchemy charges are shown",
position = 17
)
default boolean showExplorerRingCharges()
{
return true;
}
@ConfigItem(
keyName = "explorerRing",
name = "",
description = "",
hidden = true
)
default int explorerRing()
{
return -1;
}
@ConfigItem(
keyName = "explorerRing",
name = "",
description = ""
)
void explorerRing(int explorerRing);
@ConfigItem(
keyName = "showInfoboxes",
name = "Show Infoboxes",
description = "Configures whether to show an infobox equipped charge items",
position = 17
position = 18
)
default boolean showInfoboxes()
{

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2019, Aleios <https://github.com/aleios>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -84,6 +85,15 @@ class ItemChargeOverlay extends WidgetItemOverlay
charges = config.bindingNecklace();
}
else if (itemId >= ItemID.EXPLORERS_RING_1 && itemId <= ItemID.EXPLORERS_RING_4)
{
if (!config.showExplorerRingCharges())
{
return;
}
charges = config.explorerRing();
}
else
{
ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId);
@@ -119,6 +129,6 @@ class ItemChargeOverlay extends WidgetItemOverlay
{
return config.showTeleportCharges() || config.showDodgyCount() || config.showFungicideCharges()
|| config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges()
|| config.showBellowCharges() || config.showAbyssalBraceletCharges();
|| config.showBellowCharges() || config.showAbyssalBraceletCharges() || config.showExplorerRingCharges();
}
}

View File

@@ -1,6 +1,7 @@
/*
* Copyright (c) 2017, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Hydrox6 <ikada@protonmail.ch>
* Copyright (c) 2019, Aleios <https://github.com/aleios>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,10 +39,12 @@ import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemContainer;
import net.runelite.api.ItemID;
import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.Notifier;
@@ -75,6 +78,9 @@ public class ItemChargePlugin extends Plugin
private static final int MAX_DODGY_CHARGES = 10;
private static final int MAX_BINDING_CHARGES = 16;
private static final int MAX_EXPLORER_RING_CHARGES = 30;
private int lastExplorerRingCharge = -1;
@Inject
private Client client;
@@ -153,6 +159,11 @@ public class ItemChargePlugin extends Plugin
{
removeInfobox(ItemWithSlot.BINDING_NECKLACE);
}
if (!config.showExplorerRingCharges())
{
removeInfobox(ItemWithSlot.EXPLORER_RING);
}
}
@Subscribe
@@ -246,6 +257,11 @@ public class ItemChargePlugin extends Plugin
{
updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items);
}
if (config.showExplorerRingCharges())
{
updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, items);
}
}
@Subscribe
@@ -263,6 +279,16 @@ public class ItemChargePlugin extends Plugin
}
}
@Subscribe
private void onVarbitChanged(VarbitChanged event)
{
int explorerRingCharge = client.getVar(Varbits.EXPLORER_RING_ALCHS);
if (lastExplorerRingCharge != explorerRingCharge)
{
updateExplorerRingCharges(explorerRingCharge);
}
}
private void updateDodgyNecklaceCharges(final int value)
{
config.dodgyNecklace(value);
@@ -297,6 +323,24 @@ public class ItemChargePlugin extends Plugin
}
}
private void updateExplorerRingCharges(final int value)
{
// Note: Varbit counts upwards. We count down from the maximum charges.
config.explorerRing(MAX_EXPLORER_RING_CHARGES - value);
if (config.showInfoboxes() && config.showExplorerRingCharges())
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
if (itemContainer == null)
{
return;
}
updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, itemContainer.getItems());
}
}
private void checkDestroyWidget()
{
final int currentTick = client.getTickCount();
@@ -359,6 +403,10 @@ public class ItemChargePlugin extends Plugin
{
charges = config.bindingNecklace();
}
else if ((id >= ItemID.EXPLORERS_RING_1 && id <= ItemID.EXPLORERS_RING_4) && type == ItemWithSlot.EXPLORER_RING)
{
charges = config.explorerRing();
}
}
else if (itemWithCharge.getType() == type.getType())
{

View File

@@ -34,5 +34,6 @@ enum ItemChargeType
WATERCAN,
WATERSKIN,
DODGY_NECKLACE,
BINDING_NECKLACE
BINDING_NECKLACE,
EXPLORER_RING
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2019, Tomas Slusny <slusnucky@gmail.com>
* Copyright (c) 2019, Aleios <https://github.com/aleios>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +36,7 @@ enum ItemWithSlot
ABYSSAL_BRACELET(ItemChargeType.ABYSSAL_BRACELET, EquipmentInventorySlot.GLOVES),
DODGY_NECKLACE(ItemChargeType.DODGY_NECKLACE, EquipmentInventorySlot.AMULET),
BINDING_NECKLACE(ItemChargeType.BINDING_NECKLACE, EquipmentInventorySlot.AMULET),
EXPLORER_RING(ItemChargeType.EXPLORER_RING, EquipmentInventorySlot.RING),
TELEPORT(ItemChargeType.TELEPORT, EquipmentInventorySlot.WEAPON, EquipmentInventorySlot.AMULET, EquipmentInventorySlot.GLOVES, EquipmentInventorySlot.RING);
private final ItemChargeType type;