Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create migration for documents without default icons #32

Closed
crazyclausewitz opened this issue Jan 16, 2022 · 13 comments
Closed

Create migration for documents without default icons #32

crazyclausewitz opened this issue Jan 16, 2022 · 13 comments
Assignees
Labels
data-migration-needed Changes that require a data migration

Comments

@crazyclausewitz
Copy link

I was browsing through my monster list and noticed that most of the ability and weapon icons have been replaced by 'icons/svg/item-bag.svg'. When looking at my actors.db, I can see that these abilities and weapons don't have an 'img' entry. I guess in earlier versions the 'img' entry was only added when the icon had been changed and a default icon was provided for items with empty 'img' entries. Looks like this has been lost along the way.

@engleback
Copy link
Collaborator

The monster list is part of the compendium which is another module I think

@justinthejaguar
Copy link

@anthonyronda
Copy link
Member

It's true that some unused bits of code still reference icons/svg/ image assets, but I don't think they're actually used. There's a separate assets directory that hosts all of the current "default icons."

Have you encountered broken image refs for icons/svg/ ("NOT FOUND" errors)? I'd want to know about that here

@crazyclausewitz
Copy link
Author

crazyclausewitz commented Jan 17, 2022

I build my monster database long before there was a compendium, which is why most of my monsters don't have an img entry. The img entry was introduced fairly late into the codebase and it seems to only get added to the database if the icon is actually changed. Before that, the behavior was to provide default icons for weapons and abilities. But this code has been lost in the editing.
Right now there is no code for handling monsters without an img entry, which is why the foundry default fallback (bag icon) is shown. I have no way of adding the img entry to the database short of changing every single icon for hundreds of monsters.

P.S.:There are no broken image refs. Just the default icon getting displayed, which unfortunately is not the modules default icon(s).

@freohr freohr added bug Something isn't working monster-sheet Related to the monster sheet, but not the inventory tab labels Jan 17, 2022
@engleback
Copy link
Collaborator

Are we maintaining the compendium as well?

@anthonyronda
Copy link
Member

@crazyclausewitz could you tell us the expected behavior you want?

@engleback as Justin referred to above, there's a new repository for the OGL compendium but I have not begun to make changes to it. The last U~man release is still the latest release

@crazyclausewitz
Copy link
Author

If a weapon, ability, armor, spell or item has no 'img' entry add one and set it to the default icon for that category (i.e. systems/ose/assets/default/weapon.png, systems/ose/assets/default/ability.png, systems/ose/assets/default/armor.png, systems/ose/assets/default/spell.png and systems/ose/assets/default/item.png)
Maybe put it into _prepareItem on the actor sheets.

@anthonyronda anthonyronda self-assigned this Feb 8, 2022
@anthonyronda
Copy link
Member

anthonyronda commented Feb 8, 2022

We recommend the following macro for each of your compendiums (contributed by @RabidOwlbear)

edit: see owlbear's comment below

let compendiumName = "YOURCOMPENDIUMNAME";

function defaultIcons() {
  return {
    spell: "systems/ose/assets/default/spell.png",
    ability: "systems/ose/assets/default/ability.png",
    armor: "systems/ose/assets/default/armor.png",
    weapon: "systems/ose/assets/default/weapon.png",
    item: "systems/ose/assets/default/item.png",
    container: "systems/ose/assets/default/bag.png",
  };
}

let pack = game.packs.get(compendiumName);
pack.map((actor) => {
  const items = actor.items;
  items.map(async (item) => {
    if (item.img === null) {
      await item.update({ img: defaultIcons()[item.type] });
    }
  });
});

And the following macro for items on the actors already in your world (run once)

function defaultIcons() {
  return {
    spell: "systems/ose/assets/default/spell.png",
    ability: "systems/ose/assets/default/ability.png",
    armor: "systems/ose/assets/default/armor.png",
    weapon: "systems/ose/assets/default/weapon.png",
    item: "systems/ose/assets/default/item.png",
    container: "systems/ose/assets/default/bag.png",
  };
}

game.actors.map((actor) => {
  const itemsData = actor.data.items;
  itemsData.map(async (item) => {
    if (item.img === null) {
      await item.update( { img: defaultIcons()[item.type] } );
    }
  });
});

These only gives items with missing pictures a new default picture

@RabidOwlbear
Copy link
Collaborator

The compendiumName variable has a minor caveat. If the compendium is a world compendium, as in not one included with a module, the value will be 'world.YOURCOMPENDIUMNAME' otherwise it will be the module name found in the parenthesis below the compendium name like this 'module-name.YOURCOMPENDIUMNAME'

@crazyclausewitz
Copy link
Author

Thanks for the macros! I think they will work for me for now.
But the point I'm making is that you actually need some function to update user compendiums. As soon as the underlying data structures change, everyone with custom assets will again be stranded with outdated and potentially troublesome data structures.

@anthonyronda anthonyronda added data-migration-needed Changes that require a data migration and removed monster-sheet Related to the monster sheet, but not the inventory tab bug Something isn't working labels Mar 14, 2022
@anthonyronda anthonyronda changed the title Old Monster abilities and weapons no longer have a default icon Create migration for documents without default icons Sep 2, 2022
@anthonyronda
Copy link
Member

anthonyronda commented Jan 28, 2023

@bakbakbakbakbak and @wyrmisis regarding our previous discussions about migrations, do actor/token/item img migrations like above also belong in their respective data models?

@bakbakbakbakbak
Copy link
Collaborator

@bakbakbakbakbak and @wyrmisis regarding our previous discussions about migrations, do actor/token/item img migrations like above also belong in their respective data models?

Yes, we can do this migration from the data models for this. I've created a pull request: #322

@anthonyronda
Copy link
Member

Will be in the upcoming 1.8.0 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data-migration-needed Changes that require a data migration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants