client: change Counter infobox to store count as an integer
This commit is contained in:
@@ -26,15 +26,15 @@ package net.runelite.client.plugins.cannon;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import net.runelite.client.ui.overlay.infobox.Counter;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBox;
|
||||
|
||||
public class CannonCounter extends Counter
|
||||
public class CannonCounter extends InfoBox
|
||||
{
|
||||
private final CannonPlugin plugin;
|
||||
|
||||
public CannonCounter(BufferedImage img, CannonPlugin plugin)
|
||||
{
|
||||
super(img, plugin, String.valueOf(plugin.getCballsLeft()));
|
||||
super(img, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class KingdomCounter extends Counter
|
||||
|
||||
public KingdomCounter(BufferedImage image, KingdomPlugin plugin)
|
||||
{
|
||||
super(image, plugin, String.valueOf(plugin.getFavor()));
|
||||
super(image, plugin, plugin.getFavor());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,22 +31,15 @@ import net.runelite.client.ui.overlay.infobox.Counter;
|
||||
|
||||
public class GraveyardCounter extends Counter
|
||||
{
|
||||
private int count;
|
||||
|
||||
public GraveyardCounter(BufferedImage image, Plugin plugin)
|
||||
{
|
||||
super(image, plugin, "0");
|
||||
}
|
||||
|
||||
public void setCount(int count)
|
||||
{
|
||||
this.count = count;
|
||||
this.setText(String.valueOf(count));
|
||||
super(image, plugin, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getTextColor()
|
||||
{
|
||||
int count = getCount();
|
||||
if (count >= GraveyardRoom.MIN_SCORE)
|
||||
{
|
||||
return Color.GREEN;
|
||||
|
||||
@@ -33,8 +33,6 @@ import net.runelite.client.ui.overlay.infobox.Counter;
|
||||
|
||||
public class AbsorptionCounter extends Counter
|
||||
{
|
||||
private int absorption;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int threshold;
|
||||
@@ -49,20 +47,19 @@ public class AbsorptionCounter extends Counter
|
||||
|
||||
public AbsorptionCounter(BufferedImage image, Plugin plugin, int absorption, int threshold)
|
||||
{
|
||||
super(image, plugin, "");
|
||||
super(image, plugin, absorption);
|
||||
this.threshold = threshold;
|
||||
setAbsorption(absorption);
|
||||
}
|
||||
|
||||
public void setAbsorption(int absorption)
|
||||
{
|
||||
this.absorption = absorption;
|
||||
setText(String.valueOf(absorption));
|
||||
setCount(absorption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getTextColor()
|
||||
{
|
||||
int absorption = getCount();
|
||||
if (absorption >= threshold)
|
||||
{
|
||||
return aboveThresholdColor;
|
||||
@@ -76,6 +73,7 @@ public class AbsorptionCounter extends Counter
|
||||
@Override
|
||||
public String getTooltip()
|
||||
{
|
||||
int absorption = getCount();
|
||||
return "Absorption: " + absorption;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,25 +24,32 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.prayer;
|
||||
|
||||
import java.awt.Color;
|
||||
import lombok.Getter;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.overlay.infobox.Counter;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBox;
|
||||
|
||||
class PrayerCounter extends Counter
|
||||
class PrayerCounter extends InfoBox
|
||||
{
|
||||
@Getter
|
||||
private final PrayerType prayerType;
|
||||
|
||||
PrayerCounter(Plugin plugin, PrayerType prayerType)
|
||||
{
|
||||
super(null, plugin, "");
|
||||
super(null, plugin);
|
||||
this.prayerType = prayerType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
public String getText()
|
||||
{
|
||||
return "Counter{" + "prayer=" + prayerType.getName() + '}';
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getTextColor()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -580,7 +580,7 @@ public class SlayerPlugin extends Plugin
|
||||
|
||||
// add and update counter, set timer
|
||||
addCounter();
|
||||
counter.setText(String.valueOf(amount));
|
||||
counter.setCount(amount);
|
||||
infoTimer = Instant.now();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,6 @@ public class TaskCounter extends Counter
|
||||
{
|
||||
public TaskCounter(BufferedImage img, Plugin plugin, int amount)
|
||||
{
|
||||
super(img, plugin, String.valueOf(amount));
|
||||
super(img, plugin, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,30 +29,24 @@ import net.runelite.client.ui.overlay.infobox.Counter;
|
||||
|
||||
class SpecialCounter extends Counter
|
||||
{
|
||||
private int hitValue;
|
||||
private SpecialWeapon weapon;
|
||||
|
||||
SpecialCounter(BufferedImage image, SpecialCounterPlugin plugin, int hitValue, SpecialWeapon weapon)
|
||||
{
|
||||
super(image, plugin, null);
|
||||
super(image, plugin, hitValue);
|
||||
this.weapon = weapon;
|
||||
this.hitValue = hitValue;
|
||||
}
|
||||
|
||||
void addHits(double hit)
|
||||
{
|
||||
this.hitValue += hit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText()
|
||||
{
|
||||
return Integer.toString(hitValue);
|
||||
int count = getCount();
|
||||
setCount(count + (int) hit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip()
|
||||
{
|
||||
int hitValue = getCount();
|
||||
if (!weapon.isDamage())
|
||||
{
|
||||
if (hitValue == 1)
|
||||
|
||||
@@ -26,33 +26,28 @@ package net.runelite.client.ui.overlay.infobox;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
|
||||
@ToString
|
||||
public class Counter extends InfoBox
|
||||
{
|
||||
private String text;
|
||||
@Getter
|
||||
@Setter
|
||||
private int count;
|
||||
|
||||
public Counter(BufferedImage image, Plugin plugin, String text)
|
||||
public Counter(BufferedImage image, Plugin plugin, int count)
|
||||
{
|
||||
super(image, plugin);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Counter{" + "text=" + text + '}';
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
this.text = text;
|
||||
return Integer.toString(count);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
package net.runelite.client.ui.overlay.infobox;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
@@ -94,10 +95,19 @@ public class InfoBoxOverlay extends Overlay
|
||||
continue;
|
||||
}
|
||||
|
||||
final String text = box.getText();
|
||||
final Color color = box.getTextColor();
|
||||
|
||||
final InfoBoxComponent infoBoxComponent = new InfoBoxComponent();
|
||||
infoBoxComponent.setColor(box.getTextColor());
|
||||
if (!Strings.isNullOrEmpty(text))
|
||||
{
|
||||
infoBoxComponent.setText(text);
|
||||
}
|
||||
if (color != null)
|
||||
{
|
||||
infoBoxComponent.setColor(color);
|
||||
}
|
||||
infoBoxComponent.setImage(box.getScaledImage());
|
||||
infoBoxComponent.setText(box.getText());
|
||||
infoBoxComponent.setTooltip(box.getTooltip());
|
||||
panelComponent.getChildren().add(infoBoxComponent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user