Resource Icons
Resource Icons is a Foundry VTT module that adds customizable icons to tokens to track resources.
Usage
Resource Icons are configured in the Resources tab of the Token Configuration window.
To activate an icon, select a resource for it to track. To deactivate an icon, select "None."
If no icon image is selected, the default icon image is a white circle.
The border, background, and tint of each icon can be individually set.
The border shape (circle/square), where the resource icons are anchored (above/below/left of/right of token), and icon alignemnt (inside/outside of token) can be changed in the module settings (per user with an option to use world default set by GM).
Technical Notes
Resource Icons patches (via lib-wrapper) CONFIG.Token.objectClass.prototype.draw
to implement resource icon drawing. This drawing is handled by a new method added to the Token object class: drawResourceIcons
. This method adds three PIXI container children to the token. Each of these PIXI containers themselves are assigned three PIXI children (based on resource icon configuration): background (which encompasses border), icon image, and value text.
Resource Icons also patches CONFIG.Token.objectClass.prototype._onUpdate
to handle changes to resource icon configuration (in which case drawResourceIcons
is called to re-draw the icons) and to handle changes to resoure values when a token's actor is updated. This updated is handled by another new method added to the Token object class: updateResourceIconValues
. This method simply changes the value text child of each PIXI container to the new value of the assigned resource.