Skip to content

Fix for missing state image IDs in campaign files#6008

Draft
kwvanderlinde wants to merge 6 commits into
RPTools:developfrom
kwvanderlinde:bugfix/5829-missing-corner-image-asset-ids
Draft

Fix for missing state image IDs in campaign files#6008
kwvanderlinde wants to merge 6 commits into
RPTools:developfrom
kwvanderlinde:bugfix/5829-missing-corner-image-asset-ids

Conversation

@kwvanderlinde

@kwvanderlinde kwvanderlinde commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Identify the Bug or Feature request

Fixes #5933, introduced in PR #5829

Description of the Change

The recent changes in the type hierarchy for states had some unintended consequences and certain parts of the code check explicitly for the ImageTokenOverlay class. As this is no longer a base class for the other image-based states, various functionality did not recognized these states as having images.

This PR makes two core changes to avoid the problem going forward:

  1. All token overlays (states and bars) now have a generic #getAssetIds() method that returns the IDs of all the assets required by the overlay. This is used in a few places that used to do explicit type checks, but especially in CampaignProperties#getAllImageAssets() which gathers all the asset IDs that have to be included in the campaign file.
  2. Image-based states now have a common base class again, in the form of AbstractImageTokenOverlay. Where type checks are needed, this type is checked rather than individually checking for the various concrete classes.

For getInfo("campaign"), there is still some need to check concrete types to provide the "corner" and "gridSize" keys for associated states.

In TokenStatesController, an exhaustive switch is now used to make sure we handle all the possible cases.

Possible Drawbacks

None

Documentation Notes

N/A

Release Notes

N/A


This change is Reviewable

This makes campaign writing more robust as it can simply ask for the list of relevant assets rather than first trying to
figure out the types of all the states and bars.
`AbstractImageTokenOverlay` is the base for `ImageTokenOverlay`, `CornerImageTokenOverlay`, and `FlowImageTokenOverlay`.
In places where a type check is needed to look for an image-based overlay, `AbstractImageTokenOverlay` is now checked
instead of `ImageTokenOverlay`. The new base class also provides an implementation of `#getAssetId()` and `#getAssets()`
so child classes don't have to worry about it.
`Campaign#getAllAssetIds()` new leverages `CampaignProperties#getAllImageAssets()` rather than duplicating the same
logic for lookup tables, bars, and states. `CampaignProperties#getAllImageAssets()` in turn now uses
`AbstractTokenOverlay#getAssets()` rather than enumerating the possible types that could have assets.
- `getBarImage()` macro function implementation and `TokenBarController` to use the new list-based
`AbstractTokenOverlay#getAssets()`
- `TokenStatesController` uses switch for exhaustiveness over all state types
- `getInfo("campaign")` shows the grid size for shape-based flow states and image-based flow states
- `getStateImage()` macro function checks for `AbstractImageTokenOverlay` rather than `ImageTokenOverlay``
…setIds()

In `MultipleImageBarTokenOverlay`, replace the array-based accessor and mutator with `List`-based ones.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[Bug]: Images not saved to campaign file

1 participant