Change the default size of infoboxes to be smaller
- To follow Konduit style a bit more, change the default size of infoboxes to be somewhat around 24x24 instead of 36x36. - Change the margin between infoboxes to 1px Depends on #2874 Closes #1771 and closes #1016 Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.prayer;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.overlay.infobox.Counter;
|
||||
|
||||
@@ -35,9 +33,6 @@ public class PrayerCounter extends Counter
|
||||
@Getter
|
||||
private final PrayerType prayerType;
|
||||
|
||||
@Setter
|
||||
private BufferedImage image;
|
||||
|
||||
PrayerCounter(Plugin plugin, PrayerType prayerType)
|
||||
{
|
||||
super(null, plugin, "");
|
||||
@@ -55,10 +50,4 @@ public class PrayerCounter extends Counter
|
||||
{
|
||||
return prayerType.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,18 +28,16 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
public class InfoBoxComponent implements LayoutableRenderableEntity
|
||||
{
|
||||
private static final int BOX_SIZE = 35;
|
||||
private static final int SEPARATOR = 2;
|
||||
private static final int SEPARATOR = 3;
|
||||
|
||||
@Getter
|
||||
private String tooltip;
|
||||
@@ -50,42 +48,55 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
|
||||
private String text;
|
||||
private Color color = Color.WHITE;
|
||||
private Color backgroundColor = ComponentConstants.STANDARD_BACKGROUND_COLOR;
|
||||
private BufferedImage image;
|
||||
private Image image;
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
return new Dimension();
|
||||
}
|
||||
|
||||
graphics.translate(preferredLocation.x, preferredLocation.y);
|
||||
|
||||
// Calculate dimensions
|
||||
final FontMetrics metrics = graphics.getFontMetrics();
|
||||
final int w = BOX_SIZE;
|
||||
final int h = BOX_SIZE;
|
||||
final Rectangle bounds = new Rectangle(w, h);
|
||||
final int w = image.getWidth(null) + SEPARATOR * 2;
|
||||
final int h = image.getHeight(null) + SEPARATOR * 2;
|
||||
final int size = Math.max(w, h);
|
||||
final Rectangle bounds = new Rectangle(size, size);
|
||||
|
||||
// Render background
|
||||
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
||||
backgroundComponent.setBackgroundColor(backgroundColor);
|
||||
backgroundComponent.setRectangle(bounds);
|
||||
backgroundComponent.render(graphics);
|
||||
|
||||
if (Objects.nonNull(image))
|
||||
{
|
||||
graphics.drawImage(
|
||||
image,
|
||||
(w - image.getWidth()) / 2,
|
||||
(h - image.getHeight()) / 2,
|
||||
null);
|
||||
}
|
||||
// Render image
|
||||
graphics.drawImage(
|
||||
image,
|
||||
(size - image.getWidth(null)) / 2,
|
||||
(size - image.getHeight(null)) / 2,
|
||||
null);
|
||||
|
||||
// Render caption
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
textComponent.setColor(color);
|
||||
textComponent.setText(text);
|
||||
textComponent.setPosition(new Point(((w - metrics.stringWidth(text)) / 2), h - SEPARATOR));
|
||||
textComponent.setPosition(new Point(((size - metrics.stringWidth(text)) / 2), size - SEPARATOR));
|
||||
textComponent.render(graphics);
|
||||
|
||||
graphics.translate(-preferredLocation.x, -preferredLocation.y);
|
||||
return bounds.getSize();
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
return new Dimension(BOX_SIZE, BOX_SIZE);
|
||||
final int w = image.getWidth(null) + SEPARATOR * 2;
|
||||
final int h = image.getHeight(null) + SEPARATOR * 2;
|
||||
final int size = Math.max(w, h);
|
||||
return new Dimension(size, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package net.runelite.client.ui.overlay.infobox;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -32,33 +33,48 @@ import net.runelite.client.plugins.Plugin;
|
||||
|
||||
public abstract class InfoBox
|
||||
{
|
||||
private final BufferedImage image;
|
||||
private static final int SIZE = 24;
|
||||
|
||||
@Getter
|
||||
private final Plugin plugin;
|
||||
|
||||
@Getter
|
||||
private Image image;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private InfoBoxPriority priority;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String tooltip;
|
||||
|
||||
public InfoBox(BufferedImage image, Plugin plugin)
|
||||
public InfoBox(Image image, Plugin plugin)
|
||||
{
|
||||
this.image = image;
|
||||
this.plugin = plugin;
|
||||
setImage(image);
|
||||
setPriority(InfoBoxPriority.NONE);
|
||||
}
|
||||
|
||||
public BufferedImage getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
public abstract String getText();
|
||||
|
||||
public abstract Color getTextColor();
|
||||
|
||||
public void setImage(final Image image)
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double width = image.getWidth(null);
|
||||
double height = image.getHeight(null);
|
||||
double scalex = (double) SIZE / width;
|
||||
double scaley = (double) SIZE / height;
|
||||
double scale = Math.min(scalex, scaley);
|
||||
this.image = image.getScaledInstance((int) (width * scale), (int) (height * scale), BufferedImage.TYPE_INT_ARGB);
|
||||
}
|
||||
|
||||
public boolean render()
|
||||
{
|
||||
return true;
|
||||
@@ -68,14 +84,4 @@ public abstract class InfoBox
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getTooltip()
|
||||
{
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
public void setTooltip(String tooltip)
|
||||
{
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
@@ -67,7 +68,7 @@ public class InfoBoxOverlay extends Overlay
|
||||
|
||||
panelComponent.setBackgroundColor(null);
|
||||
panelComponent.setBorder(new Rectangle());
|
||||
panelComponent.setGap(new Point(2, 2));
|
||||
panelComponent.setGap(new Point(1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,6 +81,7 @@ public class InfoBoxOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
panelComponent.getChildren().clear();
|
||||
panelComponent.setWrapping(config.infoBoxWrap());
|
||||
panelComponent.setOrientation(config.infoBoxVertical()
|
||||
|
||||
Reference in New Issue
Block a user