From 4256e793a22611864c6b3eed6ebf042fdee48cc9 Mon Sep 17 00:00:00 2001 From: kckaiwei Date: Wed, 20 Jan 2021 20:33:21 -0500 Subject: [PATCH] [RELEASE] Updating manifest/changelogs --- CHANGELOG.md | 3 +++ dist/module.json | 6 +++--- dist/scripts/turnmarker.js | 2 +- dist/templates/updateWindow.html | 12 ++++++++---- src/module.json | 6 +++--- src/templates/updateWindow.html | 12 ++++++++---- 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20d5ca3..d91c52a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.7.3 +- Fixed deletion permissions in different scenes issue + # 2.7.2 - Fixed marker in wrong location after reloading - Fixed marker not pausing with game diff --git a/dist/module.json b/dist/module.json index d9561e8..249dd03 100644 --- a/dist/module.json +++ b/dist/module.json @@ -3,7 +3,7 @@ "title": "Turn Marker", "description": "Displays a (optionally animated) marker on the token who's active turn it is. Originally by Brunhine", "author": "kckaiwei", - "version": "2.7.2", + "version": "2.7.3", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.9", "manifestPlusVersion": "1.0.0", @@ -51,6 +51,6 @@ } ], "url": "https://github.com/kckaiwei/TurnMarker-alt", - "manifest": "https://raw.githubusercontent.com/kckaiwei/TurnMarker-alt/main/dist/module.json", - "download": "https://github.com/kckaiwei/TurnMarker-alt/releases/download/v2.7.2/turnmarker.zip" + "manifest": "https://raw.githubusercontent.com/kckaiwei/TurnMarker-alt/v2.7.3/src/module.json", + "download": "https://github.com/kckaiwei/TurnMarker-alt/releases/download/v2.7.3/turnmarker.zip" } \ No newline at end of file diff --git a/dist/scripts/turnmarker.js b/dist/scripts/turnmarker.js index 23600fa..d1f481c 100644 --- a/dist/scripts/turnmarker.js +++ b/dist/scripts/turnmarker.js @@ -1,3 +1,3 @@ /*! For license information please see turnmarker.js.LICENSE.txt */ -(()=>{"use strict";var e={"./src/scripts/chatter.js":(e,t,a)=>{a.r(t),a.d(t,{Chatter:()=>n});var s=a("./src/scripts/settings.js");class n{static sendTurnMessage(e,t=!1){let a=[];e.players.forEach((e=>{a.push(e.name)})),0==a.length&&a.push("GM");let n=e.actor.name,r=n;s.Settings.getAnnounceTokenName()&&(n=e.token.name,r=e.name),t&&!e.actor.hasPlayerOwner&&(n="???"),ChatMessage.create({speaker:{actor:e.actor,alias:r},content:`
${this.placeImage(e)}\n
\n

${n}'s Turn

\n

${a.join(" - ")}

\n
\n
Turn Marker`})}static placeImage(e){if(s.Settings.getIncludeAnnounceImage()){let t=e.img;return e.flags.core&&e.flags.core.thumb&&(t=e.flags.core.thumb),`
`}return""}}},"./src/scripts/marker.js":(e,t,a)=>{a.r(t),a.d(t,{Marker:()=>i});var s=a("./src/scripts/markeranimation.js"),n=a("./src/scripts/settings.js"),r=a("./src/scripts/utils.js");class i{static async deleteTurnMarker(){const e=canvas.scene.getEmbeddedCollection("Tile").filter((e=>e.flags.turnMarker)).map((e=>e._id));await canvas.scene.deleteEmbeddedEntity("Tile",e)}static async placeTurnMarker(e,t){if(t)return await this.moveMarkerToToken(e,t),t;if(await this.deleteTurnMarker(),n.Settings.getTurnMarkerEnabled()){let t=(0,r.findTokenById)(e),a=(n.Settings.getRatio(),this.getImageDimensions(t)),s=this.getImageLocation(t),i=new Tile({img:n.Settings.getImagePath(),width:a.w,height:a.h,x:s.x,y:s.y,z:900,rotation:0,hidden:t.data.hidden,locked:!1,flags:{turnMarker:!0}});return(await canvas.scene.createEmbeddedEntity("Tile",i.data))._id}return null}static async deleteStartMarker(){const e=canvas.scene.getEmbeddedCollection("Tile").filter((e=>e.flags.startMarker)).map((e=>e._id));await canvas.scene.deleteEmbeddedEntity("Tile",e),await canvas.scene.unsetFlag(r.FlagScope,r.Flags.startMarkerPlaced)}static async placeStartMarker(e){if(await this.deleteStartMarker(),n.Settings.getStartMarkerEnabled()){let t=(0,r.findTokenById)(e),a=this.getImageDimensions(t),s=this.getImageLocation(t),i=new Tile({img:n.Settings.getStartMarker(),width:a.w,height:a.h,x:s.x,y:s.y,z:900,rotation:0,hidden:t.data.hidden,locked:!1,flags:{startMarker:!0}});game.user.isGM&&(await canvas.scene.createEmbeddedEntity("Tile",i.data),await canvas.scene.setFlag(r.FlagScope,r.Flags.startMarkerPlaced,!0))}}static async moveMarkerToToken(e,t){let a=(0,r.findTokenById)(e),s=(n.Settings.getRatio(),this.getImageDimensions(a)),i=this.getImageLocation(a);await canvas.scene.updateEmbeddedEntity("Tile",{_id:t,width:s.w,height:s.h,x:i.x,y:i.y,hidden:a.data.hidden})}static async clearAllMarkers(){await this.deleteTurnMarker(),await this.deleteStartMarker()}static async updateImagePath(){if(game.user.isGM){let e=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));e&&await canvas.scene.updateEmbeddedEntity("Tile",{_id:e.id,img:n.Settings.getImagePath()})}}static async reset(){s.MarkerAnimation.stopAnimation(),await this.clearAllMarkers()}static getImageDimensions(e,t=!1){let a=t?1:n.Settings.getRatio(),s=0,r=0;switch(canvas.grid.type){case 2:case 3:s=r=e.h*a;break;case 4:case 5:s=r=e.w*a;break;default:s=e.w*a,r=e.h*a}return{w:s,h:r}}static getImageLocation(e,t=!1){let a=t?1:n.Settings.getRatio(),s=0,r=0;switch(canvas.grid.type){case 2:case 3:s=e.center.x-e.h*a/2,r=e.center.y-e.h*a/2;break;case 4:case 5:s=e.center.x-e.w*a/2,r=e.center.y-e.w*a/2;break;default:s=e.center.x-e.w*a/2,r=e.center.y-e.h*a/2}return{x:s,y:r}}}},"./src/scripts/markeranimation.js":(e,t,a)=>{a.r(t),a.d(t,{MarkerAnimation:()=>n});var s=a("./src/scripts/settings.js");class n{static startAnimation(){return this.animator||(this.animator=this.animateRotation.bind(this),canvas.app.ticker.add(this.animator)),this.animator}static stopAnimation(){this.animator&&(canvas.app.ticker.remove(this.animator),delete this.animator)}static animateRotation(e){let t=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));if(t&&t.data.img){let a=s.Settings.getInterval()/1e4;try{t.tile.img.rotation+=a*e}catch(e){}}}}},"./src/scripts/settings.js":(e,t,a)=>{a.r(t),a.d(t,{imageTitles:()=>v,announcedActorOptions:()=>y,Settings:()=>S});var s=a("./src/scripts/marker.js"),n=a("./src/scripts/markeranimation.js"),r=a("./src/scripts/settingsForm.js"),i=a("./src/scripts/utils.js");const o="tm-version",m="ratio",g="animation",c="interval",d="announce-turn",l="announce-Actors",u="announce-image",h="announce-token",k="image",p="customimage",f="turnmarker-enabled",b="startMarker-enabled",M="startMarker-custom",v=["Runes of Incendium by Rin","Runes of the Cultist by Rin","Runes of Regeneration by Rin","Runes of the Cosmos by Rin","Runes of Earthly Dust by Rin","Runes of Reality by Rin","Runes of the Believer by Rin","Runes of the Mad Mage by Rin","Runes of the Blue Sky by Rin","Runes of the Universe by Rin","Runes of Prosperity by Rin"],y=["Announce for all","Announce for players","Announce for GM-controlled","Announce all but hide GM-controlled names"];class S{static getVersion(){return game.settings.get(i.modName,o)}static setVersion(e){game.settings.set(i.modName,o,e)}static getRatio(){return game.settings.get(i.modName,m)}static setRatio(e){game.settings.set(i.modName,m,e)}static getShouldAnimate(){return game.settings.get(i.modName,g)}static getInterval(){return game.settings.get(i.modName,c)}static shouldAnnounceTurns(){return game.settings.get(i.modName,d)}static setShouldAnnounceTurns(e){game.settings.set(i.modName,d,e)}static getAnnounceActors(){return game.settings.get(i.modName,l)}static setAnnounceActors(e){return game.settings.set(i.modName,l,e)}static getAnnounceTokenName(){return game.settings.get(i.modName,h)}static setAnnounceTokenName(e){return game.settings.set(i.modName,h,e)}static getIncludeAnnounceImage(){return game.settings.get(i.modName,u)}static setIncludeAnnounceImage(e){game.settings.set(i.modName,u,e)}static getImageIndex(){return game.settings.get(i.modName,k)}static getStartMarker(){return""==game.settings.get(i.modName,M).trim()?"modules/turnmarker/assets/start.png":game.settings.get(i.modName,M)}static getTurnMarkerEnabled(){return game.settings.get(i.modName,f)}static setTurnMarkerEnabled(e){game.settings.set(i.modName,f,e)}static getStartMarkerEnabled(){return game.settings.get(i.modName,b)}static setStartMarkerEnabled(e){game.settings.set(i.modName,b,e)}static getStartMarkerPath(){return game.settings.get(i.modName,M)}static setStartMarkerPath(e){game.settings.set(i.modName,M,e)}static getImagePath(){return""==game.settings.get(i.modName,p).trim()?this.getImageByIndex(game.settings.get(i.modName,k)):game.settings.get(i.modName,p)}static getImageByIndex(e){switch(e){case 0:return"modules/turnmarker/assets/incendium.png";case 1:return"modules/turnmarker/assets/cultist.png";case 2:return"modules/turnmarker/assets/regeneration.png";case 3:return"modules/turnmarker/assets/cosmos.png";case 4:return"modules/turnmarker/assets/earthlydust.png";case 5:return"modules/turnmarker/assets/reality.png";case 6:return"modules/turnmarker/assets/believer.png";case 7:return"modules/turnmarker/assets/madmage.png";case 8:return"modules/turnmarker/assets/bluesky.png";case 9:return"modules/turnmarker/assets/universe.png";case 10:return"modules/turnmarker/assets/prosperity.png"}}static setImage(e){game.settings.set(i.modName,k,e)}static getCustomImagePath(){return game.settings.get(i.modName,p)}static setCustomImagePath(e){game.settings.set(i.modName,p,e)}static registerSettings(){game.settings.registerMenu(i.modName,"tm.settingsMenu",{name:"tm.settings.button.name",label:"tm.settings.button.label",icon:"fas fa-sync-alt",type:r.SettingsForm,restricted:!0}),game.settings.register(i.modName,o,{name:`${i.modName} version`,default:"0.0.0",type:String,scope:"world"}),game.settings.register(i.modName,m,{name:"tm.settings.ratio.name",hint:"tm.settings.ratio.hint",scope:"world",config:!1,type:Number,default:1.5,restricted:!0}),game.settings.register(i.modName,g,{name:"tm.settings.animate.name",hint:"tm.settings.animate.hint",scope:"user",config:!0,type:Boolean,default:!0,onChange:e=>{!game.paused&&e&&canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker))?n.MarkerAnimation.startAnimation():n.MarkerAnimation.stopAnimation()}}),game.settings.register(i.modName,c,{name:"tm.settings.interval.name",hint:"tm.settings.interval.hint",scope:"user",config:!0,type:Number,default:100}),game.settings.register(i.modName,k,{name:"tm.settings.image.name",scope:"world",config:!1,type:Number,default:0,choices:v,restricted:!0,onChange:e=>s.Marker.updateImagePath(e)}),game.settings.register(i.modName,l,{name:"tm.settings.announcedActors.name",hint:"tm.settings.announcedActors.hint",scope:"world",config:!1,type:Number,default:0,restricted:!0,choices:y}),game.settings.register(i.modName,h,{name:"tm.settings.announceTokenName.name",hint:"tm.settings.announceTokenName.hint",scope:"world",config:!1,type:Boolean,default:!1,restricted:!0}),game.settings.register(i.modName,p,{name:"tm.settings.customImage.name",hint:"tm.settings.customImage.hint",scope:"world",config:!1,type:String,default:"",restricted:!0,onChange:e=>s.Marker.updateImagePath(e)}),game.settings.register(i.modName,d,{name:"tm.settings.announce.name",hint:"tm.settings.announce.hint",scope:"world",config:!1,type:Boolean,default:!0}),game.settings.register(i.modName,u,{name:"tm.settings.announceImage.name",hint:"tm.settings.announceImage.hint",scope:"world",config:!1,type:Boolean,default:!0}),game.settings.register(i.modName,"announce-asActor",{name:"tm.settings.announceAs.name",hint:"tm.settings.announceAs.hint",scope:"world",config:!1,type:Boolean,default:!0}),game.settings.register(i.modName,f,{name:"tm.settings.turnMarkerEnabled.name",hint:"tm.settings.turnMarkerEnabled.hint",scope:"world",config:!1,type:Boolean,default:!0,restricted:!0,onChange:e=>{e?game.combat&&game.combat.combatant&&game.combat.started&&s.Marker.placeTurnMarker(game.combat.combatant.token._id):s.Marker.deleteTurnMarker()}}),game.settings.register(i.modName,b,{name:"tm.settings.startEnabled.name",hint:"tm.settings.startEnabled.hint",scope:"world",config:!1,type:Boolean,default:!1,restricted:!0,onChange:e=>{e?game.combat&&game.combat.combatant&&game.combat.started&&s.Marker.placeStartMarker(game.combat.combatant.token._id):s.Marker.deleteStartMarker()}}),game.settings.register(i.modName,M,{name:"tm.settings.startImage.name",hint:"tm.settings.startImage.hint",scope:"world",config:!1,type:String,default:"",restricted:!0})}}},"./src/scripts/settingsForm.js":(e,t,a)=>{a.r(t),a.d(t,{SettingsForm:()=>r});var s=a("./src/scripts/settings.js");const n=["mp4","webm","ogg"];class r extends FormApplication{constructor(e,t={}){super(e,t)}static get defaultOptions(){return mergeObject(super.defaultOptions,{id:"turnmarker-settings-form",title:"Turn Marker - Global Settings",template:"./modules/turnmarker/templates/settings.html",classes:["sheet","tm-settings"],width:500,closeOnSubmit:!0})}getData(){return{turnMarkerEnabled:s.Settings.getTurnMarkerEnabled(),ratio:s.Settings.getRatio(),image:this.getSelectList(s.imageTitles,s.Settings.getImageIndex()),announceActors:this.getSelectList(s.announcedActorOptions,s.Settings.getAnnounceActors()),customImage:s.Settings.getCustomImagePath(),announce:s.Settings.shouldAnnounceTurns(),announceImage:s.Settings.getIncludeAnnounceImage(),announceTokenName:s.Settings.getAnnounceTokenName(),startMarkerEnabled:s.Settings.getStartMarkerEnabled(),startMarkerPath:s.Settings.getStartMarkerPath(),previewPath:s.Settings.getImagePath()}}async _updateObject(e,t){console.log("Turn Marker | Saving Settings"),s.Settings.setRatio(t.ratio),t.image&&s.Settings.setImage(t.image),s.Settings.setCustomImagePath(t.customImage),s.Settings.setShouldAnnounceTurns(t.announce),s.Settings.setAnnounceActors(t.announceActors),s.Settings.setIncludeAnnounceImage(t.announceImage),s.Settings.setAnnounceTokenName(t.announceTokenName),s.Settings.setTurnMarkerEnabled(t.turnMarkerEnabled),s.Settings.setStartMarkerEnabled(t.startMarkerEnabled),s.Settings.setStartMarkerPath(t.startMarkerPath)}activateListeners(e){super.activateListeners(e);const t=e.find("#image"),a=e.find("#customImage"),n=e.find("#markerImgPreview");this.updatePreview(e),t.length>0&&t.on("change",(e=>{""==a[0].value.trim()&&n.attr("src",s.Settings.getImageByIndex(Number(e.target.value)))})),a.length>0&&a.on("change",(t=>{this.updatePreview(e)}))}updatePreview(e){const t=e.find("#image"),a=e.find("#customImage"),r=e.find("#markerImgPreview"),i=e.find("#markerVideoPreview");if(""==a[0].value.trim())t[0].disabled=!1,r.attr("src",s.Settings.getImageByIndex(Number(t[0].value))),r.removeClass("hidden"),i.addClass("hidden");else{t[0].disabled=!0;const e=this.getExtension(a[0].value);console.warn(e),n.includes(e.toLowerCase())?(i.attr("src",a[0].value),r.addClass("hidden"),i.removeClass("hidden")):(r.attr("src",a[0].value),r.removeClass("hidden"),i.addClass("hidden"))}}getExtension(e){return e.slice(2+(e.lastIndexOf(".")-1>>>0))}getSelectList(e,t){let a=[];return e.forEach(((e,s)=>{a.push({value:e,selected:s==t})})),a}}},"./src/scripts/turnmarker.js":(e,t,a)=>{a.r(t);var s=a("./src/scripts/chatter.js"),n=a("./src/scripts/marker.js"),r=a("./src/scripts/markeranimation.js"),i=a("./src/scripts/settings.js"),o=a("./src/scripts/updateWindow.js"),m=a("./src/scripts/utils.js");let g="";function c(e){if(e.data.hidden)return game.user.isGM;if(!canvas.sight.tokenVision)return!0;if(e._controlled)return!0;const t=canvas.tokens.placeables.find((e=>e.id===game.combat.combatant.tokenId));if(!t||t.data.hidden)return game.user.isGM;if(t._controlled)return!0;const a=i.Settings.getRatio(),s=e.data.width/a,n=e.data.height/a,r=Math.min(s,n)/4;return canvas.sight.testVisibility(e.center,{tolerance:r,object:e})}Hooks.once("init",(()=>{i.Settings.registerSettings()})),Hooks.once("ready",(()=>{game.user.isGM&&isNewerVersion(game.modules.get("turnmarker").data.version,i.Settings.getVersion())&&(0,o.renderUpdateWindow)()})),Hooks.on("canvasReady",(()=>{let e=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));e&&(e.zIndex=Math.max(...canvas.tiles.placeables.map((e=>e.zIndex)))+1,e.parent.sortChildren(),!game.paused&&i.Settings.getShouldAnimate()&&r.MarkerAnimation.startAnimation())})),Hooks.on("createTile",((e,t)=>{if(1==t.flags.turnMarker||1==t.flags.startMarker){const e=canvas.tiles.placeables.find((e=>e.id===t._id));e&&(1==t.flags.turnMarker&&(e.zIndex=Math.max(...canvas.tiles.placeables.map((e=>e.zIndex)))+1,e.parent.sortChildren(),!game.paused&&i.Settings.getShouldAnimate()&&r.MarkerAnimation.startAnimation()),e.renderable=c(e))}})),Hooks.on("updateCombat",(async(e,t)=>{if(e.started||await n.Marker.deleteStartMarker(),e.combatant&&t&&g!=e.combatant._id&&game.user.isGM&&game.userId==(0,m.firstGM)()&&(g=e.combatant._id,e&&e.combatant&&e.started)){await n.Marker.placeStartMarker(e.combatant.token._id);let t=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));if(await n.Marker.placeTurnMarker(e.combatant.token._id,t&&t.id||void 0),i.Settings.shouldAnnounceTurns()&&!e.combatant.hidden)switch(i.Settings.getAnnounceActors()){case 0:s.Chatter.sendTurnMessage(e.combatant);break;case 1:e.combatant.actor.hasPlayerOwner&&s.Chatter.sendTurnMessage(e.combatant);break;case 2:e.combatant.actor.hasPlayerOwner||s.Chatter.sendTurnMessage(e.combatant);break;case 3:s.Chatter.sendTurnMessage(e.combatant,!0)}}})),Hooks.on("deleteCombat",(async()=>{game.user.isGM&&await n.Marker.clearAllMarkers(),r.MarkerAnimation.stopAnimation()})),Hooks.on("updateToken",(async(e,t,a)=>{let s=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));s&&(a.x||a.y||a.width||a.height||a.hidden)&&game&&game.combat&&game.combat.combatant&&game.combat.combatant.tokenId==t._id&&game.user.isGM&&game.combat&&(await n.Marker.moveMarkerToToken(t._id,s.id),s.zIndex=Math.max(...canvas.tiles.placeables.map((e=>e.zIndex)))+1,s.parent.sortChildren())})),Hooks.on("updateTile",((e,t,a,s)=>{if(t.flags.turnMarker||t.flags.startMarker){const e=canvas.tiles.placeables.find((e=>e.id===t._id));e&&(e.renderable=c(e))}})),Hooks.on("sightRefresh",(()=>{for(const e of canvas.tiles.placeables)(e.data.flags.turnMarker||e.data.flags.startMarker)&&(e.renderable=c(e))})),Hooks.on("pauseGame",(e=>{!e&&i.Settings.getShouldAnimate()&&canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker))?r.MarkerAnimation.startAnimation():r.MarkerAnimation.stopAnimation()}))},"./src/scripts/updateWindow.js":(e,t,a)=>{a.r(t),a.d(t,{renderUpdateWindow:()=>n});var s=a("./src/scripts/settings.js");function n(){const e=game.modules.get("turnmarker");if(isNewerVersion(e.data.version,s.Settings.getVersion())){class t extends Application{static get defaultOptions(){return mergeObject(super.defaultOptions,{template:`modules/${e.id}/templates/updateWindow.html`,resizable:!1,width:500,height:600,classes:["updateWindow"],title:`${e.data.title} - Updated`})}getData(){return{version:e.data.version}}activateListeners(t){super.activateListeners(t),t.find(".show-again").on("change",(t=>{s.Settings.setVersion(t.currentTarget.checked?e.data.version:oldVersion)}))}}(new t).render(!0)}}},"./src/scripts/utils.js":(e,t,a)=>{a.r(t),a.d(t,{modName:()=>s,FlagScope:()=>n,Flags:()=>r,socketName:()=>i,socketAction:()=>o,findTokenById:()=>m,firstGM:()=>g});const s="turnmarker",n="turnmarker",r={startMarkerPlaced:"startMarkerPlaced"},i="module.turnmarker",o={placeStartMarker:0};function m(e){return canvas.tokens.ownedTokens.find((t=>t.id==e))}function g(){for(let e of game.users.entities)if(e.data.role>=4&&e.active)return e.data._id}}},t={};function a(s){if(t[s])return t[s].exports;var n=t[s]={exports:{}};return e[s](n,n.exports,a),n.exports}a.d=(e,t)=>{for(var s in t)a.o(t,s)&&!a.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a("./src/scripts/turnmarker.js")})(); +(()=>{"use strict";var e={"./src/scripts/chatter.js":(e,t,a)=>{a.r(t),a.d(t,{Chatter:()=>n});var s=a("./src/scripts/settings.js");class n{static sendTurnMessage(e,t=!1){let a=[];e.players.forEach((e=>{a.push(e.name)})),0==a.length&&a.push("GM");let n=e.actor.name,r=n;s.Settings.getAnnounceTokenName()&&(n=e.token.name,r=e.name),t&&!e.actor.hasPlayerOwner&&(n="???"),ChatMessage.create({speaker:{actor:e.actor,alias:r},content:`
${this.placeImage(e)}\n
\n

${n}'s Turn

\n

${a.join(" - ")}

\n
\n
Turn Marker`})}static placeImage(e){if(s.Settings.getIncludeAnnounceImage()){let t=e.img;return e.flags.core&&e.flags.core.thumb&&(t=e.flags.core.thumb),`
`}return""}}},"./src/scripts/marker.js":(e,t,a)=>{a.r(t),a.d(t,{Marker:()=>i});var s=a("./src/scripts/markeranimation.js"),n=a("./src/scripts/settings.js"),r=a("./src/scripts/utils.js");class i{static async deleteTurnMarker(){const e=canvas.scene.getEmbeddedCollection("Tile").filter((e=>e.flags.turnMarker)).map((e=>e._id));game.user.isGM?await canvas.scene.deleteEmbeddedEntity("Tile",e):game.socket.emit(r.socketName,{mode:r.socketAction.deleteTurnMarker,tileData:e.data})}static async placeTurnMarker(e,t){if(t)return await this.moveMarkerToToken(e,t),t;if(await this.deleteTurnMarker(),n.Settings.getTurnMarkerEnabled()){let t=(0,r.findTokenById)(e),a=(n.Settings.getRatio(),this.getImageDimensions(t)),s=this.getImageLocation(t),i=new Tile({img:n.Settings.getImagePath(),width:a.w,height:a.h,x:s.x,y:s.y,z:900,rotation:0,hidden:t.data.hidden,locked:!1,flags:{turnMarker:!0}});return(await canvas.scene.createEmbeddedEntity("Tile",i.data))._id}return null}static async deleteStartMarker(){const e=canvas.scene.getEmbeddedCollection("Tile").filter((e=>e.flags.startMarker)).map((e=>e._id));game.user.isGM?(await canvas.scene.unsetFlag(r.FlagScope,r.Flags.startMarkerPlaced),await canvas.scene.deleteEmbeddedEntity("Tile",e)):game.socket.emit(r.socketName,{mode:r.socketAction.deleteStartMarker,tileData:e.data})}static async placeStartMarker(e){if(await this.deleteStartMarker(),n.Settings.getStartMarkerEnabled()){let t=(0,r.findTokenById)(e),a=this.getImageDimensions(t),s=this.getImageLocation(t),i=new Tile({img:n.Settings.getStartMarker(),width:a.w,height:a.h,x:s.x,y:s.y,z:900,rotation:0,hidden:t.data.hidden,locked:!1,flags:{startMarker:!0}});game.user.isGM&&(await canvas.scene.createEmbeddedEntity("Tile",i.data),await canvas.scene.setFlag(r.FlagScope,r.Flags.startMarkerPlaced,!0))}}static async moveMarkerToToken(e,t){let a=(0,r.findTokenById)(e),s=(n.Settings.getRatio(),this.getImageDimensions(a)),i=this.getImageLocation(a);await canvas.scene.updateEmbeddedEntity("Tile",{_id:t,width:s.w,height:s.h,x:i.x,y:i.y,hidden:a.data.hidden})}static async clearAllMarkers(){await this.deleteTurnMarker(),await this.deleteStartMarker()}static async updateImagePath(){if(game.user.isGM){let e=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));e&&await canvas.scene.updateEmbeddedEntity("Tile",{_id:e.id,img:n.Settings.getImagePath()})}}static async reset(){s.MarkerAnimation.stopAnimation(),await this.clearAllMarkers()}static getImageDimensions(e,t=!1){let a=t?1:n.Settings.getRatio(),s=0,r=0;switch(canvas.grid.type){case 2:case 3:s=r=e.h*a;break;case 4:case 5:s=r=e.w*a;break;default:s=e.w*a,r=e.h*a}return{w:s,h:r}}static getImageLocation(e,t=!1){let a=t?1:n.Settings.getRatio(),s=0,r=0;switch(canvas.grid.type){case 2:case 3:s=e.center.x-e.h*a/2,r=e.center.y-e.h*a/2;break;case 4:case 5:s=e.center.x-e.w*a/2,r=e.center.y-e.w*a/2;break;default:s=e.center.x-e.w*a/2,r=e.center.y-e.h*a/2}return{x:s,y:r}}}},"./src/scripts/markeranimation.js":(e,t,a)=>{a.r(t),a.d(t,{MarkerAnimation:()=>n});var s=a("./src/scripts/settings.js");class n{static startAnimation(){return this.animator||(this.animator=this.animateRotation.bind(this),canvas.app.ticker.add(this.animator)),this.animator}static stopAnimation(){this.animator&&(canvas.app.ticker.remove(this.animator),delete this.animator)}static animateRotation(e){let t=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));if(t&&t.data.img){let a=s.Settings.getInterval()/1e4;try{t.tile.img.rotation+=a*e}catch(e){}}}}},"./src/scripts/settings.js":(e,t,a)=>{a.r(t),a.d(t,{imageTitles:()=>v,announcedActorOptions:()=>y,Settings:()=>S});var s=a("./src/scripts/marker.js"),n=a("./src/scripts/markeranimation.js"),r=a("./src/scripts/settingsForm.js"),i=a("./src/scripts/utils.js");const o="tm-version",m="ratio",c="animation",g="interval",d="announce-turn",l="announce-Actors",u="announce-image",k="announce-token",h="image",p="customimage",f="turnmarker-enabled",b="startMarker-enabled",M="startMarker-custom",v=["Runes of Incendium by Rin","Runes of the Cultist by Rin","Runes of Regeneration by Rin","Runes of the Cosmos by Rin","Runes of Earthly Dust by Rin","Runes of Reality by Rin","Runes of the Believer by Rin","Runes of the Mad Mage by Rin","Runes of the Blue Sky by Rin","Runes of the Universe by Rin","Runes of Prosperity by Rin"],y=["Announce for all","Announce for players","Announce for GM-controlled","Announce all but hide GM-controlled names"];class S{static getVersion(){return game.settings.get(i.modName,o)}static setVersion(e){game.settings.set(i.modName,o,e)}static getRatio(){return game.settings.get(i.modName,m)}static setRatio(e){game.settings.set(i.modName,m,e)}static getShouldAnimate(){return game.settings.get(i.modName,c)}static getInterval(){return game.settings.get(i.modName,g)}static shouldAnnounceTurns(){return game.settings.get(i.modName,d)}static setShouldAnnounceTurns(e){game.settings.set(i.modName,d,e)}static getAnnounceActors(){return game.settings.get(i.modName,l)}static setAnnounceActors(e){return game.settings.set(i.modName,l,e)}static getAnnounceTokenName(){return game.settings.get(i.modName,k)}static setAnnounceTokenName(e){return game.settings.set(i.modName,k,e)}static getIncludeAnnounceImage(){return game.settings.get(i.modName,u)}static setIncludeAnnounceImage(e){game.settings.set(i.modName,u,e)}static getImageIndex(){return game.settings.get(i.modName,h)}static getStartMarker(){return""==game.settings.get(i.modName,M).trim()?"modules/turnmarker/assets/start.png":game.settings.get(i.modName,M)}static getTurnMarkerEnabled(){return game.settings.get(i.modName,f)}static setTurnMarkerEnabled(e){game.settings.set(i.modName,f,e)}static getStartMarkerEnabled(){return game.settings.get(i.modName,b)}static setStartMarkerEnabled(e){game.settings.set(i.modName,b,e)}static getStartMarkerPath(){return game.settings.get(i.modName,M)}static setStartMarkerPath(e){game.settings.set(i.modName,M,e)}static getImagePath(){return""==game.settings.get(i.modName,p).trim()?this.getImageByIndex(game.settings.get(i.modName,h)):game.settings.get(i.modName,p)}static getImageByIndex(e){switch(e){case 0:return"modules/turnmarker/assets/incendium.png";case 1:return"modules/turnmarker/assets/cultist.png";case 2:return"modules/turnmarker/assets/regeneration.png";case 3:return"modules/turnmarker/assets/cosmos.png";case 4:return"modules/turnmarker/assets/earthlydust.png";case 5:return"modules/turnmarker/assets/reality.png";case 6:return"modules/turnmarker/assets/believer.png";case 7:return"modules/turnmarker/assets/madmage.png";case 8:return"modules/turnmarker/assets/bluesky.png";case 9:return"modules/turnmarker/assets/universe.png";case 10:return"modules/turnmarker/assets/prosperity.png"}}static setImage(e){game.settings.set(i.modName,h,e)}static getCustomImagePath(){return game.settings.get(i.modName,p)}static setCustomImagePath(e){game.settings.set(i.modName,p,e)}static registerSettings(){game.settings.registerMenu(i.modName,"tm.settingsMenu",{name:"tm.settings.button.name",label:"tm.settings.button.label",icon:"fas fa-sync-alt",type:r.SettingsForm,restricted:!0}),game.settings.register(i.modName,o,{name:`${i.modName} version`,default:"0.0.0",type:String,scope:"world"}),game.settings.register(i.modName,m,{name:"tm.settings.ratio.name",hint:"tm.settings.ratio.hint",scope:"world",config:!1,type:Number,default:1.5,restricted:!0}),game.settings.register(i.modName,c,{name:"tm.settings.animate.name",hint:"tm.settings.animate.hint",scope:"user",config:!0,type:Boolean,default:!0,onChange:e=>{!game.paused&&e&&canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker))?n.MarkerAnimation.startAnimation():n.MarkerAnimation.stopAnimation()}}),game.settings.register(i.modName,g,{name:"tm.settings.interval.name",hint:"tm.settings.interval.hint",scope:"user",config:!0,type:Number,default:100}),game.settings.register(i.modName,h,{name:"tm.settings.image.name",scope:"world",config:!1,type:Number,default:0,choices:v,restricted:!0,onChange:e=>s.Marker.updateImagePath(e)}),game.settings.register(i.modName,l,{name:"tm.settings.announcedActors.name",hint:"tm.settings.announcedActors.hint",scope:"world",config:!1,type:Number,default:0,restricted:!0,choices:y}),game.settings.register(i.modName,k,{name:"tm.settings.announceTokenName.name",hint:"tm.settings.announceTokenName.hint",scope:"world",config:!1,type:Boolean,default:!1,restricted:!0}),game.settings.register(i.modName,p,{name:"tm.settings.customImage.name",hint:"tm.settings.customImage.hint",scope:"world",config:!1,type:String,default:"",restricted:!0,onChange:e=>s.Marker.updateImagePath(e)}),game.settings.register(i.modName,d,{name:"tm.settings.announce.name",hint:"tm.settings.announce.hint",scope:"world",config:!1,type:Boolean,default:!0}),game.settings.register(i.modName,u,{name:"tm.settings.announceImage.name",hint:"tm.settings.announceImage.hint",scope:"world",config:!1,type:Boolean,default:!0}),game.settings.register(i.modName,"announce-asActor",{name:"tm.settings.announceAs.name",hint:"tm.settings.announceAs.hint",scope:"world",config:!1,type:Boolean,default:!0}),game.settings.register(i.modName,f,{name:"tm.settings.turnMarkerEnabled.name",hint:"tm.settings.turnMarkerEnabled.hint",scope:"world",config:!1,type:Boolean,default:!0,restricted:!0,onChange:e=>{e?game.combat&&game.combat.combatant&&game.combat.started&&s.Marker.placeTurnMarker(game.combat.combatant.token._id):s.Marker.deleteTurnMarker()}}),game.settings.register(i.modName,b,{name:"tm.settings.startEnabled.name",hint:"tm.settings.startEnabled.hint",scope:"world",config:!1,type:Boolean,default:!1,restricted:!0,onChange:e=>{e?game.combat&&game.combat.combatant&&game.combat.started&&s.Marker.placeStartMarker(game.combat.combatant.token._id):s.Marker.deleteStartMarker()}}),game.settings.register(i.modName,M,{name:"tm.settings.startImage.name",hint:"tm.settings.startImage.hint",scope:"world",config:!1,type:String,default:"",restricted:!0})}}},"./src/scripts/settingsForm.js":(e,t,a)=>{a.r(t),a.d(t,{SettingsForm:()=>r});var s=a("./src/scripts/settings.js");const n=["mp4","webm","ogg"];class r extends FormApplication{constructor(e,t={}){super(e,t)}static get defaultOptions(){return mergeObject(super.defaultOptions,{id:"turnmarker-settings-form",title:"Turn Marker - Global Settings",template:"./modules/turnmarker/templates/settings.html",classes:["sheet","tm-settings"],width:500,closeOnSubmit:!0})}getData(){return{turnMarkerEnabled:s.Settings.getTurnMarkerEnabled(),ratio:s.Settings.getRatio(),image:this.getSelectList(s.imageTitles,s.Settings.getImageIndex()),announceActors:this.getSelectList(s.announcedActorOptions,s.Settings.getAnnounceActors()),customImage:s.Settings.getCustomImagePath(),announce:s.Settings.shouldAnnounceTurns(),announceImage:s.Settings.getIncludeAnnounceImage(),announceTokenName:s.Settings.getAnnounceTokenName(),startMarkerEnabled:s.Settings.getStartMarkerEnabled(),startMarkerPath:s.Settings.getStartMarkerPath(),previewPath:s.Settings.getImagePath()}}async _updateObject(e,t){console.log("Turn Marker | Saving Settings"),s.Settings.setRatio(t.ratio),t.image&&s.Settings.setImage(t.image),s.Settings.setCustomImagePath(t.customImage),s.Settings.setShouldAnnounceTurns(t.announce),s.Settings.setAnnounceActors(t.announceActors),s.Settings.setIncludeAnnounceImage(t.announceImage),s.Settings.setAnnounceTokenName(t.announceTokenName),s.Settings.setTurnMarkerEnabled(t.turnMarkerEnabled),s.Settings.setStartMarkerEnabled(t.startMarkerEnabled),s.Settings.setStartMarkerPath(t.startMarkerPath)}activateListeners(e){super.activateListeners(e);const t=e.find("#image"),a=e.find("#customImage"),n=e.find("#markerImgPreview");this.updatePreview(e),t.length>0&&t.on("change",(e=>{""==a[0].value.trim()&&n.attr("src",s.Settings.getImageByIndex(Number(e.target.value)))})),a.length>0&&a.on("change",(t=>{this.updatePreview(e)}))}updatePreview(e){const t=e.find("#image"),a=e.find("#customImage"),r=e.find("#markerImgPreview"),i=e.find("#markerVideoPreview");if(""==a[0].value.trim())t[0].disabled=!1,r.attr("src",s.Settings.getImageByIndex(Number(t[0].value))),r.removeClass("hidden"),i.addClass("hidden");else{t[0].disabled=!0;const e=this.getExtension(a[0].value);console.warn(e),n.includes(e.toLowerCase())?(i.attr("src",a[0].value),r.addClass("hidden"),i.removeClass("hidden")):(r.attr("src",a[0].value),r.removeClass("hidden"),i.addClass("hidden"))}}getExtension(e){return e.slice(2+(e.lastIndexOf(".")-1>>>0))}getSelectList(e,t){let a=[];return e.forEach(((e,s)=>{a.push({value:e,selected:s==t})})),a}}},"./src/scripts/turnmarker.js":(e,t,a)=>{a.r(t);var s=a("./src/scripts/chatter.js"),n=a("./src/scripts/marker.js"),r=a("./src/scripts/markeranimation.js"),i=a("./src/scripts/settings.js"),o=a("./src/scripts/updateWindow.js"),m=a("./src/scripts/utils.js");let c="";function g(e){if(e.data.hidden)return game.user.isGM;if(!canvas.sight.tokenVision)return!0;if(e._controlled)return!0;const t=canvas.tokens.placeables.find((e=>e.id===game.combat.combatant.tokenId));if(!t||t.data.hidden)return game.user.isGM;if(t._controlled)return!0;const a=i.Settings.getRatio(),s=e.data.width/a,n=e.data.height/a,r=Math.min(s,n)/4;return canvas.sight.testVisibility(e.center,{tolerance:r,object:e})}Hooks.once("init",(()=>{i.Settings.registerSettings()})),Hooks.once("ready",(()=>{game.user.isGM&&isNewerVersion(game.modules.get("turnmarker").data.version,i.Settings.getVersion())&&(0,o.renderUpdateWindow)(),game.socket.on(m.socketName,(async e=>{if(game.user.isGM&&e){const t=canvas.tiles.placeables.find((t=>t.id===e[0]));switch(e.mode){case m.socketAction.deleteStartMarker:await canvas.scene.deleteEmbeddedEntity("Tile",t),canvas.scene.setFlag(m.FlagScope,m.Flags.startMarkerPlaced,!0);break;case m.socketAction.deleteTurnMarker:case m.socketAction.deleteDeckMarker:await canvas.scene.deleteEmbeddedEntity("Tile",t)}}}))})),Hooks.on("canvasReady",(()=>{let e=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));e&&(e.zIndex=Math.max(...canvas.tiles.placeables.map((e=>e.zIndex)))+1,e.parent.sortChildren(),!game.paused&&i.Settings.getShouldAnimate()&&r.MarkerAnimation.startAnimation())})),Hooks.on("createTile",((e,t)=>{if(1==t.flags.turnMarker||1==t.flags.startMarker){const e=canvas.tiles.placeables.find((e=>e.id===t._id));e&&(1==t.flags.turnMarker&&(e.zIndex=Math.max(...canvas.tiles.placeables.map((e=>e.zIndex)))+1,e.parent.sortChildren(),!game.paused&&i.Settings.getShouldAnimate()&&r.MarkerAnimation.startAnimation()),e.renderable=g(e))}})),Hooks.on("updateCombat",(async(e,t)=>{if(e.started||await n.Marker.deleteStartMarker(),e.combatant&&t&&c!=e.combatant._id&&game.user.isGM&&game.userId==(0,m.firstGM)()&&(c=e.combatant._id,e&&e.combatant&&e.started)){await n.Marker.placeStartMarker(e.combatant.token._id);let t=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));if(await n.Marker.placeTurnMarker(e.combatant.token._id,t&&t.id||void 0),i.Settings.shouldAnnounceTurns()&&!e.combatant.hidden)switch(i.Settings.getAnnounceActors()){case 0:s.Chatter.sendTurnMessage(e.combatant);break;case 1:e.combatant.actor.hasPlayerOwner&&s.Chatter.sendTurnMessage(e.combatant);break;case 2:e.combatant.actor.hasPlayerOwner||s.Chatter.sendTurnMessage(e.combatant);break;case 3:s.Chatter.sendTurnMessage(e.combatant,!0)}}})),Hooks.on("deleteCombat",(async()=>{game.user.isGM&&await n.Marker.clearAllMarkers(),r.MarkerAnimation.stopAnimation()})),Hooks.on("updateToken",(async(e,t,a)=>{let s=canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker));s&&(a.x||a.y||a.width||a.height||a.hidden)&&game&&game.combat&&game.combat.combatant&&game.combat.combatant.tokenId==t._id&&game.user.isGM&&game.combat&&(await n.Marker.moveMarkerToToken(t._id,s.id),s.zIndex=Math.max(...canvas.tiles.placeables.map((e=>e.zIndex)))+1,s.parent.sortChildren())})),Hooks.on("updateTile",((e,t,a,s)=>{if(t.flags.turnMarker||t.flags.startMarker){const e=canvas.tiles.placeables.find((e=>e.id===t._id));e&&(e.renderable=g(e))}})),Hooks.on("sightRefresh",(()=>{for(const e of canvas.tiles.placeables)(e.data.flags.turnMarker||e.data.flags.startMarker)&&(e.renderable=g(e))})),Hooks.on("pauseGame",(e=>{!e&&i.Settings.getShouldAnimate()&&canvas.tiles.placeables.find((e=>1==e.data.flags.turnMarker))?r.MarkerAnimation.startAnimation():r.MarkerAnimation.stopAnimation()}))},"./src/scripts/updateWindow.js":(e,t,a)=>{a.r(t),a.d(t,{renderUpdateWindow:()=>n});var s=a("./src/scripts/settings.js");function n(){const e=game.modules.get("turnmarker");if(isNewerVersion(e.data.version,s.Settings.getVersion())){class t extends Application{static get defaultOptions(){return mergeObject(super.defaultOptions,{template:`modules/${e.id}/templates/updateWindow.html`,resizable:!1,width:500,height:600,classes:["updateWindow"],title:`${e.data.title} - Updated`})}getData(){return{version:e.data.version}}activateListeners(t){super.activateListeners(t),t.find(".show-again").on("change",(t=>{s.Settings.setVersion(t.currentTarget.checked?e.data.version:oldVersion)}))}}(new t).render(!0)}}},"./src/scripts/utils.js":(e,t,a)=>{a.r(t),a.d(t,{modName:()=>s,FlagScope:()=>n,Flags:()=>r,socketName:()=>i,socketAction:()=>o,findTokenById:()=>m,firstGM:()=>c});const s="turnmarker",n="turnmarker",r={startMarkerPlaced:"startMarkerPlaced"},i="module.turnmarker",o={placeStartMarker:0};function m(e){return canvas.tokens.ownedTokens.find((t=>t.id==e))}function c(){for(let e of game.users.entities)if(e.data.role>=4&&e.active)return e.data._id}}},t={};function a(s){if(t[s])return t[s].exports;var n=t[s]={exports:{}};return e[s](n,n.exports,a),n.exports}a.d=(e,t)=>{for(var s in t)a.o(t,s)&&!a.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a("./src/scripts/turnmarker.js")})(); //# sourceMappingURL=turnmarker.js.map \ No newline at end of file diff --git a/dist/templates/updateWindow.html b/dist/templates/updateWindow.html index 63a862f..d44a9aa 100644 --- a/dist/templates/updateWindow.html +++ b/dist/templates/updateWindow.html @@ -23,16 +23,20 @@

Want to support development?

Important Changes

Below are just some of the changes to the module that should be called out. The full changelog is also available here.

-

v2.7.2

+

v2.7.3

+

v2.7.2

+

v2.7.1