// gk-greyknight — auto hooks + small tools menu Hooks.once("ready", () => { // Hook: when our Archetype is added, open Loadout Manager if (!window._gkAutoLoadoutHook) { window._gkAutoLoadoutHook = Hooks.on("createItem", async (item, opts, userId) => { try { if (item?.type !== "archetype") return; if (item?.name !== "Grey Knight (Archetype)") return; const actor = item.parent; if (!actor || game.userId !== userId) return; const code = await (await fetch("/modules/gk-greyknight/scripts/macros/gk-loadout-manager.js")).text(); (0, eval)(code); } catch (e) { console.error("gk-greyknight auto-loadout error", e); } }); } game.settings.registerMenu("gk-greyknight", "tools", { name: "Grey Knight Tools", label: "Open Tools", icon: "fas fa-shield-alt", type: class extends FormApplication { async _updateObject(event, formData) {} static get defaultOptions(){ return foundry.utils.mergeObject(super.defaultOptions, { id:"gk-tools", title:"Grey Knight Tools", template: null}); } async render(...args){ new Dialog({ title: "Grey Knight Tools", content: `
Quick actions for GK content.
`, buttons: { import: {label:"Import Items from Module", icon:"", callback: async ()=>{ const code = await (await fetch("/modules/gk-greyknight/scripts/macros/gk-import-from-module.js")).text(); (0, eval)(code); }}, loadout: {label:"Open Loadout Manager", icon:"", callback: async ()=>{ const code = await (await fetch("/modules/gk-greyknight/scripts/macros/gk-loadout-manager.js")).text(); (0, eval)(code); }}, glow: {label:"Toggle Aegis Glow", icon:"", callback: async ()=>{ const code = await (await fetch("/modules/gk-greyknight/scripts/macros/gk-glow-toggle.js")).text(); (0, eval)(code); }} }, default: "import" }).render(true); } }, restricted: true }); });