Skip to content

Refactor Setup Hook#223

Draft
mclemente wants to merge 3 commits intomainfrom
refactor-setup-hook
Draft

Refactor Setup Hook#223
mclemente wants to merge 3 commits intomainfrom
refactor-setup-hook

Conversation

@mclemente
Copy link
Copy Markdown
Collaborator

@mclemente mclemente commented Jun 18, 2024

Why

  • PbtA's initial hooks are async and this can cause issues.
    • Of note, it can work erratically with Babele's babele.ready hook.
  • There is also a setTimeout(1000) to attempt to await for changes done to the pbtaSheetConfig hook.

What Changed?

  • Refactored the pbtaSheetConfig hook to pbta.sheetConfig for consistency with potential new hooks in the future.
  • Removed the sheetConfigOverride setting.
  • Removed async from ready hook, fixing some weird behavior caused by it.
  • Added warning for when 2+ modules that override sheets are active.

Unrelated Changes

  • Removed async from init hook.
  • Sheet Configuration button on both the sidebar and the settings config window if a module is overriding it.
  • Moved Playbook listing to setup.
How It Worked Before
  • If an override exists and sheetConfigOverride was previously activated, load the override.
  • Otherwise, load the original, if any.
  • PbtA sets the sheetConfigOverride setting to false, calls the pbtaSheetConfig hook and awaits 1 second.
  • If the setting has been turned on, the override is saved.
  • Otherwise, delete any override and restore original config, if any.
  • The config is then saved to settings.
How It Works Now
  • PbtA checks if any module is flagged to override it.
  • If an override exists and a module is flagged to override it, load the override.
  • Otherwise, load the original, if any.
  • PbtA calls the pbta.sheetConfig hook.
  • If a module exists, the override is saved.
  • Otherwise, delete any override and restore original config, if any.
  • The config is then saved to settings.

What Modules Need to Change

Remove the game.settings.set('pbta', 'sheetConfigOverride', true) call that is somewhere in the code.

On module.json, add:

"flags": {
  "MODULE_ID": {
    "pbta-override": true
  }
}

@mclemente mclemente marked this pull request as draft June 18, 2024 00:44
@mclemente mclemente force-pushed the refactor-setup-hook branch from dbf0354 to f1a5165 Compare June 18, 2024 01:07
@mclemente mclemente force-pushed the refactor-setup-hook branch from 9e8aa89 to b78b50e Compare June 18, 2024 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant