diff --git a/CHANGELOG.md b/CHANGELOG.md index b384f5f..6900085 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# Version 12.01 + +v12 Compatibility + +Added tooltip to describe what the icons mean + +Fixed issue where clicking on the header wasn't opening a context menu with options + +Fixed issue with figuring out the screen size when a token moves + +Fixed issue when the scale changes but the tokens don't move, not animating to the scale changes + +Updated the screen padding option to handle less padding + # Version 11.07 Added support for Storyteller diff --git a/apps/controller.js b/apps/controller.js index dcdad77..06cffc5 100644 --- a/apps/controller.js +++ b/apps/controller.js @@ -6,7 +6,7 @@ export class ControllerApp extends FormApplication { } static get defaultOptions() { - return mergeObject(super.defaultOptions, { + return foundry.utils.mergeObject(super.defaultOptions, { id: "monkscommondisplay", title: "Monks Common Display", template: "./modules/monks-common-display/templates/controller.html", @@ -22,7 +22,7 @@ export class ControllerApp extends FormApplication { (setting('allow-gm-players') ? u.id != game.user.id && u.role < CONST.USER_ROLES.GAMEMASTER : !u.isGM)) .map(u => { let data = playerdata[u.id] || {}; - return mergeObject({ + return foundry.utils.mergeObject({ id: u.id, name: u.name, img: u.avatar, diff --git a/apps/player-interface.js b/apps/player-interface.js index ab81a21..6c8a518 100644 --- a/apps/player-interface.js +++ b/apps/player-interface.js @@ -8,7 +8,7 @@ export class PlayerInterface extends Application { } static get defaultOptions() { - return mergeObject(super.defaultOptions, { + return foundry.utils.mergeObject(super.defaultOptions, { id: "player-display", title: "", template: "./modules/monks-common-display/templates/player-interface.html", diff --git a/apps/toolbar.js b/apps/toolbar.js index 74aadeb..99c2838 100644 --- a/apps/toolbar.js +++ b/apps/toolbar.js @@ -20,7 +20,7 @@ export class CommonToolbar extends Application { } static get defaultOptions() { - let options = mergeObject(super.defaultOptions, { + let options = foundry.utils.mergeObject(super.defaultOptions, { id: "common-toolbar", template: "./modules/monks-common-display/templates/toolbar.html", width: 'auto', @@ -45,10 +45,10 @@ export class CommonToolbar extends Application { else collapseIcon = this._collapsed ? "fa-caret-right" : "fa-caret-left"; - let screen = (setting("per-scene") ? getProperty(canvas.scene, "flags.monks-common-display.screen") : setting("screen")) || "gm"; - let focus = (setting("per-scene") ? getProperty(canvas.scene, "flags.monks-common-display.focus") : setting("focus")) || "gm"; + let screen = (setting("per-scene") ? foundry.utils.getProperty(canvas.scene, "flags.monks-common-display.screen") : setting("screen")) || "gm"; + let focus = (setting("per-scene") ? foundry.utils.getProperty(canvas.scene, "flags.monks-common-display.focus") : setting("focus")) || "gm"; - return mergeObject(super.getData(options), { + return foundry.utils.mergeObject(super.getData(options), { tokens: this.tokens, cssClass: css, screen: { @@ -105,6 +105,25 @@ export class CommonToolbar extends Application { } getTooltip(id, type) { + if (MonksCommonDisplay.selectToken == type) + return "Selecting an Actor"; + + if (id == "combat") // && game.combats.active) + return "Combatant"; + else if (id == "gm" || !id) + return "GM"; + else if (id == "party") + return "Party"; + else if (id == "scene") + return "Full screen"; + + if (id.indexOf(",") > -1) + return null; + + let token = canvas.scene.tokens.find(t => t.id == id || t.actor?.id == id); + if (token) + return token.name; + return ""; } @@ -159,7 +178,7 @@ export class CommonToolbar extends Application { let tokenids = canvas.tokens.controlled.map((t) => t.id).join(","); if (setting("per-scene")) { await canvas.scene.setFlag("monks-common-display", MonksCommonDisplay.selectToken, tokenids); - setProperty(canvas.scene, `flags.monks-common-display.${MonksCommonDisplay.selectToken}`, tokenids); + foundry.utils.setProperty(canvas.scene, `flags.monks-common-display.${MonksCommonDisplay.selectToken}`, tokenids); } else { await game.settings.set("monks-common-display", MonksCommonDisplay.selectToken, tokenids); } @@ -182,16 +201,18 @@ export class CommonToolbar extends Application { this.render(); }); + /* $('.header.screen', html).on("click", async (event) => { event.preventDefault(); event.stopPropagation(); - $(event.currentTarget).closest(".common-button-group").contextmenu(); + $(event.currentTarget).closest(".common-button-group").get(0).dispatchEvent(new Event("contextmenu")); }); $('.header.focus', html).on("click", async (event) => { event.preventDefault(); event.stopPropagation(); - $(event.currentTarget).closest(".common-button-group").contextmenu(); + $(event.currentTarget).closest(".common-button-group").get(0).dispatchEvent(new Event("contextmenu")); }); + */ this._contextMenu(html); @@ -250,8 +271,8 @@ export class CommonToolbar extends Application { document.onmouseup = null; document.onmousemove = null; - let xPos = Math.clamped((elmnt.offsetLeft - pos1), 0, window.innerWidth - 200); - let yPos = Math.clamped((elmnt.offsetTop - pos2), 0, window.innerHeight - 20); + let xPos = Math.clamp((elmnt.offsetLeft - pos1), 0, window.innerWidth - 200); + let yPos = Math.clamp((elmnt.offsetTop - pos2), 0, window.innerHeight - 20); let position = { top: null, bottom: null, left: null, right: null }; if (yPos > (window.innerHeight / 2)) @@ -284,6 +305,10 @@ export class CommonToolbar extends Application { ContextMenu.create(this, html, ".common-button-group", this._getContextOptions(), { hookName: "CommonDisplayContext" }); + ContextMenu.create(this, html, ".common-button-group .header", this._getContextOptions(), { + eventName: "click", + hookName: "CommonDisplayContext" + }); } _getContextOptions() { @@ -293,12 +318,13 @@ export class CommonToolbar extends Application { icon: '', condition: game.user.isGM, callback: async (btn) => { + let action = btn.closest(".common-button-group").data("action"); MonksCommonDisplay.selectToken = null; if (setting("per-scene")) - await canvas.scene.setFlag("monks-common-display", btn.data("action"), "gm"); + await canvas.scene.setFlag("monks-common-display", action, "gm"); else - await game.settings.set("monks-common-display", btn.data("action"), "gm"); - if (btn.data("action") == "screen") MonksCommonDisplay.screenChanged(); else MonksCommonDisplay.focusChanged(); + await game.settings.set("monks-common-display", action, "gm"); + if (action == "screen") MonksCommonDisplay.screenChanged(); else MonksCommonDisplay.focusChanged(); this.render(true); } }, @@ -306,15 +332,16 @@ export class CommonToolbar extends Application { name: i18n("MonksCommonDisplay.FullScene"), icon: '', condition: (btn) => { - return game.user.isGM && btn.data("action") == "screen"; + return game.user.isGM && btn.closest(".common-button-group").data("action") == "screen"; }, callback: async (btn) => { + let action = btn.closest(".common-button-group").data("action"); MonksCommonDisplay.selectToken = null; if (setting("per-scene")) - await canvas.scene.setFlag("monks-common-display", btn.data("action"), "scene"); + await canvas.scene.setFlag("monks-common-display", action, "scene"); else - await game.settings.set("monks-common-display", btn.data("action"), "scene"); - if (btn.data("action") == "screen") MonksCommonDisplay.screenChanged(); else MonksCommonDisplay.focusChanged(); + await game.settings.set("monks-common-display", action, "scene"); + if (action == "screen") MonksCommonDisplay.screenChanged(); else MonksCommonDisplay.focusChanged(); this.render(true); } }, @@ -323,12 +350,13 @@ export class CommonToolbar extends Application { icon: '', condition: game.user.isGM, callback: async (btn) => { + let action = btn.closest(".common-button-group").data("action"); MonksCommonDisplay.selectToken = null; if (setting("per-scene")) - await canvas.scene.setFlag("monks-common-display", btn.data("action"), "combat"); + await canvas.scene.setFlag("monks-common-display", action, "combat"); else - await game.settings.set("monks-common-display", btn.data("action"), "combat"); - if (btn.data("action") == "screen") MonksCommonDisplay.screenChanged(); else MonksCommonDisplay.focusChanged(); + await game.settings.set("monks-common-display", action, "combat"); + if (action == "screen") MonksCommonDisplay.screenChanged(); else MonksCommonDisplay.focusChanged(); this.render(true); } }, @@ -336,15 +364,16 @@ export class CommonToolbar extends Application { name: i18n("MonksCommonDisplay.Party"), icon: '', condition: (btn) => { - return game.user.isGM && btn.data("action") == "screen"; + return game.user.isGM && btn.closest(".common-button-group").data("action") == "screen"; }, callback: async (btn) => { + let action = btn.closest(".common-button-group").data("action"); MonksCommonDisplay.selectToken = null; if (setting("per-scene")) - await canvas.scene.setFlag("monks-common-display", btn.data("action"), "party"); + await canvas.scene.setFlag("monks-common-display", action, "party"); else - await game.settings.set("monks-common-display", btn.data("action"), "party"); - if (btn.data("action") == "screen") MonksCommonDisplay.screenChanged(); else MonksCommonDisplay.focusChanged(); + await game.settings.set("monks-common-display", action, "party"); + if (action == "screen") MonksCommonDisplay.screenChanged(); else MonksCommonDisplay.focusChanged(); this.render(true); } }, @@ -353,7 +382,8 @@ export class CommonToolbar extends Application { icon: '', condition: game.user.isGM, callback: btn => { - MonksCommonDisplay.selectToken = (!!MonksCommonDisplay.selectToken ? null : btn.data("action")); + let action = btn.closest(".common-button-group").data("action"); + MonksCommonDisplay.selectToken = (!!MonksCommonDisplay.selectToken ? null : action); this.render(true); } } @@ -379,7 +409,7 @@ export class CommonToolbar extends Application { } if (Object.keys(diff).length > 0) { - mergeObject(tkn, diff); + foundry.utils.mergeObject(tkn, diff); if (refresh) this.render(); } diff --git a/lang/en.json b/lang/en.json index 73fdf06..a5f4ec1 100644 --- a/lang/en.json +++ b/lang/en.json @@ -26,7 +26,7 @@ "MonksCommonDisplay.per-scene.hint": "Store the settings per scene so each scene can have different display", "MonksCommonDisplay.hide-ui.name": "Hide UI", "MonksCommonDisplay.hide-ui.hint": "Hide the UI for the common display", - "MonksCommonDisplay.focus-padding.name": "Focus Padding", + "MonksCommonDisplay.focus-padding.name": "Screen Padding", "MonksCommonDisplay.focus-padding.hint": "Padding around the focused token", "MonksCommonDisplay.show-vertical.name": "Show Vertical", "MonksCommonDisplay.show-vertical.hint": "Show common display interface vertically", @@ -41,7 +41,7 @@ "MonksCommonDisplay.FullScene": "Full Scene", "MonksCommonDisplay.Combatant": "Combatant", "MonksCommonDisplay.Party": "Party", - "MonksCommonDisplay.SelectTokens": "Select Tokens", + "MonksCommonDisplay.SelectTokens": "Select Actors", "MonksCommonDisplay.ShowAsCommonDisplay": "Show as Common Display", "MonksCommonDisplay.ClearImages": "Clear Images", "MonksCommonDisplay.ClearJournals": "Clear Journals", diff --git a/module.json b/module.json index cfa2386..0e804fa 100644 --- a/module.json +++ b/module.json @@ -1,7 +1,7 @@ { "title": "Monk's Common Display", "description": "Set up a display without all the ui so that it can be displayed on an alternate screen", - "version": "11.07", + "version": "12.01", "socket": true, "authors": [ { @@ -29,16 +29,16 @@ "css/monks-common-display.css" ], "url": "https://github.com/ironmonk88/monks-common-display", - "download": "https://github.com/ironmonk88/monks-common-display/archive/11.07.zip", + "download": "https://github.com/ironmonk88/monks-common-display/archive/12.01.zip", "manifest": "https://github.com/ironmonk88/monks-common-display/releases/latest/download/module.json", "bugs": "https://github.com/ironmonk88/monks-common-display/issues", "allowBugReporter": true, "id": "monks-common-display", "compatibility": { - "minimum": "11", - "verified": "11" + "minimum": "12", + "verified": "12" }, "name": "monks-common-display", - "minimumCoreVersion": "11", - "compatibleCoreVersion": "11" + "minimumCoreVersion": "12", + "compatibleCoreVersion": "12" } diff --git a/monks-common-display-layer.js b/monks-common-display-layer.js index 9b8d856..408d2be 100644 --- a/monks-common-display-layer.js +++ b/monks-common-display-layer.js @@ -4,7 +4,7 @@ export class MonksCommonDisplayLayer extends InteractionLayer { } static get layerOptions() { - return mergeObject(super.layerOptions, { + return foundry.utils.mergeObject(super.layerOptions, { objectClass: Note, sheetClass: NoteConfig, sheetClasses: { diff --git a/monks-common-display.js b/monks-common-display.js index 4373838..4db5dc1 100644 --- a/monks-common-display.js +++ b/monks-common-display.js @@ -47,7 +47,7 @@ function registerLayer() { }; */ /* - const layers = mergeObject(Canvas.layers, { + const layers = foundry.utils.mergeObject(Canvas.layers, { MonksCommonDisplayLayer: MonksCommonDisplayLayer }); Object.defineProperty(Canvas, 'layers', { @@ -77,7 +77,7 @@ export class MonksCommonDisplay { //registerLayer(); - let noteWarn = async function (wrapped, ...args) { + patchFunc("Notifications.prototype.warn", async function (wrapped, ...args) { let [message, options] = args; let display = MonksCommonDisplay.playerdata.display || false; @@ -85,22 +85,13 @@ export class MonksCommonDisplay { return; return wrapped(...args); - } - - if (game.modules.get("lib-wrapper")?.active) { - libWrapper.register("monks-common-display", "Notifications.prototype.warn", noteWarn, "MIXED"); - } else { - const oldNoteWarn = Notifications.prototype.warn; - Notifications.prototype.warn = function (event) { - return noteWarn.call(this, oldNoteWarn.bind(this), ...arguments); - } - } + }, "MIXED"); - let checkShowImage = async function (wrapped, ...args) { + patchFunc("Journal.prototype.constructor.showImage", async function (wrapped, ...args) { let [src, data] = args; - let commonid = randomID(); - setProperty(data, "commonid", commonid); + let commonid = foundry.utils.randomID(); + foundry.utils.setProperty(data, "commonid", commonid); await wrapped(src, data); let closeAfter = setting("close-after") ?? 0; @@ -109,19 +100,10 @@ export class MonksCommonDisplay { MonksCommonDisplay.emit("closeImage", { args: { id: commonid } }); }, closeAfter * 1000); } - } - - if (game.modules.get("lib-wrapper")?.active) { - libWrapper.register("monks-common-display", "Journal.prototype.constructor.showImage", checkShowImage, "WRAPPER"); - } else { - const oldShowImage = Journal.prototype.constructor.showImage; - Journal.prototype.constructor.showImage = function (event) { - return checkShowImage.call(this, oldShowImage.bind(this), ...arguments); - } - } + }); - let checkShareImage = async function (...args) { - let commonid = randomID(); + patchFunc("ImagePopout.prototype.shareImage", async function (...args) { + let commonid = foundry.utils.randomID(); game.socket.emit("shareImage", { image: this.object, title: this.options.title, @@ -140,17 +122,9 @@ export class MonksCommonDisplay { MonksCommonDisplay.emit("closeImage", { args: { id: commonid } }); }, closeAfter * 1000); } - } + }, "OVERRIDE"); - if (game.modules.get("lib-wrapper")?.active) { - libWrapper.register("monks-common-display", "ImagePopout.prototype.shareImage", checkShareImage, "OVERRIDE"); - } else { - ImagePopout.prototype.shareImage = function (event) { - return checkShareImage.call(this, ...arguments); - } - } - - let handleShared = async function (wrapped, ...args) { + patchFunc("ImagePopout.prototype.constructor._handleShareImage", async function (wrapped, ...args) { let [options] = args; let ip = await wrapped(...args); @@ -159,18 +133,9 @@ export class MonksCommonDisplay { } return ip; - } - - if (game.modules.get("lib-wrapper")?.active) { - libWrapper.register("monks-common-display", "ImagePopout.prototype.constructor._handleShareImage", handleShared, "WRAPPER"); - } else { - const oldHandleImage = ImagePopout.prototype.constructor._handleShareImage; - ImagePopout.prototype.constructor._handleShareImage = function (event) { - return handleShared.call(this, oldHandleImage.bind(this), ...arguments); - } - } + }); - let clickEntryName = async function (wrapped, ...args) { + patchFunc("ActorDirectory.prototype._onClickEntryName", async function (wrapped, ...args) { let event = args[0]; if (!!MonksCommonDisplay.selectToken) { event.preventDefault(); @@ -178,7 +143,7 @@ export class MonksCommonDisplay { if (setting("per-scene")) { await canvas.scene.setFlag("monks-common-display", MonksCommonDisplay.selectToken, documentId); - setProperty(canvas.scene, `flags.monks-common-display.${MonksCommonDisplay.selectToken}`, documentId); + foundry.utils.setProperty(canvas.scene, `flags.monks-common-display.${MonksCommonDisplay.selectToken}`, documentId); } else { await game.settings.set("monks-common-display", MonksCommonDisplay.selectToken, documentId); } @@ -189,12 +154,10 @@ export class MonksCommonDisplay { MonksCommonDisplay.toolbar.render(true); } else wrapped(...args); - } - - patchFunc("ActorDirectory.prototype._onClickEntryName", clickEntryName, "MIXED"); + }, "MIXED"); /* - let showEntry = async function (...args) { + patchFunc("Journal.prototype.constructor._showEntry", async function (...args) { let entry = await fromUuid(uuid); const options = { tempOwnership: force, mode: JournalSheet.VIEW_MODES.MULTIPLE, pageIndex: 0 }; if (entry instanceof JournalEntryPage) { @@ -214,18 +177,10 @@ export class MonksCommonDisplay { if (options.commonid) { MonksCommonDisplay.windows[options.commonid] = ip; } - } - - if (game.modules.get("lib-wrapper")?.active) { - libWrapper.register("monks-common-display", "Journal.prototype.constructor._showEntry", showEntry, "OVERRIDE"); - } else { - Journal.prototype.constructor._showEntry = function (event) { - return showEntry.call(this, ...arguments); - } - } + }, "OVERRIDE"); */ - let addConvertMenu = function (wrapped, ...args) { + patchFunc("PlayerList.prototype._getUserContextOptions", function (wrapped, ...args) { let menu = wrapped(...args); menu.push({ @@ -249,21 +204,12 @@ export class MonksCommonDisplay { }); return menu; - } - - if (game.modules.get("lib-wrapper")?.active) { - libWrapper.register("monks-common-display", "PlayerList.prototype._getUserContextOptions", addConvertMenu, "WRAPPER"); - } else { - const oldContext = PlayerList.prototype._getUserContextOptions; - PlayerList.prototype._getUserContextOptions = function (event) { - return addConvertMenu.call(this, oldContext.bind(this), ...arguments); - } - } + }); - let sceneView = async function (wrapped, ...args) { + patchFunc("Scene.prototype.view", async function (wrapped, ...args) { let result = await wrapped.call(this, ...args); if (MonksCommonDisplay.playerdata.display || false) { - + if (setting("screen-toggle")) { if (MonksCommonDisplay.screenValue == "gm") MonksCommonDisplay.emit("requestScreenPosition"); @@ -282,16 +228,7 @@ export class MonksCommonDisplay { MonksCommonDisplay.sendScreenMessage("canvasPan", game.canvas.scene._viewPosition); return result; - } - - if (game.modules.get("lib-wrapper")?.active) { - libWrapper.register("monks-common-display", "Scene.prototype.view", sceneView, "WRAPPER"); - } else { - const oldSceneView = Scene.prototype.view; - Scene.prototype.view = function (event) { - return sceneView.call(this, oldSceneView.bind(this), ...arguments); - } - } + }); } static ready() { @@ -430,7 +367,7 @@ export class MonksCommonDisplay { } static onMessage(data) { - log('onMessage', data); + //log('onMessage', data); MonksCommonDisplay[data.action].call(MonksCommonDisplay, data.args) } @@ -499,7 +436,7 @@ export class MonksCommonDisplay { static screenChanged() { if (MonksCommonDisplay.screenValue == "gm") { if (canvas.scene.active) { - let data = mergeObject({ animate: true, speed: 1000 }, game.canvas.scene._viewPosition); + let data = foundry.utils.mergeObject({ animate: true, speed: 1000 }, game.canvas.scene._viewPosition); MonksCommonDisplay.sendScreenMessage("canvasPan", data); } } else if (MonksCommonDisplay.screenValue == "scene") { @@ -516,10 +453,15 @@ export class MonksCommonDisplay { if (tokens && tokens.length) { let x1, y1, x2, y2; for (let token of tokens) { - x1 = !x1 ? token.x : Math.min(x1, token.x); - y1 = !y1 ? token.y : Math.min(y1, token.y); - x2 = !x2 ? token.x + (token.width * canvas.dimensions.size) : Math.max(x2, token.x + (token.width * canvas.dimensions.size)); - y2 = !y2 ? token.y + (token.height * canvas.dimensions.size) : Math.max(y2, token.y + (token.height * canvas.dimensions.size)); + let x = token._mcd_x ?? token.x; + let y = token._mcd_y ?? token.y; + delete token._mcd_x; + delete token._mcd_y; + log('Token', token.name, x, y); + x1 = !x1 ? x : Math.min(x1, x); + y1 = !y1 ? y : Math.min(y1, y); + x2 = !x2 ? x + (token.width * canvas.dimensions.size) : Math.max(x2, x + (token.width * canvas.dimensions.size)); + y2 = !y2 ? y + (token.height * canvas.dimensions.size) : Math.max(y2, y + (token.height * canvas.dimensions.size)); } if (setting("show-chat-log")) @@ -529,11 +471,16 @@ export class MonksCommonDisplay { // I also need to make sure that the entire rectangle is within the screen let screenWidth = $('body').width() - (setting("show-chat-log") ? $("#sidebar").width() : 0); let ratio = screenWidth / $('body').height(); - let width = Math.max((x2 - x1) + (6 * canvas.dimensions.size), (setting("focus-padding") * ratio * canvas.dimensions.size)); - let height = Math.max((y2 - y1) + (6 * canvas.dimensions.size), (setting("focus-padding") * canvas.dimensions.size)); + let width = Math.max((x2 - x1) + canvas.dimensions.size, (setting("focus-padding") * ratio * canvas.dimensions.size)); + let height = Math.max((y2 - y1) + canvas.dimensions.size, (setting("focus-padding") * canvas.dimensions.size)); let scaleWidth = screenWidth / width; let scaleHeight = $('body').height() / height; - let panData = { x: x1 + ((x2 - x1) / 2), y: y1 + ((y2 - y1) / 2), animate: true, speed: 200, scale: Math.min(scaleWidth, scaleHeight) }; + let panData = { x: x1 + ((x2 - x1) / 2), y: y1 + ((y2 - y1) / 2), animate: true, scale: Math.min(scaleWidth, scaleHeight) }; + if (panData.x != canvas.scene._viewPosition.x || panData.y != canvas.scene._viewPosition.y) { + panData.speed = 250; + } else { + panData.duration = 1000; + } canvas.animatePan(panData); } @@ -588,15 +535,15 @@ export class MonksCommonDisplay { } static get screenValue() { - return setting("per-scene") ? getProperty(canvas.scene, "flags.monks-common-display.screen") : setting("screen"); + return setting("per-scene") ? foundry.utils.getProperty(canvas.scene, "flags.monks-common-display.screen") : setting("screen"); } static get focusValue() { - return setting("per-scene") ? getProperty(canvas.scene, "flags.monks-common-display.focus") : setting("focus"); + return setting("per-scene") ? foundry.utils.getProperty(canvas.scene, "flags.monks-common-display.focus") : setting("focus"); } static isDefeated(token) { - return (token && (token.combatant && token.combatant.defeated) || token.actor?.statuses.has(CONFIG.specialStatusEffects.DEFEATED) || token.overlayEffect == CONFIG.controlIcons.defeated); + return (token && (token.combatant && token.combatant.defeated) || token.actor?.statuses.has(CONFIG.specialStatusEffects.DEFEATED)); } static getTokens(value) { @@ -774,22 +721,6 @@ Hooks.on('renderSceneControls', (control, html, data) => { }); Hooks.on("controlToken", async (token, control) => { - /* - if (control && !!MonksCommonDisplay.selectToken) { - if (setting("per-scene")) { - await canvas.scene.setFlag("monks-common-display", MonksCommonDisplay.selectToken, token.id); - setProperty(canvas.scene, `flags.monks-common-display.${MonksCommonDisplay.selectToken}`, token.id); - } else { - await game.settings.set("monks-common-display", MonksCommonDisplay.selectToken, token.id); - } - if (MonksCommonDisplay.selectToken == "screen") MonksCommonDisplay.screenChanged(); else MonksCommonDisplay.focusChanged(); - - MonksCommonDisplay.selectToken = null; - - if (MonksCommonDisplay.toolbar && setting("show-toolbar") && game.user.isGM) - MonksCommonDisplay.toolbar.render(true); - }*/ - let focus = MonksCommonDisplay.focusValue; if (focus == "gm" && game.user.isGM && setting("focus-toggle")) { @@ -825,11 +756,14 @@ Hooks.on("updateToken", async function (document, data, options, userid) { MonksCommonDisplay.toolbar.render(true); let display = MonksCommonDisplay.playerdata.display || false; + log("updateToken", display, data, setting("screen-toggle"), document.hidden); if (display && (data.x != undefined || data.y != undefined) && setting("screen-toggle") && !document.hidden) { + document._mcd_x = data.x ?? document.x; + document._mcd_y = data.y ?? document.y; MonksCommonDisplay.changeScreen(); } }); diff --git a/settings.js b/settings.js index b0390aa..4ddfebd 100644 --- a/settings.js +++ b/settings.js @@ -60,12 +60,15 @@ export const registerSettings = function () { scope: "world", config: true, range: { - min: 5, + min: 1, max: 30, step: 1, }, default: 10, - type: Number + type: Number, + onChange: () => { + MonksCommonDisplay.screenChanged(); + } }); game.settings.register(modulename, "show-chat-log", { diff --git a/templates/toolbar.html b/templates/toolbar.html index 2807167..87fa23f 100644 --- a/templates/toolbar.html +++ b/templates/toolbar.html @@ -15,7 +15,7 @@