convert items which would override to small font to override to small version of selected font

This commit is contained in:
l2-
2018-10-22 21:49:22 +02:00
parent 15d513b3c6
commit 1f1478a9b2
31 changed files with 70 additions and 61 deletions

View File

@@ -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;
@@ -74,7 +73,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 ORANGE = new Color(255, 109, 0);
@@ -111,7 +109,6 @@ class DevToolsOverlay extends Overlay
@Override
public Dimension render(Graphics2D graphics)
{
graphics.setFont(FONT);
if (plugin.getPlayers().isActive())
{

View File

@@ -192,7 +192,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)

View File

@@ -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);

View File

@@ -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);

View File

@@ -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());

View File

@@ -106,7 +106,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);
@@ -170,7 +170,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)
{
JPanel container = new JPanel();
container.setBackground(ColorScheme.DARKER_GRAY_COLOR);
@@ -224,11 +224,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);

View File

@@ -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)

View File

@@ -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);

View File

@@ -277,8 +277,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);

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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));

View File

@@ -162,7 +162,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()
{
@@ -191,7 +191,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()
{
@@ -217,7 +217,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()
{

View File

@@ -212,7 +212,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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -134,7 +134,7 @@ class SlayerOverlay extends Overlay
int slaughterCount = plugin.getSlaughterChargeCount();
int expeditiousCount = plugin.getExpeditiousChargeCount();
graphics.setFont(FontManager.getRunescapeSmallFont());
graphics.setFont(FontManager.getSmallFont(graphics.getFont()));
for (WidgetItem item : getSlayerItems())
{

View File

@@ -105,11 +105,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);

View File

@@ -66,10 +66,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);

View File

@@ -155,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);
@@ -175,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;

View File

@@ -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;

View File

@@ -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++;

View File

@@ -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 ->

View File

@@ -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);

View File

@@ -142,10 +142,10 @@ class XpInfoBox extends JPanel
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
statsPanel.setBorder(new EmptyBorder(9, 2, 9, 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);

View File

@@ -114,8 +114,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);

View File

@@ -131,16 +131,21 @@ public class FontManager
return f.equals(runescapeFont) || f.equals(runescapeSmallFont) || f.equals(runescapeBoldFont);
}
public static Font getSmallFont(Font f)
{
if (isRunescapeFont(f))
{
return runescapeSmallFont;
}
return getFontOrDefault(f);
}
public static Font getFontFromType(Font f, FontType type)
{
switch (type)
{
case SMALL:
if (isRunescapeFont(f))
{
return runescapeSmallFont;
}
return getFontOrDefault(f);
return getSmallFont(f);
case BOLD:
if (isRunescapeFont(f))
{

View File

@@ -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);

View File

@@ -74,15 +74,15 @@ public class ProgressBar extends DimmableJPanel
topIndent = 2;
}
leftLabel.setFont(FontManager.getRunescapeSmallFont());
leftLabel.setFont(FontManager.getSmallFont(getFont()));
leftLabel.setForeground(Color.WHITE);
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(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(topIndent, 0, 0, 0));

View File

@@ -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;