farling42 / fvtt-pdf-pager

PDF Pager for Foundry
MIT License
6 stars 4 forks source link

Foundry V12: Replace deprecated functions. #89

Closed farling42 closed 4 months ago

farling42 commented 4 months ago

Use of game.template.Item.types and game.template.Item.types is deprecated in Foundry V12.

The warning in the console is:

Error: Game#template is deprecated and will be removed in Version 14. Use cases for Game#template should be refactored to instead use System#documentTypes or Game#model
Deprecated since Version 12
Backwards-compatible support will be removed in Version 14
    at Object.logCompatibilityWarning (foundry-esm.js:4488:19)
    at get template (foundry.js:10290:19)
    at updateSheets (pdf-actorsheet.mjs:217:29)
    at configureActorSettings (pdf-actorsheet.mjs:257:3)
    at Object.fn (pdf-config.mjs:310:2)
    at #call (foundry.js:733:20)
    at Hooks.callAll (foundry.js:690:17)
    at Game.setupGame (foundry.js:8972:11)
    at async Game._initializeGameView (foundry.js:10257:5)
    at async Game.initialize (foundry.js:8879:5)
farling42 commented 4 months ago

game.model.Actor - includes base in the Simple World Building. game.system.documentTypes.Actor - does not include base in the Simple World Building system.

So we should game.system.documentTypes instead of game.template

farling42 commented 4 months ago

on Foundry V11, game.system.documentTypes.Actor is an array: image

on Foundry V12, game.system.documentTypes.Actor is an object: image

farling42 commented 4 months ago

game.model.actor

Foundry V11: image

Foundry V12: image

farling42 commented 4 months ago

Actor.createDialog gets a list of the character types:

V11:

      const documentName = this.metadata.name;  // Actor
      const types = game.documentTypes[documentName].filter(t => t !== CONST.BASE_DOCUMENT_TYPE);

V12:

      const documentName = this.metadata.name;
      const types = game.documentTypes[documentName].filter(t => t !== CONST.BASE_DOCUMENT_TYPE);
farling42 commented 4 months ago

Implemented in 0.52.3