Skip to content

Conversation

@bubblobill
Copy link
Collaborator

@bubblobill bubblobill commented Aug 2, 2025

Identify the Bug or Feature request

You can link a pull request to an issue with one of
fixes #5622 #5746
progresses #5594 #5586 #4726 #4944 #3691 #2750 #2346 #2328 #2000

until I got sick of looking for affected issues

Description of the Change

LabelRenderer

  • Moved caches to class, added setters and static isLabelVisible method.
  • Moved token label generation in token rendering sequence preparatory to moving it out to DecorationRenderer.

New class TokenDecorationRenderer

  • Paints things before and after token rendering.
  • Hub for halos, bars, states, etc. More bits to follow.

New class OverlayRenderer

  • For painting states and bars.

FacingArrowRenderer

  • Facing arrow now follows grid cell shape. Made some variables non-local.

GeometryUtil

  • Added functions for finding intersection points.

HaloRenderer

  • Now honours preference for opacity.

TokenRenderer

  • Updated to call decoration renderer before and after painting image. plus other tweaks.

ZoneViewModel

  • Added method- isUsingVision().

ZoneRenderer

  • Inverted hasMoveSelectionSetMoved().
  • Made imageLabelFactory a constant.
  • LabelRenderingCache offloaded to LabelRenderer.
  • Renamed renderLabels() method as it is confusing.
  • Removed redundant image loading and token flipping from renderTokens().
  • Other housework.

Possible Drawbacks

I'm not very good at my job

Documentation Notes

Separated most token decoration rendering out of ZoneRenderer


This change is Reviewable

 - Moved caches to class, added setters and static isLabelVisible method.
 - Moved token label generation in token rendering sequence preparatory to moving it out to DecorationRenderer.
New class TokenDecorationRenderer
 - Paints things before and after token rendering.
 - Hub for halos, bars, states, etc. More bits to follow.
New class OverlayRenderer
 - For painting states and bars.
FacingArrowRenderer
 - Facing arrow now follows grid cell shape. Made some variables non-local.
GeometryUtil
 - Added functions for finding intersection points.
HaloRenderer
 - Now honours preference for opacity.
TokenRenderer
 - Updated to call decoration renderer before and after painting image. plus other tweaks.
ZoneViewModel
 - Added method- isUsingVision().
ZoneRenderer
 - Inverted hasMoveSelectionSetMoved().
 - Made imageLabelFactory a constant.
 - LabelRenderingCache offloaded to LabelRenderer.
 - Renamed renderLabels() method as it is confusing.
 - Removed redundant image loading and token flipping from renderTokens().
 - Other housework.
@github-actions github-actions bot added the feature Adding functionality that adds value label Aug 2, 2025
@bubblobill bubblobill added performance A performance or quality of life improvement code-maintenance Adding/editing javadocs, unit tests, formatting. labels Aug 2, 2025
@bubblobill bubblobill self-assigned this Aug 2, 2025
private float lineWeight = AppPreferences.haloLineWidth.get();

{
AppPreferences.haloOverlayOpacity.onChange(i -> opacity = i / 255f);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think AppPreferences.haloOverlayOpacity is intended to be used in this way as the opacity for all rendered halos, but was intended just for a token's vision when using the halo color (as per the logic in VisionOverlayRenderer.java). Given the current default preference value of 50, this code would nerf everyone's halos!

Maybe the existing AppPreferences.haloOverlayOpacity display text should be changed for clarity (even though it sits under the Map Visuals tab).

In light of my halo feature PR, maybe there should instead be a new campaign setting or preference for global halo opacity (and/or configured for halos a la lights and auras)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then they should not have called it "halo overlay opacity", and I agree the default is stoopid.

If only there was some way to manage halos in a fine-grained manner that permitted individual variation from the global setting. :P

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to echo what Baaaaaz said, don't change the behaviour of the preference in this way. Fix the wording if you don't like it.
This opacity setting should only apply to the vision overlay, not the halo around the cell. The two have nothing to do with each other, and this will only cause confusion.

@Subscribe
private void onGridChanged(GridChanged event) {
if (event.zone() != null) {
this.zone = event.zone();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want to change the zone here since each FacingArrowRenderer is specific to a single zone (as each TokenRenderer / ZoneRenderer is). Instead, check that the zone is the same, and ignore the event if it's not.

This event handling is also unnecessary. isSquare isn't used and should be removed, and isIsometric is so cheap it's not worth managing state just to get it.

return labelImageCache;
}

private final ZoneRenderer renderer;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove renderer as it's no longer used.

public class LabelRenderer implements ItemRenderer {

private static final Map<GUID, LabelRenderer> labelCache = new HashMap<>();
private static final Map<GUID, BufferedImage> labelImageCache = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The labelImageCache is a memory leak and needs to be changed. There needs to be some way to allow old entries to be garbage collected. The easy way to do this is to not make these static so that they can at least be collected when the zone is removed. Or you need a way to explicitly remove old entries. Compare with the original ZoneRenderer.labelRenderingCache which did both.

labelCache has similar issues. Although entries can be removed, it's only done as part of the render loop. So there's no way for entries from a removed zone to be collected.

private float lineWeight = AppPreferences.haloLineWidth.get();

{
AppPreferences.haloOverlayOpacity.onChange(i -> opacity = i / 255f);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to echo what Baaaaaz said, don't change the behaviour of the preference in this way. Fix the wording if you don't like it.
This opacity setting should only apply to the vision overlay, not the halo around the cell. The two have nothing to do with each other, and this will only cause confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-maintenance Adding/editing javadocs, unit tests, formatting. feature Adding functionality that adds value performance A performance or quality of life improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Facing arrow obscured

3 participants