Merge pull request #294 from runelite-extended/betteritemchargeplugin

Added recoil and explorers ring to itemcharges / updated statusbars
This commit is contained in:
Tyler Bochard
2019-05-20 04:40:20 -04:00
committed by GitHub
5 changed files with 142 additions and 1 deletions

View File

@@ -523,6 +523,14 @@ public enum Varbits
*/
QUEST_TAB(8168),
/**
* Explorer ring
*/
EXPLORER_RING_ALCHTYPE(5398),
EXPLORER_RING_TELEPORTS(4552),
EXPLORER_RING_ALCHS(4554),
EXPLORER_RING_RUNENERGY(4553),
/**
* Temple Trekking
*/

View File

@@ -388,4 +388,15 @@ public interface ItemChargeConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "showrecoil",
name = "Show If Recoil is activated",
description = "Configures if Recoil is activated",
position = 22
)
default boolean showrecoil()
{
return false;
}
}

View File

@@ -57,6 +57,8 @@ import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.util.Text;
import static net.runelite.api.ItemID.RING_OF_RECOIL;
@PluginDescriptor(
name = "Item Charges",
description = "Show number of item charges remaining",
@@ -118,6 +120,27 @@ public class ItemChargePlugin extends Plugin
private static final int MAX_EXPEDITIOUS_CHARGES = 30;
private static final int MAX_BINDING_CHARGES = 16;
public boolean isRingOfRecoilAvailable()
{
return ringOfRecoilAvailable;
}
private boolean ringOfRecoilAvailable = false;
boolean isRingOfRecoilEquipped()
{
return ringOfRecoilEquipped;
}
private boolean ringOfRecoilEquipped = false;
private BufferedImage recoilRingImage;
BufferedImage getRecoilRingImage()
{
return recoilRingImage;
}
@Inject
private Client client;
@@ -127,6 +150,9 @@ public class ItemChargePlugin extends Plugin
@Inject
private ItemChargeOverlay overlay;
@Inject
private ItemRecoilOverlay recoilOverlay;
@Inject
private ItemManager itemManager;
@@ -152,12 +178,15 @@ public class ItemChargePlugin extends Plugin
protected void startUp()
{
overlayManager.add(overlay);
overlayManager.add(recoilOverlay);
recoilRingImage = itemManager.getImage(RING_OF_RECOIL);
}
@Override
protected void shutDown() throws Exception
{
overlayManager.remove(overlay);
overlayManager.remove(recoilOverlay);
infoBoxManager.removeIf(ItemChargeInfobox.class::isInstance);
lastCheckTick = -1;
}
@@ -382,6 +411,27 @@ public class ItemChargePlugin extends Plugin
}
}
ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT);
ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY);
ringOfRecoilAvailable = false;
ringOfRecoilEquipped = false;
Item ring = equipment.getItems()[net.runelite.api.EquipmentInventorySlot.RING.getSlotIdx()];
if (ring.getId() == RING_OF_RECOIL)
{
ringOfRecoilEquipped = true;
ringOfRecoilAvailable = true;
}
Item[] items = inventory.getItems();
for (Item item : items)
{
if (item.getId() == RING_OF_RECOIL)
{
ringOfRecoilAvailable = true;
break;
}
}
Widget dialog1 = client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT);
Widget dialog2 = client.getWidget(WidgetInfo.DIALOG2_SPRITE_TEXT);

View File

@@ -0,0 +1,72 @@
/*
* Copyright (c) 2018, https://runelitepl.us
* Copyright (c) 2018, https://github.com/runeliteplusplus
* 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.itemcharges;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
class ItemRecoilOverlay extends Overlay
{
private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150);
private static final Color ACTIVATED_BACKGROUND_COLOR = new Color(0, 150, 0, 150);
private final ItemChargePlugin plugin;
private final ItemChargeConfig config;
private final PanelComponent imagePanelComponent = new PanelComponent();
@Inject
public ItemRecoilOverlay(Client client, ItemChargePlugin plugin, ItemChargeConfig config)
{
setPosition(OverlayPosition.TOP_LEFT);
this.plugin = plugin;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics)
{
this.imagePanelComponent.getChildren().clear();
if (config.showrecoil())
{
if (plugin.isRingOfRecoilAvailable())
{
BufferedImage recoilImage = plugin.getRecoilRingImage();
imagePanelComponent.setBackgroundColor(plugin
.isRingOfRecoilEquipped() ? ACTIVATED_BACKGROUND_COLOR : NOT_ACTIVATED_BACKGROUND_COLOR);
imagePanelComponent.getChildren().add(new ImageComponent(recoilImage));
return imagePanelComponent.render(graphics);
}
}
return null;
}
}

View File

@@ -72,7 +72,7 @@ public interface StatusBarsConfig extends Config
)
default boolean toggleRestorationBars()
{
return true;
return false;
}
@ConfigItem(