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

[Feature Request] New Tidy 5e Sheets Compatibility #28

Open
kgar opened this issue Mar 4, 2024 · 0 comments
Open

[Feature Request] New Tidy 5e Sheets Compatibility #28

kgar opened this issue Mar 4, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@kgar
Copy link

kgar commented Mar 4, 2024

The Sound Effects button is missing from the new Tidy 5e Sheets.
This is a feature request to establish compatibility between our modules.

image

Additional context
Tidy 5e Sheets is a full rewrite of the original module. It runs on the svelte web framework and doesn't trigger the full render hook as often. Also, the HTML structure is subject to change, so I provide my own specific tags and attributes for targeting things. For these reasons, I have provided an API for a variety of tasks, including registering Actor content.

Tidy's API sits cleanly behind a hook, so it does not disturb the regular flow of things and will be silently ignored if the module is turned off. Here is an example of registering sound effect button:

Hooks.once('tidy5e-sheet.ready', (api) => {
  api.registerActorContent(
    new api.models.HtmlContent({
      html: (data) => {
        let soundEffect = getProperty(
          data.actor,
          'flags.monks-sound-enhancements.sound-effect'
        );
        if (!soundEffect) {
          soundEffect = getProperty(
            data.actor,
            'flags.monks-little-details.sound-effect'
          );
          if (soundEffect)
            data.actor.setFlag(
              'monks-sound-enhancements',
              'sound-effect',
              soundEffect
            );
        }

        let hasSound = soundEffect != undefined;

        let button = $('<button>')
          .attr('type', 'button')
          .attr('id', 'mseCharacterSound')
          .toggleClass('loaded', hasSound)
          .html('<i class="fas fa-volume-up"></i>');

        return button.get(0).outerHTML;
      },
      injectParams: {
        selector: `[data-tidy-sheet-part="name-container"]`,
        position: 'beforebegin',
      },
      enabled: (params) =>
        setting('actor-sounds') !== 'none' &&
        (setting('actor-sounds') !== 'npc' || params.actor.type === 'npc'),
      onRender: (params) => {
        params.element
          .querySelector('#mseCharacterSound')
          .addEventListener('click', () =>
            ActorSounds.showDialog.bind(app, 'actor')
          );
      },
    })
  );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant