Skip to content

Commit

Permalink
12.01 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ironmonk88 committed Jun 2, 2024
1 parent ff5d3bd commit 3242d77
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 154 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions apps/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion apps/player-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
80 changes: 55 additions & 25 deletions apps/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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: {
Expand Down Expand Up @@ -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 "";
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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);

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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() {
Expand All @@ -293,28 +318,30 @@ export class CommonToolbar extends Application {
icon: '<i class="fas fa-user"></i>',
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);
}
},
{
name: i18n("MonksCommonDisplay.FullScene"),
icon: '<i class="fas fa-presentation-screen"></i>',
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);
}
},
Expand All @@ -323,28 +350,30 @@ export class CommonToolbar extends Application {
icon: '<i class="fas fa-swords"></i>',
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);
}
},
{
name: i18n("MonksCommonDisplay.Party"),
icon: '<i class="fas fa-users-viewfinder"></i>',
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);
}
},
Expand All @@ -353,7 +382,8 @@ export class CommonToolbar extends Application {
icon: '<i class="fas fa-bullseye"></i>',
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);
}
}
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions module.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion monks-common-display-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading

0 comments on commit 3242d77

Please sign in to comment.