Merge pull request #56 from Toofifty/textoutline

text visibility enhancements
This commit is contained in:
riktenx
2025-08-30 17:33:45 -04:00
committed by GitHub
6 changed files with 119 additions and 18 deletions

View File

@@ -67,4 +67,5 @@ Bonus Click Notification | Information Panel
* Integrated Smith's outfit effect
- [Aiadan](https://github.com/Aiadan "Aiadan's github")
* Added metal counter
- [Rikten X](https://github.com/riktenx "Rikten X's github")
* Added configs to enhance text visibility

View File

@@ -27,7 +27,7 @@ dependencies {
}
group = 'com.toofifty'
version = '1.0.10'
version = '1.0.11'
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'

View File

@@ -2,6 +2,8 @@ package com.toofifty.easygiantsfoundry;
import java.awt.Color;
import com.toofifty.easygiantsfoundry.enums.FontType;
import net.runelite.client.config.Alpha;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@@ -510,6 +512,44 @@ public interface EasyGiantsFoundryConfig extends Config
return Color.CYAN;
}
@ConfigItem(
keyName = "textBackground",
name = "Text Background",
description = "Set a color to draw a box behind text.",
position = 7,
section = colourList
)
@Alpha
default Color textBackground()
{
return null;
}
@ConfigItem(
keyName = "dynamicOverlayFont",
name = "Dynamic Overlay Font",
description = "Choose the font type for the info overlay.<br/>" +
"Defaults to your setting from RuneLite -> Overlay settings -> Dynamic overlay font.",
position = 10,
section = colourList
)
default FontType dynamicOverlayFont()
{
return FontType.DEFAULT;
}
@ConfigItem(
keyName = "textOutline",
name = "Text Outline",
description = "Use an outline around text instead of a shadow.",
position = 11,
section = colourList
)
default boolean textOutline()
{
return false;
}
@ConfigItem(
position = -100,
keyName = "alwaysShowInfoPanel",

View File

@@ -1,17 +1,18 @@
package com.toofifty.easygiantsfoundry;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Point;
import net.runelite.client.ui.ColorScheme;
import javax.inject.Singleton;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
@Slf4j
@Singleton
public final class EasyGiantsFoundryHelper
{
public static Color getHeatColor(int actions, int heat)
{
if (heat >= actions)
@@ -26,4 +27,30 @@ public final class EasyGiantsFoundryHelper
return ColorScheme.PROGRESS_ERROR_COLOR;
}
public static void renderTextLocation(Graphics2D graphics, Point point, String text, Color fg, Color bg, boolean outline)
{
if (bg != null)
{
FontMetrics fm = graphics.getFontMetrics();
graphics.setColor(bg);
graphics.fillRect(point.getX(), point.getY() - fm.getHeight(), fm.stringWidth(text), fm.getHeight());
}
graphics.setColor(Color.BLACK);
if (outline)
{
graphics.drawString(text, point.getX(), point.getY() + 1);
graphics.drawString(text, point.getX(), point.getY() - 1);
graphics.drawString(text, point.getX() + 1, point.getY());
graphics.drawString(text, point.getX() - 1, point.getY());
}
else
{
graphics.drawString(text, point.getX() + 1, point.getY() + 1);
}
graphics.setColor(fg);
graphics.drawString(text, point.getX(), point.getY());
}
}

View File

@@ -2,9 +2,11 @@ package com.toofifty.easygiantsfoundry;
import static com.toofifty.easygiantsfoundry.EasyGiantsFoundryClientIDs.*;
import static com.toofifty.easygiantsfoundry.EasyGiantsFoundryHelper.getHeatColor;
import static com.toofifty.easygiantsfoundry.EasyGiantsFoundryHelper.renderTextLocation;
import static com.toofifty.easygiantsfoundry.MouldHelper.SWORD_TYPE_1_VARBIT;
import static com.toofifty.easygiantsfoundry.MouldHelper.SWORD_TYPE_2_VARBIT;
import com.toofifty.easygiantsfoundry.enums.CommissionType;
import com.toofifty.easygiantsfoundry.enums.FontType;
import com.toofifty.easygiantsfoundry.enums.Heat;
import com.toofifty.easygiantsfoundry.enums.Stage;
@@ -24,7 +26,6 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.widgets.Widget;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.outline.ModelOutlineRenderer;
import org.apache.commons.lang3.StringUtils;
@@ -107,6 +108,11 @@ public class FoundryOverlay3D extends Overlay
return null;
}
if (config.dynamicOverlayFont() != FontType.DEFAULT)
{
graphics.setFont(config.dynamicOverlayFont().getFont());
}
if (config.highlightKovac())
{
drawKovacIfHandIn(graphics);
@@ -147,8 +153,6 @@ public class FoundryOverlay3D extends Overlay
return null;
}
drawActionOverlay(graphics, stageObject);
Heat heat = state.getCurrentHeat();
Color color = getObjectColor(stage, heat);
// TODO Config
@@ -186,6 +190,8 @@ public class FoundryOverlay3D extends Overlay
}
}
drawActionOverlay(graphics, stageObject);
return null;
}
@@ -274,7 +280,7 @@ public class FoundryOverlay3D extends Overlay
Color color = config.lavaWaterfallColour();
OverlayUtil.renderTextLocation(graphics, pos, text, color);
renderTextLocation(graphics, pos, text, color, config.textBackground(), config.textOutline());
}
private void drawHeatChangerOverlay(Graphics2D graphics, GameObject stageObject)
@@ -304,7 +310,7 @@ public class FoundryOverlay3D extends Overlay
Point pos = Perspective.getCanvasTextLocation(client, graphics, stageLoc, text, 50);
Color color = config.lavaWaterfallColour();
OverlayUtil.renderTextLocation(graphics, pos, text, color);
renderTextLocation(graphics, pos, text, color, config.textBackground(), config.textOutline());
}
private void drawHeatChangers(Graphics2D graphics)
@@ -382,7 +388,7 @@ public class FoundryOverlay3D extends Overlay
{
color = config.generalHighlight();
}
OverlayUtil.renderTextLocation(graphics, pos, text, color);
renderTextLocation(graphics, pos, text, color, config.textBackground(), config.textOutline());
}
private void drawMouldScoreIfMouldSet(Graphics2D graphics) {
@@ -405,7 +411,7 @@ public class FoundryOverlay3D extends Overlay
Point pos = Perspective.getCanvasTextLocation(client, graphics, mouldLoc, text, 115);
Color color = config.generalHighlight();
OverlayUtil.renderTextLocation(graphics, pos, text, color);
renderTextLocation(graphics, pos, text, color, config.textBackground(), config.textOutline());
}
private void drawPreformScoreIfPoured(Graphics2D graphics) {
if (client.getVarbitValue(VARBIT_GAME_STAGE) != 2)
@@ -425,7 +431,7 @@ public class FoundryOverlay3D extends Overlay
Color color = config.generalHighlight();
OverlayUtil.renderTextLocation(graphics, pos, text, color);
renderTextLocation(graphics, pos, text, color, config.textBackground(), config.textOutline());
}
private void drawCrucibleIfMouldSet(Graphics2D graphics)
@@ -439,8 +445,6 @@ public class FoundryOverlay3D extends Overlay
return;
}
drawCrucibleContent(graphics);
if (config.highlightStyle() == HighlightStyle.HIGHLIGHT_CLICKBOX)
{
Shape shape = crucible.getConvexHull();
@@ -473,6 +477,8 @@ public class FoundryOverlay3D extends Overlay
}
drawObjectOutline(graphics, crucible, color);
}
drawCrucibleContent(graphics);
}
private void drawMouldIfNotSet(Graphics2D graphics)
@@ -510,7 +516,7 @@ public class FoundryOverlay3D extends Overlay
textLocation = new LocalPoint(textLocation.getX(), textLocation.getY());
Point canvasLocation = Perspective.getCanvasTextLocation(client, graphics, textLocation, text, 100);
canvasLocation = new Point(canvasLocation.getX(), canvasLocation.getY() + 10);
OverlayUtil.renderTextLocation(graphics, canvasLocation, text, config.generalHighlight());
renderTextLocation(graphics, canvasLocation, text, config.generalHighlight(), config.textBackground(), config.textOutline());
}
}
@@ -562,7 +568,7 @@ public class FoundryOverlay3D extends Overlay
{
return;
}
OverlayUtil.renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft));
renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft), config.textBackground(), config.textOutline());
}
if (config.drawActionLeftOverlay())
// Draw actions left
@@ -575,8 +581,8 @@ public class FoundryOverlay3D extends Overlay
{
return;
}
canvasLocation = new Point(canvasLocation.getX(), canvasLocation.getY() + 10);
OverlayUtil.renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft));
canvasLocation = new Point(canvasLocation.getX(), canvasLocation.getY() + graphics.getFontMetrics().getHeight());
renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft), config.textBackground(), config.textOutline());
}
}
}

View File

@@ -0,0 +1,27 @@
package com.toofifty.easygiantsfoundry.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.client.ui.FontManager;
import java.awt.Font;
@Getter
@AllArgsConstructor
public enum FontType
{
DEFAULT("Default", null),
REGULAR("Regular", FontManager.getRunescapeFont()),
BOLD("Bold", FontManager.getRunescapeBoldFont()),
SMALL("Small", FontManager.getRunescapeSmallFont()),
;
private final String name;
private final Font font;
@Override
public String toString()
{
return name;
}
}