@@ -29,6 +29,7 @@ import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.io.File;
|
||||
@@ -66,6 +67,7 @@ import net.runelite.client.RuneLite;
|
||||
import static net.runelite.client.RuneLite.PROFILES_DIR;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -508,6 +510,10 @@ public class ConfigManager
|
||||
{
|
||||
return Enum.valueOf((Class<? extends Enum>) type, str);
|
||||
}
|
||||
if (type == Font.class)
|
||||
{
|
||||
return FontManager.getFontOrDefault(FontManager.lookupFont(str));
|
||||
}
|
||||
if (type == Instant.class)
|
||||
{
|
||||
return Instant.parse(str);
|
||||
@@ -564,6 +570,10 @@ public class ConfigManager
|
||||
{
|
||||
return ((Enum) object).name();
|
||||
}
|
||||
if (object instanceof Font)
|
||||
{
|
||||
return FontManager.getFontName((Font)object);
|
||||
}
|
||||
if (object instanceof Dimension)
|
||||
{
|
||||
Dimension d = (Dimension) object;
|
||||
|
||||
@@ -24,21 +24,18 @@
|
||||
*/
|
||||
package net.runelite.client.config;
|
||||
|
||||
import java.awt.Font;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum FontType
|
||||
{
|
||||
REGULAR("Regular", FontManager.getRunescapeFont()),
|
||||
BOLD("Bold", FontManager.getRunescapeBoldFont()),
|
||||
SMALL("Small", FontManager.getRunescapeSmallFont());
|
||||
REGULAR("Regular"),
|
||||
BOLD("Bold"),
|
||||
SMALL("Small");
|
||||
|
||||
private final String name;
|
||||
private final Font font;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
package net.runelite.client.config;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import net.runelite.api.Constants;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
|
||||
@ConfigGroup("runelite")
|
||||
public interface RuneLiteConfig extends Config
|
||||
@@ -207,6 +209,17 @@ public interface RuneLiteConfig extends Config
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "clientFont",
|
||||
name = "Font",
|
||||
description = "Configure what font is used for the client and runelite added overlays",
|
||||
position = 29
|
||||
)
|
||||
default Font clientFont()
|
||||
{
|
||||
return FontManager.getRunescapeFont();
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "fontType",
|
||||
name = "Dynamic Overlay Font",
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
@@ -99,6 +100,7 @@ import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.DynamicGridLayout;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
import net.runelite.client.ui.components.ComboBoxListRenderer;
|
||||
import net.runelite.client.ui.components.IconButton;
|
||||
@@ -999,6 +1001,36 @@ public class ConfigPanel extends PluginPanel
|
||||
item.add(button, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
if (cid.getType() == Font.class)
|
||||
{
|
||||
JComboBox box = new JComboBox(FontManager.getAvailableFontNames());
|
||||
box.setPreferredSize(new Dimension(150, 25));
|
||||
box.setRenderer(new ComboBoxListRenderer());
|
||||
box.setForeground(Color.WHITE);
|
||||
box.setFocusable(false);
|
||||
String currentlyConfigured = configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName());
|
||||
if (FontManager.lookupFont(currentlyConfigured) != null)
|
||||
{
|
||||
box.setSelectedItem(currentlyConfigured);
|
||||
box.setToolTipText(currentlyConfigured);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.debug("Selected font wasn't found on this system, resetting font back to runescape regular");
|
||||
configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), FontManager.getRunescapeFont());
|
||||
}
|
||||
box.addItemListener(e ->
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED && box.getSelectedItem() != null)
|
||||
{
|
||||
final Font selected = FontManager.lookupFont(box.getSelectedItem().toString());
|
||||
configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), selected);
|
||||
box.setToolTipText(box.getSelectedItem().toString());
|
||||
}
|
||||
});
|
||||
item.add(box, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
mainPanel.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ package net.runelite.client.plugins.devtools;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
@@ -63,7 +62,6 @@ import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
@@ -77,7 +75,6 @@ class DevToolsOverlay extends Overlay
|
||||
private static final int ITEM_EMPTY = 6512;
|
||||
private static final int ITEM_FILLED = 20594;
|
||||
|
||||
private static final Font FONT = FontManager.getRunescapeFont().deriveFont(Font.BOLD, 16);
|
||||
private static final Color RED = new Color(221, 44, 0);
|
||||
private static final Color GREEN = new Color(0, 200, 83);
|
||||
private static final Color TURQOISE = new Color(0, 200, 157);
|
||||
@@ -115,7 +112,6 @@ class DevToolsOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
graphics.setFont(FONT);
|
||||
|
||||
if (plugin.getPlayers().isActive())
|
||||
{
|
||||
@@ -398,7 +394,7 @@ class DevToolsOverlay extends Overlay
|
||||
Rectangle2D textBounds = fm.getStringBounds(idText, graphics);
|
||||
|
||||
int textX = (int) (slotBounds.getX() + (slotBounds.getWidth() / 2) - (textBounds.getWidth() / 2));
|
||||
int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (textBounds.getHeight() / 2));
|
||||
int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (fm.getHeight() / 2) - fm.getMaxDescent());
|
||||
|
||||
graphics.setColor(new Color(255, 255, 255, 65));
|
||||
graphics.fill(slotBounds);
|
||||
@@ -540,7 +536,7 @@ class DevToolsOverlay extends Overlay
|
||||
Rectangle2D textBounds = fm.getStringBounds(text, graphics);
|
||||
|
||||
int textX = (int) (bounds.getX() + (bounds.getWidth() / 2) - (textBounds.getWidth() / 2));
|
||||
int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (textBounds.getHeight() / 2));
|
||||
int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (fm.getHeight() / 2) - fm.getMaxDescent());
|
||||
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.drawString(text, textX + 1, textY + 1);
|
||||
|
||||
@@ -193,7 +193,7 @@ class VarInspector extends JFrame
|
||||
{
|
||||
lastTick = tick;
|
||||
JLabel header = new JLabel("Tick " + tick);
|
||||
header.setFont(FontManager.getRunescapeSmallFont());
|
||||
header.setFont(FontManager.getSmallFont(getFont()));
|
||||
header.setBorder(new CompoundBorder(
|
||||
BorderFactory.createMatteBorder(0, 0, 1, 0, ColorScheme.LIGHT_GRAY_COLOR),
|
||||
BorderFactory.createEmptyBorder(3, 6, 0, 0)
|
||||
|
||||
@@ -221,14 +221,14 @@ class FeedPanel extends PluginPanel
|
||||
Color darkerForeground = UIManager.getColor("Label.foreground").darker();
|
||||
|
||||
JLabel titleLabel = new JLabel(item.getTitle());
|
||||
titleLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
titleLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
titleLabel.setBackground(null);
|
||||
titleLabel.setForeground(darkerForeground);
|
||||
titleLabel.setPreferredSize(new Dimension(CONTENT_WIDTH - TIME_WIDTH, 0));
|
||||
|
||||
Duration duration = Duration.between(Instant.ofEpochMilli(item.getTimestamp()), Instant.now());
|
||||
JLabel timeLabel = new JLabel(durationToString(duration));
|
||||
timeLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
timeLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
timeLabel.setForeground(darkerForeground);
|
||||
|
||||
titleAndTime.add(titleLabel, BorderLayout.WEST);
|
||||
@@ -237,9 +237,9 @@ class FeedPanel extends PluginPanel
|
||||
JPanel content = new JPanel(new BorderLayout());
|
||||
content.setBackground(null);
|
||||
|
||||
JLabel contentLabel = new JLabel(lineBreakText(item.getContent(), FontManager.getRunescapeSmallFont()));
|
||||
JLabel contentLabel = new JLabel(lineBreakText(item.getContent(), FontManager.getSmallFont(getFont())));
|
||||
contentLabel.setBorder(new EmptyBorder(2, 0, 0, 0));
|
||||
contentLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
contentLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
contentLabel.setForeground(darkerForeground);
|
||||
|
||||
content.add(contentLabel, BorderLayout.CENTER);
|
||||
|
||||
@@ -131,11 +131,11 @@ public class GrandExchangeOfferSlot extends JPanel
|
||||
|
||||
itemName.setForeground(Color.WHITE);
|
||||
itemName.setVerticalAlignment(JLabel.BOTTOM);
|
||||
itemName.setFont(FontManager.getRunescapeSmallFont());
|
||||
itemName.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
offerInfo.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||
offerInfo.setVerticalAlignment(JLabel.TOP);
|
||||
offerInfo.setFont(FontManager.getRunescapeSmallFont());
|
||||
offerInfo.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
JLabel switchFaceViewIcon = new JLabel();
|
||||
switchFaceViewIcon.setIcon(RIGHT_ARROW_ICON);
|
||||
@@ -162,11 +162,11 @@ public class GrandExchangeOfferSlot extends JPanel
|
||||
|
||||
itemPrice.setForeground(Color.WHITE);
|
||||
itemPrice.setVerticalAlignment(JLabel.BOTTOM);
|
||||
itemPrice.setFont(FontManager.getRunescapeSmallFont());
|
||||
itemPrice.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
offerSpent.setForeground(Color.WHITE);
|
||||
offerSpent.setVerticalAlignment(JLabel.TOP);
|
||||
offerSpent.setFont(FontManager.getRunescapeSmallFont());
|
||||
offerSpent.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
JLabel switchDetailsViewIcon = new JLabel();
|
||||
switchDetailsViewIcon.setIcon(LEFT_ARROW_ICON);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
package net.runelite.client.plugins.grounditems;
|
||||
|
||||
import java.awt.Color;
|
||||
import net.runelite.client.config.Alpha;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
@@ -57,6 +58,7 @@ public interface GroundItemsConfig extends Config
|
||||
position = 2,
|
||||
parent = "colorsStub"
|
||||
)
|
||||
@Alpha
|
||||
default Color defaultColor()
|
||||
{
|
||||
return Color.WHITE;
|
||||
@@ -69,6 +71,7 @@ public interface GroundItemsConfig extends Config
|
||||
position = 3,
|
||||
parent = "colorsStub"
|
||||
)
|
||||
@Alpha
|
||||
default Color highlightedColor()
|
||||
{
|
||||
return Color.decode("#AA00FF");
|
||||
@@ -81,6 +84,7 @@ public interface GroundItemsConfig extends Config
|
||||
position = 4,
|
||||
parent = "colorsStub"
|
||||
)
|
||||
@Alpha
|
||||
default Color hiddenColor()
|
||||
{
|
||||
return Color.GRAY;
|
||||
@@ -319,6 +323,7 @@ public interface GroundItemsConfig extends Config
|
||||
position = 23,
|
||||
parent = "lowValueStub"
|
||||
)
|
||||
@Alpha
|
||||
default Color lowValueColor()
|
||||
{
|
||||
return Color.decode("#66B2FF");
|
||||
@@ -366,6 +371,7 @@ public interface GroundItemsConfig extends Config
|
||||
position = 27,
|
||||
parent = "mediumValueStub"
|
||||
)
|
||||
@Alpha
|
||||
default Color mediumValueColor()
|
||||
{
|
||||
return Color.decode("#99FF99");
|
||||
@@ -413,6 +419,7 @@ public interface GroundItemsConfig extends Config
|
||||
position = 31,
|
||||
parent = "highValueStub"
|
||||
)
|
||||
@Alpha
|
||||
default Color highValueColor()
|
||||
{
|
||||
return Color.decode("#FF9600");
|
||||
@@ -460,6 +467,7 @@ public interface GroundItemsConfig extends Config
|
||||
position = 35,
|
||||
parent = "insaneValueStub"
|
||||
)
|
||||
@Alpha
|
||||
default Color insaneValueColor()
|
||||
{
|
||||
return Color.decode("#FF66B2");
|
||||
@@ -618,4 +626,16 @@ public interface GroundItemsConfig extends Config
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Alpha
|
||||
@ConfigItem(
|
||||
keyName = "bordercolor",
|
||||
name = "Border color",
|
||||
description = "Change the border color",
|
||||
position = 49
|
||||
)
|
||||
default Color bordercolor()
|
||||
{
|
||||
return new Color(0, 0, 0, 150);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,6 @@ public class GroundItemsOverlay extends Overlay
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final FontMetrics fm = graphics.getFontMetrics();
|
||||
final Player player = client.getLocalPlayer();
|
||||
|
||||
if (player == null || client.getViewportWidget() == null)
|
||||
@@ -118,6 +116,8 @@ public class GroundItemsOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
final FontMetrics fm = graphics.getFontMetrics();
|
||||
|
||||
offsetMap.clear();
|
||||
final LocalPoint localLocation = player.getLocalLocation();
|
||||
final Point mousePos = client.getMouseCanvasPosition();
|
||||
@@ -319,14 +319,14 @@ public class GroundItemsOverlay extends Overlay
|
||||
|
||||
// Item bounds
|
||||
int x = textX - 2;
|
||||
int y = textY - stringHeight - 2;
|
||||
int y = textY - stringHeight - 2 + fm.getMaxDescent();
|
||||
int width = stringWidth + 4;
|
||||
int height = stringHeight + 4;
|
||||
final Rectangle itemBounds = new Rectangle(x, y, width, height);
|
||||
|
||||
// Hidden box
|
||||
x += width + 2;
|
||||
y = textY - (RECTANGLE_SIZE + stringHeight) / 2;
|
||||
y = textY - (fm.getMaxAscent() + RECTANGLE_SIZE) / 2;
|
||||
width = height = RECTANGLE_SIZE;
|
||||
final Rectangle itemHiddenBox = new Rectangle(x, y, width, height);
|
||||
|
||||
@@ -376,7 +376,8 @@ public class GroundItemsOverlay extends Overlay
|
||||
|
||||
if (config.toggleOutline())
|
||||
{
|
||||
graphics.setColor(Color.BLACK);
|
||||
final Color bordercolor = config.bordercolor();
|
||||
graphics.setColor(bordercolor);
|
||||
graphics.drawString(itemString, textX + 1, textY + 1);
|
||||
graphics.drawString(itemString, textX - 1, textY - 1);
|
||||
graphics.drawString(itemString, textX - 1, textY + 1);
|
||||
@@ -388,7 +389,6 @@ public class GroundItemsOverlay extends Overlay
|
||||
textComponent.setPosition(new java.awt.Point(textX, textY));
|
||||
textComponent.render(graphics);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ public class GroundItemsPlugin extends Plugin
|
||||
private static final int EXAMINE_ITEM = MenuAction.EXAMINE_ITEM_GROUND.getId();
|
||||
private static final int WALK = MenuAction.WALK.getId();
|
||||
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private Map.Entry<Rectangle, GroundItem> textBoxBounds;
|
||||
|
||||
@@ -295,7 +295,7 @@ public class HiscorePanel extends PluginPanel
|
||||
private JPanel makeSkillPanel(HiscoreSkill skill)
|
||||
{
|
||||
JLabel label = new JLabel();
|
||||
label.setFont(FontManager.getRunescapeSmallFont());
|
||||
label.setFont(FontManager.getSmallFont(getFont()));
|
||||
label.setText("--");
|
||||
|
||||
String skillName = (skill == null ? "combat" : skill.getName().toLowerCase());
|
||||
|
||||
@@ -115,7 +115,7 @@ public class InfoPanel extends PluginPanel
|
||||
versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
versionPanel.setLayout(new GridLayout(0, 1));
|
||||
|
||||
final Font smallFont = FontManager.getRunescapeSmallFont();
|
||||
final Font smallFont = FontManager.getSmallFont(getFont());
|
||||
|
||||
JLabel version = new JLabel(htmlLabel("RuneLite version: ", runeLiteProperties.getVersion()));
|
||||
version.setFont(smallFont);
|
||||
@@ -191,7 +191,7 @@ public class InfoPanel extends PluginPanel
|
||||
/**
|
||||
* Builds a link panel with a given icon, text and url to redirect to.
|
||||
*/
|
||||
private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, String url)
|
||||
private JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, String url)
|
||||
{
|
||||
return buildLinkPanel(icon, topText, bottomText, () -> LinkBrowser.browse(url));
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public class InfoPanel extends PluginPanel
|
||||
/**
|
||||
* Builds a link panel with a given icon, text and callable to call.
|
||||
*/
|
||||
private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, Runnable callback)
|
||||
private JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, Runnable callback)
|
||||
{
|
||||
JPanel container = new JPanel();
|
||||
container.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
@@ -253,11 +253,11 @@ public class InfoPanel extends PluginPanel
|
||||
|
||||
JLabel topLine = new JLabel(topText);
|
||||
topLine.setForeground(Color.WHITE);
|
||||
topLine.setFont(FontManager.getRunescapeSmallFont());
|
||||
topLine.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
JLabel bottomLine = new JLabel(bottomText);
|
||||
bottomLine.setForeground(Color.WHITE);
|
||||
bottomLine.setFont(FontManager.getRunescapeSmallFont());
|
||||
bottomLine.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
textContainer.add(topLine);
|
||||
textContainer.add(bottomLine);
|
||||
|
||||
@@ -166,7 +166,7 @@ class ItemChargeOverlay extends WidgetItemOverlay
|
||||
|
||||
final Rectangle bounds = itemWidget.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
textComponent.setPosition(new Point(bounds.x - 1, bounds.y + 15));
|
||||
textComponent.setPosition(new Point(bounds.x, bounds.y + 1 + graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent()));
|
||||
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
|
||||
textComponent.setColor(itemChargePlugin.getColor(charges));
|
||||
textComponent.render(graphics);
|
||||
|
||||
@@ -47,7 +47,7 @@ class BookPanel extends JPanel
|
||||
JLabel image = new JLabel();
|
||||
b.getIcon().addTo(image);
|
||||
JLabel name = new JLabel(b.getShortName());
|
||||
location.setFont(FontManager.getRunescapeSmallFont());
|
||||
location.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
layout.setVerticalGroup(layout.createParallelGroup()
|
||||
.addComponent(image)
|
||||
|
||||
@@ -90,12 +90,12 @@ class LootTrackerBox extends JPanel
|
||||
logTitle.setBackground(ColorScheme.DARKER_GRAY_COLOR.darker());
|
||||
|
||||
final JLabel titleLabel = new JLabel(Text.removeTags(id));
|
||||
titleLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
titleLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
titleLabel.setForeground(Color.WHITE);
|
||||
|
||||
logTitle.add(titleLabel, BorderLayout.WEST);
|
||||
|
||||
subTitleLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
subTitleLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
subTitleLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||
logTitle.add(subTitleLabel, BorderLayout.CENTER);
|
||||
|
||||
@@ -104,7 +104,7 @@ class LootTrackerBox extends JPanel
|
||||
subTitleLabel.setText(subtitle);
|
||||
}
|
||||
|
||||
priceLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
priceLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
priceLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||
logTitle.add(priceLabel, BorderLayout.EAST);
|
||||
|
||||
|
||||
@@ -293,8 +293,8 @@ class LootTrackerPanel extends PluginPanel
|
||||
overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
overallInfo.setLayout(new GridLayout(2, 1));
|
||||
overallInfo.setBorder(new EmptyBorder(2, 10, 2, 0));
|
||||
overallKillsLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
overallGpLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
overallKillsLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
overallGpLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
overallInfo.add(overallKillsLabel);
|
||||
overallInfo.add(overallGpLabel);
|
||||
overallPanel.add(overallIcon, BorderLayout.WEST);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MTAInventoryOverlay extends Overlay
|
||||
{
|
||||
if (room.inside())
|
||||
{
|
||||
graphics.setFont(FontManager.getRunescapeBoldFont());
|
||||
graphics.setFont(FontManager.getSmallFont(graphics.getFont()));
|
||||
room.over(graphics);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MTASceneOverlay extends Overlay
|
||||
{
|
||||
if (room.inside())
|
||||
{
|
||||
graphics.setFont(FontManager.getRunescapeFont());
|
||||
graphics.setFont(FontManager.getSmallFont(graphics.getFont()));
|
||||
room.under(graphics);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,10 @@ public class RunepouchOverlay extends WidgetItemOverlay
|
||||
Point location = itemWidget.getCanvasLocation();
|
||||
StringBuilder tooltipBuilder = new StringBuilder();
|
||||
|
||||
// location.getY() + graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent()
|
||||
// this will draw the character exactly on the border
|
||||
int yLocation = location.getY() + 1 +
|
||||
graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent();
|
||||
for (int i = 0; i < AMOUNT_VARBITS.length; i++)
|
||||
{
|
||||
Varbits amountVarbit = AMOUNT_VARBITS[i];
|
||||
@@ -117,9 +121,18 @@ public class RunepouchOverlay extends WidgetItemOverlay
|
||||
continue;
|
||||
}
|
||||
|
||||
// the reason this is not split up in maxascent and maxdescent to equal the height of the text like it should
|
||||
// be is because numbers (afaik) dont use font descent so a 1 pixel seperator should be good and give
|
||||
// consistent results across fonts
|
||||
int yOffset = (1 + (graphics.getFontMetrics().getMaxAscent()) * i);
|
||||
|
||||
graphics.setColor(Color.black);
|
||||
graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 13 : 6),
|
||||
yLocation + yOffset);
|
||||
|
||||
graphics.setColor(config.fontColor());
|
||||
graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 12 : 5),
|
||||
location.getY() + 13 + (graphics.getFontMetrics().getHeight() - 1) * i);
|
||||
yLocation + yOffset);
|
||||
|
||||
graphics.setColor(config.fontColor());
|
||||
graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 11 : 4),
|
||||
@@ -134,7 +147,13 @@ public class RunepouchOverlay extends WidgetItemOverlay
|
||||
if (image != null)
|
||||
{
|
||||
OverlayUtil.renderImageLocation(graphics,
|
||||
new Point(location.getX() - 1, location.getY() + graphics.getFontMetrics().getHeight() * i - 1),
|
||||
//TODO :: SEE WHAT ONE IS RIGHT?
|
||||
//new Point(location.getX() - 1, location.getY() + graphics.getFontMetrics().getMaxAscent() * i - 1),
|
||||
//image);
|
||||
//or
|
||||
//new Point(location.getX(), location.getY() + (1 + graphics.getFontMetrics().getMaxAscent()) * i),
|
||||
//image);
|
||||
new Point(location.getX(), location.getY() + (1 + graphics.getFontMetrics().getMaxAscent()) * i),
|
||||
image);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ScreenMarkerCreationPanel extends JPanel
|
||||
setBorder(new EmptyBorder(8, 8, 8, 8));
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
instructionsLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
instructionsLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
instructionsLabel.setForeground(Color.WHITE);
|
||||
|
||||
JPanel actionsContainer = new JPanel(new GridLayout(1, 2, 8, 0));
|
||||
|
||||
@@ -164,7 +164,7 @@ class ScreenMarkerPanel extends JPanel
|
||||
nameActions.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
|
||||
save.setVisible(false);
|
||||
save.setFont(FontManager.getRunescapeSmallFont());
|
||||
save.setFont(FontManager.getSmallFont(getFont()));
|
||||
save.setForeground(ColorScheme.PROGRESS_COMPLETE_COLOR);
|
||||
save.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
@@ -188,7 +188,7 @@ class ScreenMarkerPanel extends JPanel
|
||||
});
|
||||
|
||||
cancel.setVisible(false);
|
||||
cancel.setFont(FontManager.getRunescapeSmallFont());
|
||||
cancel.setFont(FontManager.getSmallFont(getFont()));
|
||||
cancel.setForeground(ColorScheme.PROGRESS_ERROR_COLOR);
|
||||
cancel.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
@@ -211,7 +211,7 @@ class ScreenMarkerPanel extends JPanel
|
||||
}
|
||||
});
|
||||
|
||||
rename.setFont(FontManager.getRunescapeSmallFont());
|
||||
rename.setFont(FontManager.getSmallFont(getFont()));
|
||||
rename.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker());
|
||||
rename.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
|
||||
@@ -252,7 +252,7 @@ class SkillCalculator extends JPanel
|
||||
JCheckBox uiCheckbox = new JCheckBox();
|
||||
|
||||
uiLabel.setForeground(Color.WHITE);
|
||||
uiLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
uiLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
uiOption.setBorder(BorderFactory.createEmptyBorder(3, 7, 3, 0));
|
||||
uiOption.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
|
||||
@@ -125,7 +125,7 @@ class UIActionSlot extends JPanel
|
||||
uiLabelName.setForeground(Color.WHITE);
|
||||
|
||||
uiLabelActions = new JShadowedLabel("Unknown");
|
||||
uiLabelActions.setFont(FontManager.getRunescapeSmallFont());
|
||||
uiLabelActions.setFont(FontManager.getSmallFont(getFont()));
|
||||
uiLabelActions.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||
|
||||
uiInfo.add(uiLabelName);
|
||||
|
||||
@@ -123,7 +123,7 @@ class UICalculatorInputArea extends JPanel
|
||||
uiInput.setHoverBackgroundColor(ColorScheme.DARK_GRAY_HOVER_COLOR);
|
||||
uiInput.setBorder(new EmptyBorder(5, 7, 5, 7));
|
||||
|
||||
uiLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
uiLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
uiLabel.setBorder(new EmptyBorder(0, 0, 4, 0));
|
||||
uiLabel.setForeground(Color.WHITE);
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class UICombinedActionSlot extends JPanel
|
||||
uiLabelTitle.setForeground(Color.WHITE);
|
||||
|
||||
uiLabelActions = new JShadowedLabel("Shift-click to select multiple");
|
||||
uiLabelActions.setFont(FontManager.getRunescapeSmallFont());
|
||||
uiLabelActions.setFont(FontManager.getSmallFont(getFont()));
|
||||
uiLabelActions.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||
|
||||
uiInfo.add(uiLabelTitle);
|
||||
|
||||
@@ -117,7 +117,7 @@ class SlayerOverlay extends WidgetItemOverlay
|
||||
return;
|
||||
}
|
||||
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
graphics.setFont(FontManager.getSmallFont(graphics.getFont()));
|
||||
|
||||
final Rectangle bounds = itemWidget.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
|
||||
@@ -106,11 +106,11 @@ class OverviewItemPanel extends JPanel
|
||||
|
||||
JLabel titleLabel = new JLabel(title);
|
||||
titleLabel.setForeground(Color.WHITE);
|
||||
titleLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
titleLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
statusLabel = new JLabel();
|
||||
statusLabel.setForeground(Color.GRAY);
|
||||
statusLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
statusLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
textContainer.add(titleLabel);
|
||||
textContainer.add(statusLabel);
|
||||
|
||||
@@ -67,10 +67,10 @@ public class TimeablePanel<T> extends JPanel
|
||||
infoPanel.setBorder(new EmptyBorder(4, 4, 4, 0));
|
||||
|
||||
final JLabel location = new JShadowedLabel(title);
|
||||
location.setFont(FontManager.getRunescapeSmallFont());
|
||||
location.setFont(FontManager.getSmallFont(getFont()));
|
||||
location.setForeground(Color.WHITE);
|
||||
|
||||
estimate.setFont(FontManager.getRunescapeSmallFont());
|
||||
estimate.setFont(FontManager.getSmallFont(getFont()));
|
||||
estimate.setForeground(Color.GRAY);
|
||||
|
||||
infoPanel.add(location);
|
||||
|
||||
@@ -40,6 +40,7 @@ import net.runelite.client.plugins.timetracking.TimeTrackingPlugin;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.DynamicGridLayout;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
import net.runelite.client.ui.components.IconButton;
|
||||
import net.runelite.client.ui.components.shadowlabel.JShadowedLabel;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
@@ -97,6 +98,13 @@ public class ClockTabPanel extends TabContentPanel
|
||||
rebuild();
|
||||
}
|
||||
|
||||
// The max panel width is 225 but the + sign gets cut off at 225 so we set it at 223
|
||||
@Override
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
return new Dimension(PluginPanel.PANEL_WIDTH - 2, super.getPreferredSize().height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears and recreates the components of this panel.
|
||||
* This should be done whenever a clock is added or removed.
|
||||
@@ -147,7 +155,7 @@ public class ClockTabPanel extends TabContentPanel
|
||||
|
||||
JLabel headerLabel = new JLabel(title);
|
||||
headerLabel.setForeground(Color.WHITE);
|
||||
headerLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
headerLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
panel.add(headerLabel, BorderLayout.CENTER);
|
||||
|
||||
IconButton addButton = new IconButton(ADD_ICON, ADD_ICON_HOVER);
|
||||
@@ -167,7 +175,7 @@ public class ClockTabPanel extends TabContentPanel
|
||||
|
||||
JLabel infoLabel = new JShadowedLabel(text);
|
||||
infoLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker());
|
||||
infoLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
infoLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
panel.add(infoLabel);
|
||||
|
||||
return panel;
|
||||
|
||||
@@ -129,7 +129,7 @@ class StopwatchPanel extends ClockPanel
|
||||
private JLabel createSmallLabel(String text)
|
||||
{
|
||||
JLabel label = new JLabel(text, SwingConstants.CENTER);
|
||||
label.setFont(FontManager.getRunescapeSmallFont());
|
||||
label.setFont(FontManager.getSmallFont(getFont()));
|
||||
label.setForeground(LAP_DATA_COLOR);
|
||||
|
||||
return label;
|
||||
|
||||
@@ -94,7 +94,7 @@ public class FarmingTabPanel extends TabContentPanel
|
||||
groupLabel.setBorder(new EmptyBorder(15, 0, 0, 0));
|
||||
}
|
||||
|
||||
groupLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
groupLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
add(groupLabel, c);
|
||||
c.gridy++;
|
||||
|
||||
@@ -102,7 +102,7 @@ class WorldTableHeader extends JPanel
|
||||
});
|
||||
|
||||
textLabel.setText(title);
|
||||
textLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
textLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
final JMenuItem refresh = new JMenuItem("Refresh worlds");
|
||||
refresh.addActionListener(e ->
|
||||
|
||||
@@ -271,7 +271,7 @@ class WorldTableRow extends JPanel
|
||||
column.setBorder(new EmptyBorder(0, 5, 0, 5));
|
||||
|
||||
playerCountField = new JLabel(world.getPlayers() + "");
|
||||
playerCountField.setFont(FontManager.getRunescapeSmallFont());
|
||||
playerCountField.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
column.add(playerCountField, BorderLayout.WEST);
|
||||
|
||||
@@ -300,7 +300,7 @@ class WorldTableRow extends JPanel
|
||||
column.setBorder(new EmptyBorder(0, 5, 0, 5));
|
||||
|
||||
activityField = new JLabel(world.getActivity());
|
||||
activityField.setFont(FontManager.getRunescapeSmallFont());
|
||||
activityField.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
column.add(activityField, BorderLayout.WEST);
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ public class XpGlobesOverlay extends Overlay
|
||||
|
||||
final FontMetrics metrics = graphics.getFontMetrics();
|
||||
int drawX = x + (config.xpOrbSize() / 2) - (metrics.stringWidth(progress) / 2);
|
||||
int drawY = y + (config.xpOrbSize() / 2) + (metrics.getHeight() / 2);
|
||||
int drawY = y + (config.xpOrbSize() / 2) + (metrics.getHeight() / 2) - metrics.getMaxDescent();
|
||||
|
||||
OverlayUtil.renderTextLocation(graphics, new Point(drawX, drawY), progress, Color.WHITE);
|
||||
}
|
||||
|
||||
@@ -175,10 +175,10 @@ class XpInfoBox extends JPanel
|
||||
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
statsPanel.setBorder(new EmptyBorder(6, 5, 0, 2));
|
||||
|
||||
expGained.setFont(FontManager.getRunescapeSmallFont());
|
||||
expHour.setFont(FontManager.getRunescapeSmallFont());
|
||||
expLeft.setFont(FontManager.getRunescapeSmallFont());
|
||||
actionsLeft.setFont(FontManager.getRunescapeSmallFont());
|
||||
expGained.setFont(FontManager.getSmallFont(getFont()));
|
||||
expHour.setFont(FontManager.getSmallFont(getFont()));
|
||||
expLeft.setFont(FontManager.getSmallFont(getFont()));
|
||||
actionsLeft.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
statsPanel.add(expGained);
|
||||
statsPanel.add(expLeft);
|
||||
|
||||
@@ -113,8 +113,8 @@ class XpPanel extends PluginPanel
|
||||
overallInfo.setLayout(new GridLayout(2, 1));
|
||||
overallInfo.setBorder(new EmptyBorder(0, 10, 0, 0));
|
||||
|
||||
overallExpGained.setFont(FontManager.getRunescapeSmallFont());
|
||||
overallExpHour.setFont(FontManager.getRunescapeSmallFont());
|
||||
overallExpGained.setFont(FontManager.getSmallFont(getFont()));
|
||||
overallExpHour.setFont(FontManager.getSmallFont(getFont()));
|
||||
|
||||
overallInfo.add(overallExpGained);
|
||||
overallInfo.add(overallExpHour);
|
||||
|
||||
@@ -24,11 +24,18 @@
|
||||
*/
|
||||
package net.runelite.client.ui;
|
||||
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import java.awt.Canvas;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.io.IOException;
|
||||
import javax.swing.text.StyleContext;
|
||||
import lombok.Getter;
|
||||
import net.runelite.client.config.FontType;
|
||||
|
||||
public class FontManager
|
||||
{
|
||||
@@ -36,37 +43,59 @@ public class FontManager
|
||||
private static final Font runescapeSmallFont;
|
||||
private static final Font runescapeBoldFont;
|
||||
|
||||
@Getter
|
||||
private static class CachedFont
|
||||
{
|
||||
private final Font reg;
|
||||
private final Font small;
|
||||
private final Font bold;
|
||||
|
||||
private CachedFont(Font f)
|
||||
{
|
||||
reg = f.deriveFont(14.0f);
|
||||
small = getFontOffCorrectSize(f);
|
||||
bold = f.deriveFont(Font.BOLD, 14.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private static final ImmutableBiMap<String, Font> fontMap;
|
||||
private static final HashMap<Font, CachedFont> derivedFontMap = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
|
||||
try
|
||||
{
|
||||
Font font = Font.createFont(Font.TRUETYPE_FONT,
|
||||
runescapeFont = Font.createFont(Font.TRUETYPE_FONT,
|
||||
FontManager.class.getResourceAsStream("runescape.ttf"))
|
||||
.deriveFont(Font.PLAIN, 16);
|
||||
ge.registerFont(font);
|
||||
|
||||
runescapeFont = StyleContext.getDefaultStyleContext()
|
||||
.getFont(font.getName(), Font.PLAIN, 16);
|
||||
ge.registerFont(runescapeFont);
|
||||
|
||||
Font smallFont = Font.createFont(Font.TRUETYPE_FONT,
|
||||
runescapeSmallFont = Font.createFont(Font.TRUETYPE_FONT,
|
||||
FontManager.class.getResourceAsStream("runescape_small.ttf"))
|
||||
.deriveFont(Font.PLAIN, 16);
|
||||
ge.registerFont(smallFont);
|
||||
|
||||
runescapeSmallFont = StyleContext.getDefaultStyleContext()
|
||||
.getFont(smallFont.getName(), Font.PLAIN, 16);
|
||||
ge.registerFont(runescapeSmallFont);
|
||||
|
||||
Font boldFont = Font.createFont(Font.TRUETYPE_FONT,
|
||||
runescapeBoldFont = Font.createFont(Font.TRUETYPE_FONT,
|
||||
FontManager.class.getResourceAsStream("runescape_bold.ttf"))
|
||||
.deriveFont(Font.PLAIN, 16);
|
||||
ge.registerFont(boldFont);
|
||||
|
||||
runescapeBoldFont = StyleContext.getDefaultStyleContext()
|
||||
.getFont(boldFont.getName(), Font.PLAIN, 16);
|
||||
final LinkedHashMap<String, Font> _fontMap = new LinkedHashMap<>();
|
||||
_fontMap.put("Runescape", runescapeFont);
|
||||
|
||||
// Get all available fonts on the system
|
||||
Font[] availableFonts = ge.getAllFonts();
|
||||
// build bidirectional map
|
||||
Arrays.stream(availableFonts).sorted(Comparator.comparing(Font::getFontName)).forEach(f ->
|
||||
{
|
||||
if (!_fontMap.containsKey(f.getFontName()))
|
||||
{
|
||||
_fontMap.put(f.getFontName(), f);
|
||||
}
|
||||
});
|
||||
fontMap = ImmutableBiMap.copyOf(_fontMap);
|
||||
|
||||
ge.registerFont(runescapeFont);
|
||||
ge.registerFont(runescapeSmallFont);
|
||||
ge.registerFont(runescapeBoldFont);
|
||||
}
|
||||
catch (FontFormatException ex)
|
||||
@@ -79,6 +108,25 @@ public class FontManager
|
||||
}
|
||||
}
|
||||
|
||||
public static Font getFontOffCorrectSize(Font f)
|
||||
{
|
||||
// Size of the font is already set
|
||||
if (f.getSize2D() > 1)
|
||||
{
|
||||
return f;
|
||||
}
|
||||
|
||||
// Dummy canvas for font metrics
|
||||
Canvas c = new Canvas();
|
||||
|
||||
f = f.deriveFont(12f);
|
||||
if (c.getFontMetrics(f).getMaxAscent() > 11)
|
||||
{
|
||||
f = f.deriveFont(11f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
public static Font getRunescapeFont()
|
||||
{
|
||||
return runescapeFont;
|
||||
@@ -93,4 +141,93 @@ public class FontManager
|
||||
{
|
||||
return runescapeBoldFont;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isRunescapeFont(Font f)
|
||||
{
|
||||
return f.equals(runescapeFont) || f.equals(runescapeSmallFont) || f.equals(runescapeBoldFont);
|
||||
}
|
||||
|
||||
public static Font getSmallFont(Font f)
|
||||
{
|
||||
if (isRunescapeFont(f))
|
||||
{
|
||||
return runescapeSmallFont;
|
||||
}
|
||||
|
||||
if (derivedFontMap.containsKey(f))
|
||||
{
|
||||
return derivedFontMap.get(f).getSmall();
|
||||
}
|
||||
|
||||
// cache and return
|
||||
CachedFont cachedFont = new CachedFont(f);
|
||||
derivedFontMap.put(f, cachedFont);
|
||||
return cachedFont.getSmall();
|
||||
}
|
||||
|
||||
public static Font getFontFromType(Font f, FontType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SMALL:
|
||||
return getSmallFont(f);
|
||||
case BOLD:
|
||||
if (isRunescapeFont(f))
|
||||
{
|
||||
return runescapeBoldFont;
|
||||
}
|
||||
if (derivedFontMap.containsKey(f))
|
||||
{
|
||||
return derivedFontMap.get(f).getBold();
|
||||
}
|
||||
|
||||
// cache and return
|
||||
CachedFont cachedBoldFont = new CachedFont(f);
|
||||
derivedFontMap.put(f, cachedBoldFont);
|
||||
return cachedBoldFont.getBold();
|
||||
default: //in this case regular
|
||||
if (isRunescapeFont(f))
|
||||
{
|
||||
return runescapeFont;
|
||||
}
|
||||
if (derivedFontMap.containsKey(f))
|
||||
{
|
||||
return derivedFontMap.get(f).getReg();
|
||||
}
|
||||
|
||||
// cache and return
|
||||
CachedFont cachedFont = new CachedFont(f);
|
||||
derivedFontMap.put(f, cachedFont);
|
||||
return cachedFont.getReg();
|
||||
}
|
||||
}
|
||||
|
||||
public static Font lookupFont(String fontName)
|
||||
{
|
||||
return fontMap.get(fontName);
|
||||
}
|
||||
|
||||
public static String getFontName(Font font)
|
||||
{
|
||||
return fontMap.inverse().get(font);
|
||||
}
|
||||
|
||||
public static String[] getAvailableFontNames()
|
||||
{
|
||||
return fontMap.keySet().toArray(new String[fontMap.keySet().size()]);
|
||||
}
|
||||
|
||||
public static boolean isAvailable(Font font)
|
||||
{
|
||||
return fontMap.containsKey(font.getFontName());
|
||||
}
|
||||
|
||||
public static Font getFontOrDefault(Font font)
|
||||
{
|
||||
if (font == null || !fontMap.containsKey(font.getFontName()))
|
||||
{
|
||||
return getRunescapeFont();
|
||||
}
|
||||
return getFontOffCorrectSize(font);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class PluginErrorPanel extends JPanel
|
||||
noResultsTitle.setForeground(Color.WHITE);
|
||||
noResultsTitle.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
noResultsDescription.setFont(FontManager.getRunescapeSmallFont());
|
||||
noResultsDescription.setFont(FontManager.getSmallFont(getFont()));
|
||||
noResultsDescription.setForeground(Color.GRAY);
|
||||
noResultsDescription.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
|
||||
@@ -69,18 +69,26 @@ public class ProgressBar extends DimmableJPanel
|
||||
|
||||
setPreferredSize(new Dimension(100, 16));
|
||||
|
||||
leftLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
int topIndent = 0;
|
||||
if (getFont().equals(FontManager.getRunescapeSmallFont())
|
||||
|| getFont().equals(FontManager.getRunescapeFont())
|
||||
|| getFont().equals(FontManager.getRunescapeBoldFont()))
|
||||
{
|
||||
topIndent = 2;
|
||||
}
|
||||
|
||||
leftLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
leftLabel.setForeground(Color.WHITE);
|
||||
leftLabel.setBorder(new EmptyBorder(2, 5, 0, 0));
|
||||
leftLabel.setBorder(new EmptyBorder(topIndent, 5, 0, 0));
|
||||
|
||||
rightLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
rightLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
rightLabel.setForeground(Color.WHITE);
|
||||
rightLabel.setBorder(new EmptyBorder(2, 0, 0, 5));
|
||||
rightLabel.setBorder(new EmptyBorder(topIndent, 0, 0, 5));
|
||||
|
||||
centerLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
centerLabel.setFont(FontManager.getSmallFont(getFont()));
|
||||
centerLabel.setForeground(Color.WHITE);
|
||||
centerLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
centerLabel.setBorder(new EmptyBorder(2, 0, 0, 0));
|
||||
centerLabel.setBorder(new EmptyBorder(topIndent, 0, 0, 0));
|
||||
|
||||
// Adds components to be automatically redrawn when paintComponents is called
|
||||
add(leftLabel, BorderLayout.WEST);
|
||||
|
||||
@@ -25,7 +25,11 @@
|
||||
package net.runelite.client.ui.components.shadowlabel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.util.Map;
|
||||
import javax.swing.JLabel;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -61,4 +65,17 @@ public class JShadowedLabel extends JLabel
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
// Set font rendering properties like the OS's font rendering
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
Map desktopHints = (Map)(tk.getDesktopProperty("awt.font.desktophints"));
|
||||
if (desktopHints != null)
|
||||
{
|
||||
((Graphics2D)g).addRenderingHints(desktopHints);
|
||||
}
|
||||
super.paint(g);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,11 @@ import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.SwingUtilities;
|
||||
@@ -53,6 +55,7 @@ import net.runelite.client.input.MouseAdapter;
|
||||
import net.runelite.client.input.MouseManager;
|
||||
import net.runelite.client.ui.JagexColors;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.util.MiscUtils;
|
||||
|
||||
@Singleton
|
||||
@@ -165,6 +168,14 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
||||
return;
|
||||
}
|
||||
|
||||
// Set font rendering properties like the OS's font rendering
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
Map desktopHints = (Map)(tk.getDesktopProperty("awt.font.desktophints"));
|
||||
if (desktopHints != null)
|
||||
{
|
||||
graphics.addRenderingHints(desktopHints);
|
||||
}
|
||||
|
||||
if (shouldInvalidateBounds())
|
||||
{
|
||||
snapCorners = buildSnapCorners();
|
||||
@@ -446,15 +457,15 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
||||
// Set font based on configuration
|
||||
if (position == OverlayPosition.DYNAMIC || position == OverlayPosition.DETACHED)
|
||||
{
|
||||
subGraphics.setFont(runeLiteConfig.fontType().getFont());
|
||||
subGraphics.setFont(FontManager.getFontFromType(runeLiteConfig.clientFont(), runeLiteConfig.fontType()));
|
||||
}
|
||||
else if (position == OverlayPosition.TOOLTIP)
|
||||
{
|
||||
subGraphics.setFont(runeLiteConfig.tooltipFontType().getFont());
|
||||
subGraphics.setFont(FontManager.getFontFromType(runeLiteConfig.clientFont(), runeLiteConfig.tooltipFontType()));
|
||||
}
|
||||
else
|
||||
{
|
||||
subGraphics.setFont(runeLiteConfig.interfaceFontType().getFont());
|
||||
subGraphics.setFont(FontManager.getFontFromType(runeLiteConfig.clientFont(), runeLiteConfig.interfaceFontType()));
|
||||
}
|
||||
|
||||
subGraphics.translate(point.x, point.y);
|
||||
|
||||
@@ -39,7 +39,7 @@ import net.runelite.client.ui.FontManager;
|
||||
@Setter
|
||||
public class InfoBoxComponent implements LayoutableRenderableEntity
|
||||
{
|
||||
private static final int SEPARATOR = 3;
|
||||
private static final int SEPARATOR = 2;
|
||||
private static final int DEFAULT_SIZE = 32;
|
||||
|
||||
@Getter
|
||||
@@ -63,7 +63,14 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
|
||||
return new Dimension();
|
||||
}
|
||||
|
||||
graphics.setFont(getSize() < DEFAULT_SIZE ? FontManager.getRunescapeSmallFont() : FontManager.getRunescapeFont());
|
||||
if (graphics.getFont().equals(FontManager.getRunescapeFont()) && getSize() > DEFAULT_SIZE)
|
||||
{
|
||||
graphics.setFont(FontManager.getRunescapeFont());
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.setFont(FontManager.getSmallFont(graphics.getFont()));
|
||||
}
|
||||
|
||||
final int baseX = preferredLocation.x;
|
||||
final int baseY = preferredLocation.y;
|
||||
@@ -92,7 +99,7 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
textComponent.setColor(color);
|
||||
textComponent.setText(text);
|
||||
textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - SEPARATOR));
|
||||
textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - metrics.getMaxDescent() - SEPARATOR));
|
||||
textComponent.render(graphics);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class LineComponent implements LayoutableRenderableEntity
|
||||
|
||||
final FontMetrics metrics = graphics.getFontMetrics();
|
||||
final int baseX = preferredLocation.x;
|
||||
final int baseY = preferredLocation.y + metrics.getHeight();
|
||||
final int baseY = preferredLocation.y;
|
||||
int x = baseX;
|
||||
int y = baseY;
|
||||
final int leftFullWidth = getLineWidth(left, metrics);
|
||||
@@ -92,6 +92,7 @@ public class LineComponent implements LayoutableRenderableEntity
|
||||
|
||||
for (int i = 0; i < lineCount; i++)
|
||||
{
|
||||
y += metrics.getMaxAscent();
|
||||
String leftText = "";
|
||||
String rightText = "";
|
||||
|
||||
@@ -116,7 +117,7 @@ public class LineComponent implements LayoutableRenderableEntity
|
||||
rightLineComponent.setText(rightText);
|
||||
rightLineComponent.setColor(rightColor);
|
||||
rightLineComponent.render(graphics);
|
||||
y += metrics.getHeight();
|
||||
y += metrics.getMaxDescent();
|
||||
}
|
||||
|
||||
final Dimension dimension = new Dimension(preferredSize.width, y - baseY);
|
||||
@@ -124,6 +125,7 @@ public class LineComponent implements LayoutableRenderableEntity
|
||||
bounds.setSize(dimension);
|
||||
return dimension;
|
||||
}
|
||||
y += metrics.getMaxAscent();
|
||||
|
||||
final TextComponent leftLineComponent = new TextComponent();
|
||||
leftLineComponent.setPosition(new Point(x, y));
|
||||
@@ -136,7 +138,7 @@ public class LineComponent implements LayoutableRenderableEntity
|
||||
rightLineComponent.setText(right);
|
||||
rightLineComponent.setColor(rightColor);
|
||||
rightLineComponent.render(graphics);
|
||||
y += metrics.getHeight();
|
||||
y += metrics.getMaxDescent();
|
||||
|
||||
final Dimension dimension = new Dimension(preferredSize.width, y - baseY);
|
||||
bounds.setLocation(preferredLocation);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ProgressBarComponent implements LayoutableRenderableEntity
|
||||
final int width = preferredSize.width;
|
||||
final int height = Math.max(preferredSize.height, 16);
|
||||
final int progressTextX = barX + (width - metrics.stringWidth(textToWrite)) / 2;
|
||||
final int progressTextY = barY + ((height - metrics.getHeight()) / 2) + metrics.getHeight();
|
||||
final int progressTextY = barY + ((height - metrics.getHeight()) / 2) + metrics.getMaxAscent();
|
||||
final int progressFill = (int) (width * Math.min(1, pc));
|
||||
|
||||
// Draw bar
|
||||
|
||||
@@ -24,11 +24,15 @@
|
||||
*/
|
||||
package net.runelite.client.ui.overlay.components;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.ui.overlay.RenderableEntity;
|
||||
@@ -43,6 +47,7 @@ public class TextComponent implements RenderableEntity
|
||||
private String text;
|
||||
private Point position = new Point();
|
||||
private Color color = Color.WHITE;
|
||||
private Color borderColor = Color.BLACK;
|
||||
|
||||
public static String textWithoutColTags(String text)
|
||||
{
|
||||
@@ -64,28 +69,43 @@ public class TextComponent implements RenderableEntity
|
||||
final String textWithoutCol = textWithoutColTags(textSplitOnCol);
|
||||
final String colColor = textSplitOnCol.substring(textSplitOnCol.indexOf("=") + 1, textSplitOnCol.indexOf(">"));
|
||||
|
||||
// shadow
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.drawString(textWithoutCol, x + 1, position.y + 1);
|
||||
|
||||
// actual text
|
||||
graphics.setColor(Color.decode("#" + colColor));
|
||||
graphics.drawString(textWithoutCol, x, position.y);
|
||||
renderText(graphics, x, position.y, textWithoutCol, Color.decode("#" + colColor), borderColor);
|
||||
|
||||
x += fontMetrics.stringWidth(textWithoutCol);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// shadow
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.drawString(text, position.x + 1, position.y + 1);
|
||||
|
||||
// actual text
|
||||
graphics.setColor(color);
|
||||
graphics.drawString(text, position.x, position.y);
|
||||
renderText(graphics, position.x, position.y, text, color, borderColor);
|
||||
}
|
||||
|
||||
return new Dimension(fontMetrics.stringWidth(text), fontMetrics.getHeight());
|
||||
}
|
||||
|
||||
private void renderText(Graphics2D graphics, int x, int y, String text, Color color, Color border)
|
||||
{
|
||||
// remember previous composite
|
||||
Composite originalComposite = graphics.getComposite();
|
||||
|
||||
// create a vector of the text
|
||||
GlyphVector vector = graphics.getFont().createGlyphVector(graphics.getFontRenderContext(), text);
|
||||
|
||||
// compute the text shape
|
||||
Shape stroke = vector.getOutline(x + 1, y + 1);
|
||||
Shape shape = vector.getOutline(x, y);
|
||||
|
||||
// draw text border
|
||||
graphics.setColor(border);
|
||||
graphics.fill(stroke);
|
||||
|
||||
// replace the pixels instead of overlaying
|
||||
graphics.setComposite(AlphaComposite.Src);
|
||||
|
||||
// draw actual text
|
||||
graphics.setColor(color);
|
||||
graphics.fill(shape);
|
||||
|
||||
// reset composite to original
|
||||
graphics.setComposite(originalComposite);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class TitleComponent implements LayoutableRenderableEntity
|
||||
titleComponent.setColor(color);
|
||||
titleComponent.setPosition(new Point(
|
||||
baseX + ((preferredSize.width - metrics.stringWidth(text)) / 2),
|
||||
baseY + metrics.getHeight()));
|
||||
baseY + metrics.getMaxAscent()));
|
||||
final Dimension rendered = titleComponent.render(graphics);
|
||||
final Dimension dimension = new Dimension(preferredSize.width, rendered.height);
|
||||
bounds.setLocation(preferredLocation);
|
||||
|
||||
@@ -104,7 +104,7 @@ public class TooltipComponent implements RenderableEntity
|
||||
textComponent.setColor(nextColor);
|
||||
String text = line.substring(begin, j);
|
||||
textComponent.setText(text);
|
||||
textComponent.setPosition(new Point(lineX, textY + (i + 1) * textHeight - textDescent));
|
||||
textComponent.setPosition(new Point(lineX, textY + (i + 1) * metrics.getMaxAscent() + i * metrics.getMaxDescent()));
|
||||
textComponent.render(graphics);
|
||||
|
||||
lineX += metrics.stringWidth(text);
|
||||
@@ -141,7 +141,7 @@ public class TooltipComponent implements RenderableEntity
|
||||
textComponent.setColor(nextColor);
|
||||
String text = line.substring(begin, j + 1);
|
||||
textComponent.setText(text);
|
||||
textComponent.setPosition(new Point(lineX, textY + (i + 1) * textHeight - textDescent));
|
||||
textComponent.setPosition(new Point(lineX, textY + (i + 1) * metrics.getMaxAscent() + i * metrics.getMaxDescent()));
|
||||
textComponent.render(graphics);
|
||||
|
||||
lineX += metrics.stringWidth(text);
|
||||
@@ -155,7 +155,7 @@ public class TooltipComponent implements RenderableEntity
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
textComponent.setColor(nextColor);
|
||||
textComponent.setText(line.substring(begin));
|
||||
textComponent.setPosition(new Point(lineX, textY + (i + 1) * textHeight - textDescent));
|
||||
textComponent.setPosition(new Point(lineX, textY + (i + 1) * metrics.getMaxAscent() + i * metrics.getMaxDescent()));
|
||||
textComponent.render(graphics);
|
||||
}
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ public class WorldMapOverlay extends Overlay
|
||||
graphics.setColor(JagexColors.TOOLTIP_BORDER);
|
||||
graphics.drawRect((int) tooltipRect.getX(), (int) tooltipRect.getY(), (int) tooltipRect.getWidth(), (int) tooltipRect.getHeight());
|
||||
graphics.setColor(JagexColors.TOOLTIP_TEXT);
|
||||
graphics.drawString(tooltip, drawPoint.getX(), drawPoint.getY() + height);
|
||||
graphics.drawString(tooltip, drawPoint.getX(), drawPoint.getY() + fm.getMaxAscent());
|
||||
}
|
||||
|
||||
private Point clipToRectangle(Point drawPoint, Rectangle mapDisplayRectangle)
|
||||
|
||||
@@ -309,6 +309,8 @@ public class SwingUtil
|
||||
// Use substance look and feel
|
||||
SwingUtil.setTheme(new SubstanceRuneLiteLookAndFeel());
|
||||
// Use custom UI font
|
||||
//TODO : SUPPORT CUSTOM FONT?
|
||||
//SwingUtil.setFont(FontManager.getFontOrDefault(config.clientFont()));
|
||||
SwingUtil.setFont(FontManager.getRunescapeFont());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user