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