Carpathias / tgce-restyler-5e3

Restyler for DnD5e 3.0
Other
4 stars 0 forks source link

[Feature request] Copy/Paste Layout #7

Closed Garg80 closed 4 months ago

Garg80 commented 4 months ago

So I guess this is a little counter to what you've done, but is there a way to make it so I don't have to edit each sheet, and can just paste a default format?

Carpathias commented 4 months ago

that is in the works. I plan on having an export to JSON option, so you can export from one VTT and import into another for players that play in multiple games. And also thinking of having a "copy from Actor" option, where you could select another actor you own and copy the config. I think initially I can probably accomplish both of those ideas with macros. I'll keep you posted. Might be a week or two. I have burned much of my fuel in getting 2.0 to this point, need a little break.

Carpathias commented 4 months ago

For now, I have written a macro that will copy the Flag data from one actor to another. Macro is below the line.

  1. Select two tokens. First token selected will be the 'source', second will be the 'target'.
  2. Run macro.

Let me know if you have any issues. -Carp


/* TGCE-RESTYLER-5E3 | MACRO | Copy Restyler Config to Actor

Instructions
1.  Clear any existing Restyler config found on target actor.   
        The Target actor should have no Restyler config. If the target actor does have an existing config
        use the Restyler UI to clear the target actor to deafults before hand.
2.  De-select all selected Tokens. 
3.  Select the 'source' token first.
        This is the token for the actor that has the Restyler config to be copied. 
4.  Select the 'target' token second.
        This is the token for the actor that will recieve the source token's Restyler config. 
        Note: Hold down the 'shift' when clicking the second token, so two tokens are selected. 
5.  Run this macro.

*/

if (canvas.tokens.controlled.length !== 2){ console.log('TGCE-RESTYLER-5E3 | MACRO | Please select two, and only two, tokens...'); ui.notifications.warn('TGCE-RESTYLER-5E3 | MACRO | Please select two, and only two, tokens... The first token selected will be the source.'); return; }

const [sourceActor, targetActor] = canvas.tokens.controlled const sourceActorData = game.actors.get(sourceActor.document.actorId) const targetActorData = game.actors.get(targetActor.document.actorId) const sourceElementFlags = sourceActorData.getFlag('tgce-restyler-5e3', 'elements') const sourceCssTextFlags = sourceActorData.getFlag('tgce-restyler-5e3', 'cssText')

console.log(TGCE-RESTYLER-5E3 | MACRO | Clearing existing flags on target:${targetActor.document.actorId}) ui.notifications.info(TGCE-RESTYLER-5E3 | MACRO | Clearing existing flags on target:${targetActor.document.actorId}); targetActorData.unsetFlag('tgce-restyler-5e3','elements') targetActorData.unsetFlag('tgce-restyler-5e3','cssText')

console.log(TGCE-RESTYLER-5E3 | MACRO | Copying Flags from actor:${sourceActor.document.actorId} to actor:${targetActor.document.actorID}); ui.notifications.info(TGCE-RESTYLER-5E3 | MACRO | Copying Flags from actor:${sourceActor.document.actorId} to actor:${targetActor.document.actorID}); Object.entries(sourceElementFlags).forEach(([key, value]) => { targetActorData.setFlag('tgce-restyler-5e3', elements.${key}, value) }) Object.entries(sourceCssTextFlags).forEach(([key, value]) => { targetActorData.setFlag('tgce-restyler-5e3', cssText.${key.replace(sourceActor.document.actorId,targetActor.document.actorId)}, value) })

console.log(TGCE-RESTYLER-5E3 | MACRO | Completed. You may need to reload the game to clear any existing CSS for the target actor, if it had an existing Restyler config.); ui.notifications.info(TGCE-RESTYLER-5E3 | MACRO | Completed. You may need to reload the game to clear any existing CSS for the target actor, if it had an existing Restyler config.);

Carpathias commented 4 months ago

Macro can also be found here https://github.com/Carpathias/tgce-restyler-5e3/blob/main/macros/Restyler.Macro.CopyConfigToActor.js

Carpathias commented 4 months ago

v2.0.03 was released and includes a macro compendium. The Copy Flags to Actor macro will copy the module flags (css info) stored on a Restyler configured actor to another (non-configured) actor. Instructions are in the macro comments.