From 7fc8d2c09c1fe04aa0c610065c2d57af49581286 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Thu, 9 Jul 2026 07:49:12 +0200 Subject: [PATCH] feat: batch NPC import, ally/enemy gen, map sync, UI shortcuts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - batch NPC creator: import images from dir → actors (dedup, folder) - ally/enemy generator: data tables, D66 specials, tests (39 pass) - sector map sync: DialogV2 player view, socket v13/v14, sync click pos - actor/scene directory: shortcut buttons (Commerce, PNJ, Map, Sync vue) - closeImagePopout: GM closes player portraits via socket - canvasSync: force same canvas view on all players - FilePicker: v14 folder picker support with v13 fallback - cleanup: debug logs, template dedup, return guards --- module.json | 2 + scripts/SectorMapApp.js | 154 ++++++++++++++++++++++++--------- scripts/batchNpcCreator.js | 82 ++++++++++++++++++ scripts/npc.js | 1 + scripts/sector.js | 14 +-- scripts/sectorSocket.js | 108 +++++++++++++++++++++++ scripts/startupNotice.js | 2 +- styles/npc.css | 14 +-- templates/batch-npc-dialog.hbs | 41 +++------ templates/player-map.hbs | 3 + 10 files changed, 337 insertions(+), 84 deletions(-) create mode 100644 scripts/sectorSocket.js create mode 100644 templates/player-map.hbs diff --git a/module.json b/module.json index 317ccbc..1109d12 100644 --- a/module.json +++ b/module.json @@ -7,12 +7,14 @@ "verified": "13", "maximum": "14" }, + "socket": "true", "description": "Module de compendium et d'outils Mongoose Traveller 2e pour FoundryVTT écrit par JdR.Ninja.\nInclut les commandes /commerce, /pnj, /rencontre et /mission pour automatiser le commerce, les PNJ rapides, les rencontres et les contrats aléatoires. La fenêtre /pnj inclut un onglet 'PNJ Détaillé' pour la génération de PNJ Traveller selon les règles du générateur officiel, en s'appuyant sur les compétences natives des fiches.", "esmodules": [ "scripts/batchNpcCreator.js", "scripts/commerce.js", "scripts/npc.js", "scripts/sector.js", + "scripts/sectorSocket.js", "scripts/utils/travellerNpcUtils.js", "scripts/data/travellerNpcGenerator.js", "scripts/travellerNpcGenerator.js", diff --git a/scripts/SectorMapApp.js b/scripts/SectorMapApp.js index a5254f3..0ccbb56 100644 --- a/scripts/SectorMapApp.js +++ b/scripts/SectorMapApp.js @@ -19,12 +19,15 @@ export class SectorMapApp extends ApplicationV2 { window: { icon: 'fas fa-map', resizable: true, controls: [] }, }; - constructor(sector, subsector) { + constructor(sector, subsector, { readOnly = false } = {}) { super(); this._sector = sector; this._subsector = subsector; + this._readOnly = readOnly; this._handler = null; this._mapHex = null; + this._mapCenter = null; + this._mapScale = null; this._searchTimeout = null; } @@ -37,13 +40,16 @@ export class SectorMapApp extends ApplicationV2 { get _mapUrl() { const base = 'https://travellermap.com'; + const cb = this._readOnly ? '' : '&callback=postmessage'; if (!this._sector) return `${base}/?style=mongoose&hideui=1`; if (this._subsector) { - return `${base}/?sector=${encodeURIComponent(this._sector)}&subsector=${encodeURIComponent(this._subsector)}&style=mongoose&hideui=1`; + return `${base}/?sector=${encodeURIComponent(this._sector)}&subsector=${encodeURIComponent(this._subsector)}&style=mongoose&hideui=1${cb}`; } - let url = `${base}/go/${encodeURIComponent(this._sector)}?style=mongoose`; + let url = `${base}/?sector=${encodeURIComponent(this._sector)}&style=mongoose&hideui=1${cb}`; if (this._mapHex) { url += `&hex=${this._mapHex}&scale=512`; + } else if (this._mapCenter && this._mapScale) { + url += `¢er=${this._mapCenter}&scale=${this._mapScale}`; } return url; } @@ -58,6 +64,20 @@ export class SectorMapApp extends ApplicationV2 { } _renderHTML() { + if (this._readOnly) { + return `
+
+ ${SectorMapApp._escapeAttr(this.title)} + Carte partagée par le MJ +
+ +
`; + } return `
${this._sector ? `${this._sector}${this._subsector ? ` — ss.${this._subsector}` : ''}` : 'Toute la carte'} Cliquez sur un hex pour voir les détails du monde - - +
+