Refactor PrayerAlert
This commit is contained in:
@@ -33,6 +33,7 @@ public interface PrayerAlertConfig extends Config
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "oldRenderMode",
|
||||
|
||||
@@ -16,10 +16,16 @@
|
||||
|
||||
package net.runelite.client.plugins.prayeralert;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.plugins.itemstats.stats.Stat;
|
||||
import net.runelite.client.plugins.itemstats.stats.Stats;
|
||||
@@ -56,32 +62,42 @@ class PrayerAlertOverlay extends Overlay
|
||||
panelComponent.getChildren().clear();
|
||||
int prayerLevel = getPrayerLevel();
|
||||
int prayerPoints = getPrayerPoints();
|
||||
if (config.oldRenderMode()){
|
||||
if (config.alwaysShowAlert()){
|
||||
if (config.oldRenderMode())
|
||||
{
|
||||
if (config.alwaysShowAlert())
|
||||
{
|
||||
boolean drink = drinkPrayerPotion(prayerLevel, prayerPoints);
|
||||
if (drink) {
|
||||
if (drink)
|
||||
{
|
||||
oldPrayerRestorePanel(graphics);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
boolean drink = drinkPrayerPotion(prayerLevel, prayerPoints);
|
||||
boolean hasPrayerPotion = checkInventoryForPotion();
|
||||
if (drink && hasPrayerPotion) {
|
||||
if (drink && hasPrayerPotion)
|
||||
{
|
||||
oldPrayerRestorePanel(graphics);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (config.alwaysShowAlert()){
|
||||
else
|
||||
{
|
||||
if (config.alwaysShowAlert())
|
||||
{
|
||||
boolean drink = drinkPrayerPotion(prayerLevel, prayerPoints);
|
||||
if (drink) {
|
||||
if (drink)
|
||||
{
|
||||
prayerRestorePanel(panelComponent, graphics);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
boolean drink = drinkPrayerPotion(prayerLevel, prayerPoints);
|
||||
boolean hasPrayerPotion = checkInventoryForPotion();
|
||||
if (drink && hasPrayerPotion) {
|
||||
if (drink && hasPrayerPotion)
|
||||
{
|
||||
prayerRestorePanel(panelComponent, graphics);
|
||||
}
|
||||
}
|
||||
@@ -143,7 +159,8 @@ class PrayerAlertOverlay extends Overlay
|
||||
return hasPrayerPotion;
|
||||
}
|
||||
|
||||
private void prayerRestorePanel(PanelComponent panelComponent, Graphics2D graphics){
|
||||
private void prayerRestorePanel(PanelComponent panelComponent, Graphics2D graphics)
|
||||
{
|
||||
panelComponent.getChildren().add(new ImageComponent(itemManager.getImage(ItemID.PRAYER_POTION4)));
|
||||
panelComponent.getChildren().add(TitleComponent.builder()
|
||||
.text("Drink")
|
||||
@@ -153,7 +170,8 @@ class PrayerAlertOverlay extends Overlay
|
||||
graphics.getFontMetrics().stringWidth("Drink") + 12, 0));
|
||||
}
|
||||
|
||||
private void oldPrayerRestorePanel(Graphics2D graphics){
|
||||
private void oldPrayerRestorePanel(Graphics2D graphics)
|
||||
{
|
||||
graphics.translate(-100, 15);
|
||||
graphics.setColor(new Color(0.2f, 0.2f, 0.2f, 0.5f));
|
||||
graphics.fillRect(0, 0, 100, 45);
|
||||
|
||||
@@ -18,9 +18,9 @@ package net.runelite.client.plugins.prayeralert;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
|
||||
@@ -39,9 +39,6 @@ public class PrayerAlertPlugin extends Plugin
|
||||
@Inject
|
||||
private PrayerAlertOverlay overlay;
|
||||
|
||||
@Inject
|
||||
private PrayerAlertConfig config;
|
||||
|
||||
@Provides
|
||||
PrayerAlertConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user