Skip to content

Commit

Permalink
12.04 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ironmonk88 committed Nov 24, 2024
1 parent 7b1208a commit 8c63d53
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 76 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# version 12.04

Fixed deprecation warning when sorting conditions

Fixed how the labels are found for the status texts

Fixed issue with the clear all conditions.

Removed the alter HUD functionality in StarFinder system since that RPG already does it.

Added Region Layer to the quick access key press list

Fixed issues when teleporting using the M key to a new location when there are tokens of differing sizes involved.

Fixed issue where compendium actors were getting the option to be transformed to that actor when the system doesn't support it.

Added a tooltip to the chat message time so you can see the specific time the message was sent rather than just how long ago it was sent.

Adding Italian translations

# version 12.03

Added the option to shift the center of a popUp dialog, in case you use dual monitors and want to stretch across both, you can have popUp windows center on the left or right monitor rather than in the middle split between them.
Expand Down
30 changes: 16 additions & 14 deletions js/hud-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export class HUDChanges {

patchFunc("TokenHUD.prototype._getStatusEffectChoices", function (wrapped, ...args) {
if (setting('sort-statuses') != 'none') {
CONFIG.statusEffects = CONFIG.statusEffects.map(e => {
let label = e.label ?? e.name;
e.label = e.name = label;
return e;
}).sort(function (a, b) {
let aid = (a.label != undefined ? i18n(a.label) : a.id || a);
let bid = (b.label != undefined ? i18n(b.label) : b.id || b);
CONFIG.statusEffects = CONFIG.statusEffects.sort(function (a, b) {
let aName = a.name;
let bName = b.name;
if (!aName) aName = i18n(a.label);
if (!bName) bName = i18n(b.label);
let aid = aName || a.id || a;
let bid = bName || b.id || b;
return (aid > bid ? 1 : (aid < bid ? -1 : 0));
//return (a.id == undefined || a.id > b.id ? 1 : (a.id < b.id ? -1 : 0)); //(a.label == undefined || i18n(a.label) > i18n(b.label) ? 1 : (i18n(a.label) < i18n(b.label) ? -1 : 0));
});
Expand All @@ -47,7 +47,12 @@ export class HUDChanges {
$(img).css({ 'visibility': 'hidden' });
} else {
//const status = statuses[img.getAttribute("src")] || {};
let title = $(img).attr('data-tooltip') || $(img).attr('data-status-id') || $(img).attr('title') || $(img).attr('data-condition');
let statusId = $(img).attr('data-status-id') || $(img).attr('data-condition');
let title = $(img).attr('data-tooltip') || $(img).attr('title');

var condition = CONFIG.statusEffects.find(c => c.id == statusId);
if (condition)
title = i18n(condition.name);

$(img).removeAttr('data-tooltip');

Expand Down Expand Up @@ -99,13 +104,10 @@ export class HUDChanges {

for (const [k, status] of Object.entries(statuses)) {
if (status.isActive) {
if (game.system.id == "dnd5e") {
let id = `dnd5e${status.id}`;
if (id.length >= 16) id = id.substring(0, 16);
id = id.padEnd(16, "0");
const existing = this.object.actor.effects.get(id);
if (game.system.id == "dnd5e") {
const existing = this.object.actor.effects.find(e => e.statuses.has(status.id));
if (existing)
await this.object.actor.deleteEmbeddedDocuments("ActiveEffect", [id]);
await this.object.actor.deleteEmbeddedDocuments("ActiveEffect", [existing.id]);
} else {
let effect = { id: status.id, icon: status.src };
if (game.system.id == "D35E" && !Object.keys(CONFIG.D35E.conditions).includes(status.id)) {
Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Monk's Little Details",
"description": "Things to tidy up the interface and flow",
"version": "12.03",
"version": "12.04",
"authors": [
{
"name": "IronMonk",
Expand Down Expand Up @@ -69,7 +69,7 @@
"css/monks-little-details.css"
],
"url": "https://github.com/ironmonk88/monks-little-details",
"download": "https://github.com/ironmonk88/monks-little-details/archive/12.03.zip",
"download": "https://github.com/ironmonk88/monks-little-details/archive/12.04.zip",
"manifest": "https://github.com/ironmonk88/monks-little-details/releases/latest/download/module.json",
"bugs": "https://github.com/ironmonk88/monks-little-details/issues",
"id": "monks-little-details",
Expand Down
142 changes: 82 additions & 60 deletions monks-little-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export class MonksLittleDetails {
MonksLittleDetails.SOCKET = "module.monks-little-details";

MonksLittleDetails._rejectlist = {
"add-extra-statuses": ["pf2e"]
"add-extra-statuses": ["pf2e"],
"alter-hud": ["sfrpg"]
}
MonksLittleDetails._onlylist = {
"sort-by-columns": ["dnd5e"],
Expand Down Expand Up @@ -290,7 +291,6 @@ export class MonksLittleDetails {
const currentPosition = this.position;
if (scale === null) scale = 1;
scale = scale ?? currentPosition.scale ?? 1;
let adjustWidth = window.innerWidth / 4;

const scaledWidth = this.position.width * scale;
const tarL = ((window.innerWidth / 2) - scaledWidth) / 2 + (setting("dual-monitor") == "right" ? (window.innerWidth / 2) : 0);
Expand All @@ -303,6 +303,18 @@ export class MonksLittleDetails {

return result;
});

/*
patchFunc("ControlsLayer.prototype.handlePing", function (wrapped, ...args) {
let [user, position, options] = args;
if (setting("dual-monitor") != "none") {
var offset = (window.innerWidth / 2) * (setting("dual-monitor") == "right" ? 1 : -1);
position.x += offset;
}
return wrapped(...args);
});
*/
}

static addQuickLink(target, favorite = false) {
Expand Down Expand Up @@ -464,6 +476,7 @@ export class MonksLittleDetails {
{ name: "Wall Layer", tool: 'walls', restricted: true },
{ name: "Lighting Layer", tool: 'lighting', def: "KeyJ", restricted: true },
{ name: "Sound Layer", tool: 'sounds', def: "KeyK", restricted: true },
{ name: "Region Layer", tool: 'regions', restricted: true },
{ name: "Note Layer", tool: 'notes', restricted: false }
];
if (game.modules["enhanced-terrain-layer"]?.active)
Expand Down Expand Up @@ -628,41 +641,44 @@ background-color: rgba(0, 0, 0, 0.5);
static async moveTokens(event) {
let moveKey = MonksLittleDetails.getMoveKey();

let tokens = canvas.tokens.controlled.map(t => t.document);
if (!tokens.length && MonksLittleDetails._selectedTokens?.tokens)
tokens = MonksLittleDetails._selectedTokens.tokens;

if (game.user.isGM && moveKey && game.keyboard.downKeys.has(moveKey) && tokens.length > 0) {
let pos = event.data.getLocalPosition(canvas.app.stage);
let gs = canvas.scene.dimensions.size;

let mid = {
x: tokens[0].x,
y: tokens[0].y
};
for (let i = 1; i < tokens.length; i++) {
mid.x += tokens[i].x;
mid.y += tokens[i].y;
}
mid.x = (mid.x / tokens.length);
mid.y = (mid.y / tokens.length);

let updates = [];
for (let i = 0; i < tokens.length; i++) {
let offset = { x: tokens[i].x - mid.x, y: tokens[i].y - mid.y };
let pt = { x: pos.x + offset.x, y: pos.y + offset.y };
pt.x = Math.floor(pt.x / gs) * gs;
pt.y = Math.floor(pt.y / gs) * gs;
let shift = { x: Math.floor(((tokens[i].width * gs) / 2) / gs) * gs, y: Math.floor(((tokens[i].height * gs) / 2) / gs) * gs };
pt = { x: pt.x - shift.x, y: pt.y - shift.y };

//t.update({ x: px[0], y: px[1] }, { animate: false });
updates.push({ _id: tokens[i].id, x: pt.x, y: pt.y });
}
if (updates.length) {
MonksLittleDetails.movingToken = true;
await canvas.scene.updateEmbeddedDocuments("Token", updates, { animate: false, bypass: true });
MonksLittleDetails.movingToken = false;
if (game.user.isGM && moveKey && game.keyboard.downKeys.has(moveKey)) {
let tokens = canvas.tokens.controlled.map(t => t.document);
if (!tokens.length && MonksLittleDetails._selectedTokens?.tokens)
tokens = MonksLittleDetails._selectedTokens.tokens;
if (tokens.length > 0) {
let pos = event.data.getLocalPosition(canvas.app.stage);
let gs = canvas.scene.dimensions.size;
pos.x = Math.floor(pos.x / gs) * gs;
pos.y = Math.floor(pos.y / gs) * gs;

let mid = {
x: tokens[0].x,
y: tokens[0].y
};
for (let i = 1; i < tokens.length; i++) {
mid.x += tokens[i].x;
mid.y += tokens[i].y;
}
mid.x = (mid.x / tokens.length);
mid.y = (mid.y / tokens.length);

let updates = [];
for (let i = 0; i < tokens.length; i++) {
let offset = { x: tokens[i].x - mid.x, y: tokens[i].y - mid.y };
let pt = { x: pos.x + offset.x, y: pos.y + offset.y };
//let shift = { x: Math.floor(((tokens[i].width * gs) / 2) / gs) * gs, y: Math.floor(((tokens[i].height * gs) / 2) / gs) * gs };
//pt = { x: pt.x - shift.x, y: pt.y - shift.y };
pt.x = Math.floor(pt.x / gs) * gs;
pt.y = Math.floor(pt.y / gs) * gs;

//t.update({ x: px[0], y: px[1] }, { animate: false });
updates.push({ _id: tokens[i].id, x: pt.x, y: pt.y });
}
if (updates.length) {
MonksLittleDetails.movingToken = true;
await canvas.scene.updateEmbeddedDocuments("Token", updates, { animate: false, bypass: true });
MonksLittleDetails.movingToken = false;
}
}
}
}
Expand Down Expand Up @@ -1173,32 +1189,34 @@ Hooks.on("getActorDirectoryEntryContext", (html, entries) => {
});

Hooks.on("getCompendiumEntryContext", (html, entries) => {
entries.push({
name: "Transform into this Actor",
icon: '<i class="fas fa-random"></i>',
condition: li => {
if (!$(li).hasClass("actor"))
return false;
const canPolymorph = game.user.isGM || (game.settings.get("dnd5e", "allowPolymorphing"));
return canPolymorph;
},
callback: async (li) => {
let compendium = $(li).closest('.directory');
let data = {
pack: compendium.data("pack"),
id: li.data("documentId")
}
if (game.system.id == "dnd5e") {
entries.push({
name: "Transform into this Actor",
icon: '<i class="fas fa-random"></i>',
condition: li => {
if (!$(li).hasClass("actor"))
return false;
const canPolymorph = game.user.isGM || (game.settings.get("dnd5e", "allowPolymorphing"));
return canPolymorph;
},
callback: async (li) => {
let compendium = $(li).closest('.directory');
let data = {
pack: compendium.data("pack"),
id: li.data("documentId")
}

let actors = canvas.tokens.controlled.map(t => t.actor);
let actors = canvas.tokens.controlled.map(t => t.actor);

if (actors.length == 0 && !game.user.isGM)
actors = [game.user.character];
if (actors.length == 0 && !game.user.isGM)
actors = [game.user.character];

for (let actor of actors) {
actor.sheet._onDropActor(null, data);
for (let actor of actors) {
actor.sheet._onDropActor(null, data);
}
}
}
});
});
}
});

Hooks.on("updateScene", (scene, data, options) => {
Expand Down Expand Up @@ -1322,4 +1340,8 @@ Hooks.on("pauseGame", (state) => {
if (setting("pause-border")) {
$("body").toggleClass("mld-paused", state && $('#board').length > 0);
}
})
});

Hooks.on("renderChatMessage", (app, html, data) => {
$(".message-timestamp", html).attr("title", new Date(data.message.timestamp).toLocaleString());
});
Binary file removed monks-little-details.zip
Binary file not shown.

0 comments on commit 8c63d53

Please sign in to comment.