journal-to-canvas-slideshow/packs/jtcs-utility-macros.db

6 lines
7.2 KiB
Plaintext
Raw Permalink Normal View History

2024-01-28 15:59:53 -06:00
{"name":"Tile Toggle Locked Status","type":"script","author":"FLvo1qb3UkC40yKG","img":"icons/svg/padlock.svg","scope":"global","command":"// originally by Anthony Vadala and Shawn Dibble\n//https://github.com/foundry-vtt-community/macros/blob/main/misc/tile_toggle_locked_status.js\n\n//Simple macro to loop through ALL SELECTED TILES and toggle their locked status.\n//In other words:\n //If an individual tile is unlocked, this macro will lock it.\n //If an individual tile is locked, this macro will unlock it.\n\n const tiles = canvas.background.controlled.length ? canvas.background.controlled : canvas.foreground.controlled;\n const updates = tiles.map(tile => ({ _id: tile.id, locked: !tile.data.locked }));\n canvas.scene.updateEmbeddedDocuments(\"Tile\", updates);","folder":null,"sort":0,"permission":{"default":0,"FLvo1qb3UkC40yKG":3},"flags":{"core":{"sourceId":"Macro.FcmAATox0lTQuPvn"}},"_id":"DO68MDHqstmJJh2S"}
{"name":"Open JTCS-Art-Gallery Config","type":"script","author":"FLvo1qb3UkC40yKG","img":"icons/svg/card-hand.svg","scope":"global","command":"if(!game.JTCSlideshowConfig) game.JTCSlideshowConfig = new SlideshowConfig()\nif(!game.JTCSlideshowConfig.rendered)\n game.JTCSlideshowConfig.render(true)\nelse\n game.JTCSlideshowConfig.bringToTop()","folder":null,"sort":0,"permission":{"default":0,"FLvo1qb3UkC40yKG":3},"flags":{"advanced-macros":{"runAsGM":false},"core":{"sourceId":"Macro.WWxPRiTaL2mg8lql"}},"_id":"RyYAGTXo26QPi6ZB"}
{"name":"Tile Scale Manager","type":"script","author":"FLvo1qb3UkC40yKG","img":"modules/journal-to-canvas-slideshow/assets/contract.svg","scope":"global","command":"(()=>{\n \n let buttonValues = {\n \"scaleLarger\": 2.0,\n \"scaleSmaller\": 0.5\n}\nlet axisValues = [\" \", \"width\", \"height\"]\n\nrenderDialog()\n\n\nfunction processButtonObject(){\n \n return object;\n}\n\nfunction renderDialog(){\n let options= {\n width: 600,\n id: \"JTCS-custom-dialog\",\n classes: [\"dialog-grid-3\"]\n }\n let dialog;\n let object = {}\n for(const key in buttonValues){\n let value = buttonValues[key]\n \n for(const axis of axisValues){\n object[`${key}${axis}`] = {\n label: `x${value} ${axis}`,\n callback: ()=> {\n scaleAndMove(value, axis)\n dialog.render(true)\n \n }\n }\n \n }\n }\n dialog = new Dialog({\n title: 'Tile Controls',\n content: `click the buttons below to scale a tile`,\n buttons: object,\n}, options).render(true);\n}\n\nfunction scaleAndMove(scale, axis){\n game.JTCS.utils.manager.scaleControlledTiles(scale, axis)\n renderDialog()\n}\n \n})();","folder":null,"sort":0,"permission":{"default":0,"FLvo1qb3UkC40yKG":3},"flags":{"core":{"sourceId":"Macro.s2LknTdxNh4N69p4"}},"_id":"UCJcOT7EH8WaUhAE"}
{"name":"Tile Movement Manager","type":"script","author":"FLvo1qb3UkC40yKG","img":"modules/journal-to-canvas-slideshow/assets/multi-directions.svg","scope":"global","command":"(()=>{\n \n let buttonValues = {\n \"moveTiny\": 0.5,\n \"moveSmall\": 1.0,\n \"moveLarge\": 10,\n \"moveHuge\": 20,\n}\nlet directions = [1, -1]\nlet axisValues = [\"x\", \"y\"]\n\nrenderDialog()\n\n\n\n\nfunction renderDialog(){\n let options= {\n width: 600,\n id: \"JTCS-custom-dialog\",\n classes: [\"dialog-grid\"]\n }\n\n let dialog;\n let object = {};\n for(const key in buttonValues){\n for(const axis of axisValues){\n for(const direction of directions){\n let value = buttonValues[key] * direction\n let label = getDirectionName(axis, value) + \" \" + buttonValues[key].toString()\n let directionName = (direction >= 1)\n object[label] = {\n label: label,\n callback: ()=> {\n scaleAndMove(value, axis)\n dialog.render(true)\n \n }\n }\n } \n }\n \n}\n\n dialog = new Dialog({\n title: 'Tile Controls',\n content: `click the buttons below to move a tile`,\n buttons: object,\n }, options).render(true)\n \n}\n\nfunction getDirectionName(axis, amount){\n let directionName = \"\";\n if(axis === \"x\"){\n if(amount < 0){\n directionName = \"left\"\n \n } else{\n \n directionName = \"right\"\n }\n }\n if(axis === \"y\"){\n if( amount < 0){\n directionName = \"up\"\n \n }else{\n directionName = \"down\"\n \n }\n \n \n }\n return directionName;\n \n \n}\n\nfunction scaleAndMove(amount, direction){\n game.JTCS.utils.manager.moveControlledTiles(amount, direction)\n //renderDialog()\n}\n \n})();","folder":null,"sort":0,"permission":{"default":0,"FLvo1qb3UkC40yKG":3},"flags":{"core":{"sourceId":"Macro.gKU43tEiULxIIRVw"}},"_id":"moGBJ148Fro1pbUP"}
{"name":"Fit Tile to Scene","type":"script","author":"FLvo1qb3UkC40yKG","img":"icons/skills/targeting/crosshair-bars-yellow.webp","scope":"global","command":"renderDialog();\n\nfunction renderDialog(){\n //filter out things that aren't tiles\n let viewedScene = game.scenes.viewed;\n let sceneTiles = canvas.background.controlled.filter((obj)=> obj.document.documentName === 'Tile');\n if(sceneTiles.length === 0){\n ui.notifications.warn(\"No tiles selected\");\n return;\n }\n let d = new Dialog({\n title: 'Fit Tile to Scene',\n content: `Along which dimension should the tile fit?`,\n buttons: {\n width: {\n label: 'Width',\n callback: ()=>{fitTo('width')}\n },\n\n height: {\n label: 'Height',\n callback: ()=>{fitTo('height')}\n }, \n both: {\n label: 'Both',\n callback: ()=>{fitTo('both')}\n },\n }\n}).render(true);\n}\n\nfunction fitTo(whichDimension){\n //filter out things that aren't tiles\n let viewedScene = game.scenes.viewed;\n\n let sceneTiles = canvas.background.controlled.filter((obj)=> obj.document.documentName === 'Tile');\n let dimensions = viewedScene.dimensions;\n\n //get array of tile ids for update\n let tileData = sceneTiles.map((tile) => {return{_id: tile.data._id}})\n let updateData = {}\n \n switch (whichDimension) {\n case 'width':\n // code\n updateData.width = dimensions.sceneRect.width;\n break;\n case 'height':\n updateData.height = dimensions.sceneRect.height;\n break;\n case 'both':\n updateData.width = dimensions.sceneWidth;\n updateData.height = dimensions.sceneHeight;\n break;\n }\n tileData = tileData.map((data)=> {return {...data, ...updateData}})\n updateTiles(tileData)\n}\n\nfunction updateTiles(updateData){\n let viewedScene = game.scenes.viewed;\n\n viewedScene.updateEmbeddedDocuments(\"Tile\", updateData);\n}","folder":null,"sort":0,"permission":{"default":0,"xjKGzWFbtOifTl9H":3,"FLvo1qb3UkC40yKG":3},"flags":{"advanced-macros":{"runAsGM":false},"core":{"sourceId":"Macro.KWmUj6RKO4bzYdk8"}},"_id":"wbmIqlU6VPkKlTPP"}