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;
|
package net.runelite.client.plugins.prayer;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.ui.overlay.infobox.Counter;
|
import net.runelite.client.ui.overlay.infobox.Counter;
|
||||||
|
|
||||||
@@ -35,9 +33,6 @@ public class PrayerCounter extends Counter
|
|||||||
@Getter
|
@Getter
|
||||||
private final PrayerType prayerType;
|
private final PrayerType prayerType;
|
||||||
|
|
||||||
@Setter
|
|
||||||
private BufferedImage image;
|
|
||||||
|
|
||||||
PrayerCounter(Plugin plugin, PrayerType prayerType)
|
PrayerCounter(Plugin plugin, PrayerType prayerType)
|
||||||
{
|
{
|
||||||
super(null, plugin, "");
|
super(null, plugin, "");
|
||||||
@@ -55,10 +50,4 @@ public class PrayerCounter extends Counter
|
|||||||
{
|
{
|
||||||
return prayerType.getDescription();
|
return prayerType.getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BufferedImage getImage()
|
|
||||||
{
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,18 +28,16 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Image;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.util.Objects;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
public class InfoBoxComponent implements LayoutableRenderableEntity
|
public class InfoBoxComponent implements LayoutableRenderableEntity
|
||||||
{
|
{
|
||||||
private static final int BOX_SIZE = 35;
|
private static final int SEPARATOR = 3;
|
||||||
private static final int SEPARATOR = 2;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private String tooltip;
|
private String tooltip;
|
||||||
@@ -50,42 +48,55 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
|
|||||||
private String text;
|
private String text;
|
||||||
private Color color = Color.WHITE;
|
private Color color = Color.WHITE;
|
||||||
private Color backgroundColor = ComponentConstants.STANDARD_BACKGROUND_COLOR;
|
private Color backgroundColor = ComponentConstants.STANDARD_BACKGROUND_COLOR;
|
||||||
private BufferedImage image;
|
private Image image;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public Dimension render(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
|
if (image == null)
|
||||||
|
{
|
||||||
|
return new Dimension();
|
||||||
|
}
|
||||||
|
|
||||||
graphics.translate(preferredLocation.x, preferredLocation.y);
|
graphics.translate(preferredLocation.x, preferredLocation.y);
|
||||||
|
|
||||||
|
// Calculate dimensions
|
||||||
final FontMetrics metrics = graphics.getFontMetrics();
|
final FontMetrics metrics = graphics.getFontMetrics();
|
||||||
final int w = BOX_SIZE;
|
final int w = image.getWidth(null) + SEPARATOR * 2;
|
||||||
final int h = BOX_SIZE;
|
final int h = image.getHeight(null) + SEPARATOR * 2;
|
||||||
final Rectangle bounds = new Rectangle(w, h);
|
final int size = Math.max(w, h);
|
||||||
|
final Rectangle bounds = new Rectangle(size, size);
|
||||||
|
|
||||||
|
// Render background
|
||||||
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
||||||
backgroundComponent.setBackgroundColor(backgroundColor);
|
backgroundComponent.setBackgroundColor(backgroundColor);
|
||||||
backgroundComponent.setRectangle(bounds);
|
backgroundComponent.setRectangle(bounds);
|
||||||
backgroundComponent.render(graphics);
|
backgroundComponent.render(graphics);
|
||||||
|
|
||||||
if (Objects.nonNull(image))
|
// Render image
|
||||||
{
|
graphics.drawImage(
|
||||||
graphics.drawImage(
|
image,
|
||||||
image,
|
(size - image.getWidth(null)) / 2,
|
||||||
(w - image.getWidth()) / 2,
|
(size - image.getHeight(null)) / 2,
|
||||||
(h - image.getHeight()) / 2,
|
null);
|
||||||
null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Render caption
|
||||||
final TextComponent textComponent = new TextComponent();
|
final TextComponent textComponent = new TextComponent();
|
||||||
textComponent.setColor(color);
|
textComponent.setColor(color);
|
||||||
textComponent.setText(text);
|
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);
|
textComponent.render(graphics);
|
||||||
|
|
||||||
graphics.translate(-preferredLocation.x, -preferredLocation.y);
|
graphics.translate(-preferredLocation.x, -preferredLocation.y);
|
||||||
return bounds.getSize();
|
return bounds.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dimension getPreferredSize()
|
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
|
@Override
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
package net.runelite.client.ui.overlay.infobox;
|
package net.runelite.client.ui.overlay.infobox;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Image;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -32,33 +33,48 @@ import net.runelite.client.plugins.Plugin;
|
|||||||
|
|
||||||
public abstract class InfoBox
|
public abstract class InfoBox
|
||||||
{
|
{
|
||||||
private final BufferedImage image;
|
private static final int SIZE = 24;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Image image;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private InfoBoxPriority priority;
|
private InfoBoxPriority priority;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
private String tooltip;
|
private String tooltip;
|
||||||
|
|
||||||
public InfoBox(BufferedImage image, Plugin plugin)
|
public InfoBox(Image image, Plugin plugin)
|
||||||
{
|
{
|
||||||
this.image = image;
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
setImage(image);
|
||||||
setPriority(InfoBoxPriority.NONE);
|
setPriority(InfoBoxPriority.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getImage()
|
|
||||||
{
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String getText();
|
public abstract String getText();
|
||||||
|
|
||||||
public abstract Color getTextColor();
|
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()
|
public boolean render()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -68,14 +84,4 @@ public abstract class InfoBox
|
|||||||
{
|
{
|
||||||
return false;
|
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 javax.inject.Provider;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
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.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
@@ -67,7 +68,7 @@ public class InfoBoxOverlay extends Overlay
|
|||||||
|
|
||||||
panelComponent.setBackgroundColor(null);
|
panelComponent.setBackgroundColor(null);
|
||||||
panelComponent.setBorder(new Rectangle());
|
panelComponent.setBorder(new Rectangle());
|
||||||
panelComponent.setGap(new Point(2, 2));
|
panelComponent.setGap(new Point(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -80,6 +81,7 @@ public class InfoBoxOverlay extends Overlay
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||||
panelComponent.getChildren().clear();
|
panelComponent.getChildren().clear();
|
||||||
panelComponent.setWrapping(config.infoBoxWrap());
|
panelComponent.setWrapping(config.infoBoxWrap());
|
||||||
panelComponent.setOrientation(config.infoBoxVertical()
|
panelComponent.setOrientation(config.infoBoxVertical()
|
||||||
|
|||||||
Reference in New Issue
Block a user