How should we handle mod-added frames into icon "animations"?

So first of all there is existing animation format. Please check it:

Today @hkoehler asked about adding new icons for secondary skills added by mods. Currently for existing skills there is SECSKILL.def that contain 3 frames (basic, advanced and expert) for each existing skill. His initial idea was to add frames into animation dynamically, but it’s seems very ugly and not practical because currently animation can only contain integer identifiers.

From what I see we efficiently have two options how to solve this while keep using CAnimation and CAnimImage for said icons. In both cases we need to allow text identifiers for “frames” and convert existing H3 DEF to decided format.

  1. First option is to just make every modder merge own frames into our newly converted SECSKILL.json just by usual JSON merge. I don’t like this very much because this would mean modders will have additional file to change and mess up.
  2. Another option is to add option to CAnimation so instead of using pre-defined frames list it’s could be configured with path to directory with icons. Then UI will be able to request literally any file in that directory as frame:
iconSecondarySkill->setFrame("core:pathfinding", "advanced");

In the end CAnimation will just load image like /data/vcmi/icons/skills/core:pathfinding/advanced.png. Of course it’s will be preloaded, but you get the point.

Or we might stop using CAnimation for any icons that contents might be modified by mods. Then we don’t need to mess with animation format and possibly this is sanest solution.

See Graphics::initializeImageLists()

2 Likes

Some explanations:

  1. we use CAnimation to store all icons
  2. certain icon (frame) index is implementation detail of Entity,
  3. actual path to icon image is stored in entity configuration (modders should not care about how we deal with icons internally)

Yeah I really never saw this part of the code. Thanks :slight_smile: