Loading fix
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"type": "module",
|
||||
"title": "Gowler's Tracking Ledger",
|
||||
"description": "Adds HP/XP/Currency log buttons to PF1 sheets and opens the tracking dialog preloaded with the actor's logs.",
|
||||
"version": "0.1.21",
|
||||
"version": "1.3.2",
|
||||
"authors": [
|
||||
{ "name": "Gowler", "url": "https://foundryvtt.com" }
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
const MODULE_ID = "gowlers-tracking-ledger";
|
||||
const MODULE_VERSION = "1.3.0";
|
||||
const MODULE_VERSION = "1.3.2";
|
||||
const TRACK_SETTING = "actorSettings";
|
||||
const FLAG_SCOPE = "world";
|
||||
const MAX_HISTORY_ROWS = 100;
|
||||
@@ -292,12 +292,12 @@ Hooks.once("init", () => {
|
||||
|
||||
registerSettings();
|
||||
registerSettingsMenu();
|
||||
registerSceneControls(true);
|
||||
});
|
||||
|
||||
Hooks.once("ready", async () => {
|
||||
if (game.system.id !== "pf1") return;
|
||||
await initializeModule();
|
||||
registerSceneControls();
|
||||
// Expose NPC toggle helper for damage meter checkbox
|
||||
window.GowlersTrackingDamageMeterToggleNPCs = (checked) => {
|
||||
ledgerState.damageMeterIncludeNPCs = !!checked;
|
||||
@@ -603,7 +603,9 @@ function registerSettingsMenu() {
|
||||
});
|
||||
}
|
||||
|
||||
function registerSceneControls() {
|
||||
function registerSceneControls(forceRefresh = false) {
|
||||
if (ledgerState.controlsRegistered) return;
|
||||
ledgerState.controlsRegistered = true;
|
||||
Hooks.on("getSceneControlButtons", (controls) => {
|
||||
const tokenControls = controls.find((c) => c.name === "token");
|
||||
if (!tokenControls) return;
|
||||
@@ -633,6 +635,14 @@ function registerSceneControls() {
|
||||
},
|
||||
});
|
||||
});
|
||||
if (forceRefresh && ui?.controls) {
|
||||
try {
|
||||
ui.controls.initialize();
|
||||
ui.controls.render(true);
|
||||
} catch (err) {
|
||||
console.warn("[GowlersTracking] Failed to refresh controls after registration", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openDamageMeterOverlay() {
|
||||
@@ -2504,6 +2514,7 @@ function primeDocBaseline(doc) {
|
||||
if (actor) primeActor(actor);
|
||||
}
|
||||
|
||||
|
||||
function collectAllActorDocuments() {
|
||||
const actors = new Map();
|
||||
for (const a of game.actors.contents ?? []) {
|
||||
|
||||
@@ -107,7 +107,7 @@ Hooks.once('init', () => {
|
||||
});
|
||||
|
||||
const hideShowForPlayers = game.settings.get('searchanywhere', 'settingPlayers');
|
||||
if(hideShowForPlayers && !new User(game.data.users.find(user => user._id === game.data.userId)).isGM) {
|
||||
if(hideShowForPlayers && !game.user.isGM) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -668,7 +668,7 @@ class AutoCompletionField {
|
||||
let folder = entity.folder;
|
||||
while (folder !== null && !excluded) {
|
||||
excluded = excludedFolders.includes(folder.id);
|
||||
folder = folder.data.parent ? game.folders.get(folder.data.parent.id) : null;
|
||||
folder = folder.folder ? game.folders.get(folder.folder.id) : null;
|
||||
}
|
||||
return excluded;
|
||||
}
|
||||
@@ -1042,11 +1042,11 @@ class EntitySuggestionData {
|
||||
get content() {
|
||||
let content = '';
|
||||
switch (this.entityType) {
|
||||
case 'Actor': content = safeGet(this.entity, 'data.data.details.biography.value'); break;
|
||||
case 'Item': content = safeGet(this.entity, 'data.data.description.value'); break;
|
||||
case 'JournalEntry': content = safeGet(this.entity, 'data.content'); break;
|
||||
case 'RollTable': content = safeGet(this.entity, 'data.content'); break;
|
||||
case 'Playlist': content = safeGet(this.entity, 'data.description'); break;
|
||||
case 'Actor': content = safeGet(this.entity, 'system.details.biography.value'); break;
|
||||
case 'Item': content = safeGet(this.entity, 'system.description.value'); break;
|
||||
case 'JournalEntry': content = safeGet(this.entity, 'content'); break;
|
||||
case 'RollTable': content = safeGet(this.entity, 'description'); break;
|
||||
case 'Playlist': content = safeGet(this.entity, 'description'); break;
|
||||
}
|
||||
return stripHtml(content);
|
||||
}
|
||||
@@ -1065,7 +1065,7 @@ class EntitySuggestionData {
|
||||
|
||||
get image() {
|
||||
switch (this.entityType) {
|
||||
case 'Macro': return this.entity.data.img;
|
||||
case 'Macro': return this.entity.img;
|
||||
case 'JournalEntry': return 'modules/searchanywhere/icons/book.svg';
|
||||
case 'RollTable': return 'icons/svg/d20-grey.svg';
|
||||
}
|
||||
@@ -1161,7 +1161,7 @@ class EntitySuggestionData {
|
||||
|
||||
toSheet(sheetTd) {
|
||||
let sheet = game.searchAnywhere.openedSheets.get(parseInt(sheetTd));
|
||||
sheet.actor.createEmbeddedDocuments("Item", [this.entity.data.toJSON()]);
|
||||
sheet.actor.createEmbeddedDocuments("Item", [this.entity.toObject()]);
|
||||
}
|
||||
|
||||
toTable(sheetTd) {
|
||||
@@ -1172,7 +1172,7 @@ class EntitySuggestionData {
|
||||
collection: this.entity.entity,
|
||||
text: this.entity.name,
|
||||
resultId: this.entity.id,
|
||||
img: this.entity.data.img || null
|
||||
img: this.entity.img || null
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1347,7 +1347,7 @@ class CompendiumSuggestionData {
|
||||
this.pack.getDocument(this.entry._id)
|
||||
.then(entity => {
|
||||
let sheet = game.searchAnywhere.openedSheets.get(parseInt(sheetTd));
|
||||
sheet.actor.createEmbeddedDocuments("Item", [entity.data.toJSON()]);
|
||||
sheet.actor.createEmbeddedDocuments("Item", [entity.toObject()]);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(`Unable to add compendium item to sheet: ${err}`);
|
||||
@@ -1364,7 +1364,7 @@ class CompendiumSuggestionData {
|
||||
collection: this.pack.collection,
|
||||
text: entity.name,
|
||||
resultId: entity.id,
|
||||
img: entity.data.img || null
|
||||
img: entity.img || null
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
Reference in New Issue
Block a user