text visibility enhancements

* add config for text outline, draw text over gameobject highlight
* add configurable dynamic overlay font
* space heat/action text according to font height
* draw text manually
* add configurable text background
This commit is contained in:
riktenx
2025-08-28 22:56:57 -04:00
parent 00b214af3f
commit 5cb7de46c6
4 changed files with 116 additions and 16 deletions

View File

@@ -2,6 +2,8 @@ package com.toofifty.easygiantsfoundry;
import java.awt.Color; 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.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
@@ -510,6 +512,44 @@ public interface EasyGiantsFoundryConfig extends Config
return Color.CYAN; 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( @ConfigItem(
position = -100, position = -100,
keyName = "alwaysShowInfoPanel", keyName = "alwaysShowInfoPanel",

View File

@@ -1,17 +1,18 @@
package com.toofifty.easygiantsfoundry; package com.toofifty.easygiantsfoundry;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Point;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import javax.inject.Singleton; import javax.inject.Singleton;
import java.awt.Color; import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
@Slf4j @Slf4j
@Singleton @Singleton
public final class EasyGiantsFoundryHelper public final class EasyGiantsFoundryHelper
{ {
public static Color getHeatColor(int actions, int heat) public static Color getHeatColor(int actions, int heat)
{ {
if (heat >= actions) if (heat >= actions)
@@ -26,4 +27,30 @@ public final class EasyGiantsFoundryHelper
return ColorScheme.PROGRESS_ERROR_COLOR; 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.EasyGiantsFoundryClientIDs.*;
import static com.toofifty.easygiantsfoundry.EasyGiantsFoundryHelper.getHeatColor; 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_1_VARBIT;
import static com.toofifty.easygiantsfoundry.MouldHelper.SWORD_TYPE_2_VARBIT; import static com.toofifty.easygiantsfoundry.MouldHelper.SWORD_TYPE_2_VARBIT;
import com.toofifty.easygiantsfoundry.enums.CommissionType; import com.toofifty.easygiantsfoundry.enums.CommissionType;
import com.toofifty.easygiantsfoundry.enums.FontType;
import com.toofifty.easygiantsfoundry.enums.Heat; import com.toofifty.easygiantsfoundry.enums.Heat;
import com.toofifty.easygiantsfoundry.enums.Stage; 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.api.widgets.Widget;
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.outline.ModelOutlineRenderer; import net.runelite.client.ui.overlay.outline.ModelOutlineRenderer;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -107,6 +108,11 @@ public class FoundryOverlay3D extends Overlay
return null; return null;
} }
if (config.dynamicOverlayFont() != FontType.DEFAULT)
{
graphics.setFont(config.dynamicOverlayFont().getFont());
}
if (config.highlightKovac()) if (config.highlightKovac())
{ {
drawKovacIfHandIn(graphics); drawKovacIfHandIn(graphics);
@@ -147,8 +153,6 @@ public class FoundryOverlay3D extends Overlay
return null; return null;
} }
drawActionOverlay(graphics, stageObject);
Heat heat = state.getCurrentHeat(); Heat heat = state.getCurrentHeat();
Color color = getObjectColor(stage, heat); Color color = getObjectColor(stage, heat);
// TODO Config // TODO Config
@@ -186,6 +190,8 @@ public class FoundryOverlay3D extends Overlay
} }
} }
drawActionOverlay(graphics, stageObject);
return null; return null;
} }
@@ -274,7 +280,7 @@ public class FoundryOverlay3D extends Overlay
Color color = config.lavaWaterfallColour(); 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) 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); Point pos = Perspective.getCanvasTextLocation(client, graphics, stageLoc, text, 50);
Color color = config.lavaWaterfallColour(); Color color = config.lavaWaterfallColour();
OverlayUtil.renderTextLocation(graphics, pos, text, color); renderTextLocation(graphics, pos, text, color, config.textBackground(), config.textOutline());
} }
private void drawHeatChangers(Graphics2D graphics) private void drawHeatChangers(Graphics2D graphics)
@@ -382,7 +388,7 @@ public class FoundryOverlay3D extends Overlay
{ {
color = config.generalHighlight(); color = config.generalHighlight();
} }
OverlayUtil.renderTextLocation(graphics, pos, text, color); renderTextLocation(graphics, pos, text, color, config.textBackground(), config.textOutline());
} }
private void drawMouldScoreIfMouldSet(Graphics2D graphics) { private void drawMouldScoreIfMouldSet(Graphics2D graphics) {
@@ -405,7 +411,7 @@ public class FoundryOverlay3D extends Overlay
Point pos = Perspective.getCanvasTextLocation(client, graphics, mouldLoc, text, 115); Point pos = Perspective.getCanvasTextLocation(client, graphics, mouldLoc, text, 115);
Color color = config.generalHighlight(); Color color = config.generalHighlight();
OverlayUtil.renderTextLocation(graphics, pos, text, color); renderTextLocation(graphics, pos, text, color, config.textBackground(), config.textOutline());
} }
private void drawPreformScoreIfPoured(Graphics2D graphics) { private void drawPreformScoreIfPoured(Graphics2D graphics) {
if (client.getVarbitValue(VARBIT_GAME_STAGE) != 2) if (client.getVarbitValue(VARBIT_GAME_STAGE) != 2)
@@ -425,7 +431,7 @@ public class FoundryOverlay3D extends Overlay
Color color = config.generalHighlight(); Color color = config.generalHighlight();
OverlayUtil.renderTextLocation(graphics, pos, text, color); renderTextLocation(graphics, pos, text, color, config.textBackground(), config.textOutline());
} }
private void drawCrucibleIfMouldSet(Graphics2D graphics) private void drawCrucibleIfMouldSet(Graphics2D graphics)
@@ -439,8 +445,6 @@ public class FoundryOverlay3D extends Overlay
return; return;
} }
drawCrucibleContent(graphics);
if (config.highlightStyle() == HighlightStyle.HIGHLIGHT_CLICKBOX) if (config.highlightStyle() == HighlightStyle.HIGHLIGHT_CLICKBOX)
{ {
Shape shape = crucible.getConvexHull(); Shape shape = crucible.getConvexHull();
@@ -473,6 +477,8 @@ public class FoundryOverlay3D extends Overlay
} }
drawObjectOutline(graphics, crucible, color); drawObjectOutline(graphics, crucible, color);
} }
drawCrucibleContent(graphics);
} }
private void drawMouldIfNotSet(Graphics2D graphics) private void drawMouldIfNotSet(Graphics2D graphics)
@@ -510,7 +516,7 @@ public class FoundryOverlay3D extends Overlay
textLocation = new LocalPoint(textLocation.getX(), textLocation.getY()); textLocation = new LocalPoint(textLocation.getX(), textLocation.getY());
Point canvasLocation = Perspective.getCanvasTextLocation(client, graphics, textLocation, text, 100); Point canvasLocation = Perspective.getCanvasTextLocation(client, graphics, textLocation, text, 100);
canvasLocation = new Point(canvasLocation.getX(), canvasLocation.getY() + 10); 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; return;
} }
OverlayUtil.renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft)); renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft), config.textBackground(), config.textOutline());
} }
if (config.drawActionLeftOverlay()) if (config.drawActionLeftOverlay())
// Draw actions left // Draw actions left
@@ -575,8 +581,8 @@ public class FoundryOverlay3D extends Overlay
{ {
return; return;
} }
canvasLocation = new Point(canvasLocation.getX(), canvasLocation.getY() + 10); canvasLocation = new Point(canvasLocation.getX(), canvasLocation.getY() + graphics.getFontMetrics().getHeight());
OverlayUtil.renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft)); 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;
}
}