Loading fix

This commit is contained in:
centron\schwoerer
2025-11-25 13:40:34 +01:00
parent 6de6353fab
commit 9bba7c82f6
3 changed files with 27 additions and 16 deletions

View File

@@ -3,7 +3,7 @@
"type": "module", "type": "module",
"title": "Gowler's Tracking Ledger", "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.", "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": [ "authors": [
{ "name": "Gowler", "url": "https://foundryvtt.com" } { "name": "Gowler", "url": "https://foundryvtt.com" }
], ],

View File

@@ -1,6 +1,6 @@
const MODULE_ID = "gowlers-tracking-ledger"; const MODULE_ID = "gowlers-tracking-ledger";
const MODULE_VERSION = "1.3.0"; const MODULE_VERSION = "1.3.2";
const TRACK_SETTING = "actorSettings"; const TRACK_SETTING = "actorSettings";
const FLAG_SCOPE = "world"; const FLAG_SCOPE = "world";
const MAX_HISTORY_ROWS = 100; const MAX_HISTORY_ROWS = 100;
@@ -292,12 +292,12 @@ Hooks.once("init", () => {
registerSettings(); registerSettings();
registerSettingsMenu(); registerSettingsMenu();
registerSceneControls(true);
}); });
Hooks.once("ready", async () => { Hooks.once("ready", async () => {
if (game.system.id !== "pf1") return; if (game.system.id !== "pf1") return;
await initializeModule(); await initializeModule();
registerSceneControls();
// Expose NPC toggle helper for damage meter checkbox // Expose NPC toggle helper for damage meter checkbox
window.GowlersTrackingDamageMeterToggleNPCs = (checked) => { window.GowlersTrackingDamageMeterToggleNPCs = (checked) => {
ledgerState.damageMeterIncludeNPCs = !!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) => { Hooks.on("getSceneControlButtons", (controls) => {
const tokenControls = controls.find((c) => c.name === "token"); const tokenControls = controls.find((c) => c.name === "token");
if (!tokenControls) return; 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() { function openDamageMeterOverlay() {
@@ -2504,6 +2514,7 @@ function primeDocBaseline(doc) {
if (actor) primeActor(actor); if (actor) primeActor(actor);
} }
function collectAllActorDocuments() { function collectAllActorDocuments() {
const actors = new Map(); const actors = new Map();
for (const a of game.actors.contents ?? []) { for (const a of game.actors.contents ?? []) {

View File

@@ -107,7 +107,7 @@ Hooks.once('init', () => {
}); });
const hideShowForPlayers = game.settings.get('searchanywhere', 'settingPlayers'); 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; return;
} }
@@ -668,7 +668,7 @@ class AutoCompletionField {
let folder = entity.folder; let folder = entity.folder;
while (folder !== null && !excluded) { while (folder !== null && !excluded) {
excluded = excludedFolders.includes(folder.id); 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; return excluded;
} }
@@ -1042,11 +1042,11 @@ class EntitySuggestionData {
get content() { get content() {
let content = ''; let content = '';
switch (this.entityType) { switch (this.entityType) {
case 'Actor': content = safeGet(this.entity, 'data.data.details.biography.value'); break; case 'Actor': content = safeGet(this.entity, 'system.details.biography.value'); break;
case 'Item': content = safeGet(this.entity, 'data.data.description.value'); break; case 'Item': content = safeGet(this.entity, 'system.description.value'); break;
case 'JournalEntry': content = safeGet(this.entity, 'data.content'); break; case 'JournalEntry': content = safeGet(this.entity, 'content'); break;
case 'RollTable': content = safeGet(this.entity, 'data.content'); break; case 'RollTable': content = safeGet(this.entity, 'description'); break;
case 'Playlist': content = safeGet(this.entity, 'data.description'); break; case 'Playlist': content = safeGet(this.entity, 'description'); break;
} }
return stripHtml(content); return stripHtml(content);
} }
@@ -1065,7 +1065,7 @@ class EntitySuggestionData {
get image() { get image() {
switch (this.entityType) { 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 'JournalEntry': return 'modules/searchanywhere/icons/book.svg';
case 'RollTable': return 'icons/svg/d20-grey.svg'; case 'RollTable': return 'icons/svg/d20-grey.svg';
} }
@@ -1161,7 +1161,7 @@ class EntitySuggestionData {
toSheet(sheetTd) { toSheet(sheetTd) {
let sheet = game.searchAnywhere.openedSheets.get(parseInt(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) { toTable(sheetTd) {
@@ -1172,7 +1172,7 @@ class EntitySuggestionData {
collection: this.entity.entity, collection: this.entity.entity,
text: this.entity.name, text: this.entity.name,
resultId: this.entity.id, 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) this.pack.getDocument(this.entry._id)
.then(entity => { .then(entity => {
let sheet = game.searchAnywhere.openedSheets.get(parseInt(sheetTd)); let sheet = game.searchAnywhere.openedSheets.get(parseInt(sheetTd));
sheet.actor.createEmbeddedDocuments("Item", [entity.data.toJSON()]); sheet.actor.createEmbeddedDocuments("Item", [entity.toObject()]);
}) })
.catch(err => { .catch(err => {
console.error(`Unable to add compendium item to sheet: ${err}`); console.error(`Unable to add compendium item to sheet: ${err}`);
@@ -1364,7 +1364,7 @@ class CompendiumSuggestionData {
collection: this.pack.collection, collection: this.pack.collection,
text: entity.name, text: entity.name,
resultId: entity.id, resultId: entity.id,
img: entity.data.img || null img: entity.img || null
}); });
}) })
.catch(err => { .catch(err => {