Skip to content

Commit

Permalink
Merge pull request #24 from Jennykinns/master
Browse files Browse the repository at this point in the history
Update to support Foundry v12
  • Loading branch information
Galdormin authored Dec 7, 2024
2 parents 498a880 + 041cb03 commit 449f1e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "fate-aspect-tracker",
"title": "Fate Aspect Tracker",
"description": "An Aspect Tracker for any Fate RPG.",
"version": "1.3.0",
"version": "1.4.0",
"authors": [
{
"name": "Théo Plénet",
Expand All @@ -14,8 +14,8 @@
"manifest": "https://raw.githubusercontent.com/Galdormin/FoundryVTT-Fate-Aspect-Tracker/master/module.json",
"download": "https://github.com/Galdormin/FoundryVTT-Fate-Aspect-Tracker/releases/latest/download/module.zip",
"compatibility": {
"minimum": "10",
"verified": "11"
"minimum": "12",
"verified": "12"
},
"esmodules": [
"modules/fate-aspect-tracker.js",
Expand Down
28 changes: 15 additions & 13 deletions modules/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class Tracker {
if (coordx > 0 && coordx < canvas.dimensions.width && coordy > 0 && coordy < canvas.dimensions.height) {
const text = aspect.description + " ( " + aspect.invoke + " )";

const gridsize = game.scenes.viewed.data.grid.size
const gridsize = game.scenes.viewed.grid.size;
const size = gridsize*game.settings.get("fate-aspect-tracker","AspectDrawingFontSize")/100;

const fontsize = Math.min(256, Math.max(8, Math.round(size/2)));
Expand All @@ -213,12 +213,14 @@ export class Tracker {
}

const drawing = {
type: CONST.DRAWING_TYPES.RECTANGLE,
type: foundry.data.ShapeData.TYPES.RECTANGLE,
author: game.user.id,
x: coordx - width/2,
y: coordy - height/2,
width: width,
height: height,
shape:{
width: width,
height: height,
},
fillType: CONST.DRAWING_FILL_TYPES.SOLID,
fillColor: game.settings.get("fate-aspect-tracker","AspectDrawingFillColor"),
fillAlpha: game.settings.get("fate-aspect-tracker","AspectDrawingFillOpacity"),
Expand All @@ -227,14 +229,14 @@ export class Tracker {
strokeAlpha: game.settings.get("fate-aspect-tracker","AspectDrawingBorderOpacity"),
text: text,
fontSize: fontsize,
fontFamily: CONFIG.fontFamilies[game.settings.get("fate-aspect-tracker","AspectDrawingFontFamily")],
fontFamily: CONFIG.fontDefinitions[game.settings.get("fate-aspect-tracker","AspectDrawingFontFamily")],
textColor: color,
points: []
};

const d = await game.scenes.viewed.createEmbeddedDocuments('Drawing', [drawing]);

d.forEach( drawing => aspect.drawings.push(drawing.data._id));
d.forEach( drawing => aspect.drawings.push(drawing.id));
await this.store();
} else {
ui.notifications.warn(game.i18n.localize("FateAspectTracker.aspectText.error"));
Expand All @@ -256,15 +258,15 @@ export class Tracker {
// Update all textbox on all scene
game.scenes.forEach(scene => {
const drawings = scene.getEmbeddedCollection("Drawing").map(drawing => {
if(aspect.drawings.includes(drawing.data._id)) {
const gridsize = drawing.parent.data.grid.size
if(aspect.drawings.includes(drawing.id)) {
const gridsize = drawing.parent.grid.size
const size = gridsize*game.settings.get("fate-aspect-tracker","AspectDrawingFontSize")/100;

const fontsize = Math.min(256, Math.max(8, Math.round(size/2)));
const height = size;
const width = (updatedText.length * fontsize / 1.5);

return { _id: drawing.data._id, text: updatedText, width: width, height: height, fontSize: fontsize}
return { _id: drawing.id, text: updatedText, width: width, height: height, fontSize: fontsize}
} else {
return null
}
Expand All @@ -288,10 +290,10 @@ export class Tracker {
// Delete all other textbox on all other scene
game.scenes.forEach(scene => {
const ds = scene.getEmbeddedCollection("Drawing").filter(drawing => {
return aspect.drawings.includes(drawing.data._id);
return aspect.drawings.includes(drawing.id);
});

scene.deleteEmbeddedDocuments('Drawing', ds.map(drawing => drawing.data._id));
scene.deleteEmbeddedDocuments('Drawing', ds.map(drawing => drawing.id));
});
}

Expand All @@ -318,8 +320,8 @@ export class Tracker {
// Hide all textbox on all scene
game.scenes.forEach(scene => {
const drawings = scene.getEmbeddedCollection("Drawing").map(drawing => {
if(aspect.drawings.includes(drawing.data._id))
return { _id: drawing.data._id, hidden: aspect.hidden }
if(aspect.drawings.includes(drawing.id))
return { _id: drawing.id, hidden: aspect.hidden }
else
return null
}).filter(d => d != null);
Expand Down

0 comments on commit 449f1e5

Please sign in to comment.