|
1 | | -import { MODULE_ID, PIN_COLORS } from "../config.js"; |
| 1 | +import { MODULE_ID, PIN_COLORS, STICKY_TINTS, INK_COLORS } from "../config.js"; |
2 | 2 | import { collaborativeUpdate } from "../utils/socket-handler.js"; |
3 | 3 | import { applyTapeEffectToSound } from "../utils/audio-utils.js"; |
4 | 4 | import { |
@@ -67,6 +67,10 @@ export class CustomDrawingSheet extends DrawingConfig { |
67 | 67 | context.font = customData.font; |
68 | 68 | context.fontSize = customData.fontSize; |
69 | 69 | context.audioEffectEnabled = customData.audioEffectEnabled; |
| 70 | + context.tint = customData.tint; |
| 71 | + context.textColor = customData.textColor; |
| 72 | + context.stickyTints = customData.stickyTints; |
| 73 | + context.inkColors = customData.inkColors; |
70 | 74 |
|
71 | 75 | // Enrich the linked object for display |
72 | 76 | context.enrichedLinkedObject = context.linkedObject ? await TextEditor.enrichHTML(context.linkedObject, { async: true }) : ""; |
@@ -116,6 +120,10 @@ export class CustomDrawingSheet extends DrawingConfig { |
116 | 120 | image: this.document.flags[MODULE_ID]?.image || (noteType === "handout" ? "modules/investigation-board/assets/newhandout.webp" : "modules/investigation-board/assets/placeholder.webp"), |
117 | 121 | font: this.document.flags[MODULE_ID]?.font || game.settings.get(MODULE_ID, "font"), |
118 | 122 | fontSize: this.document.flags[MODULE_ID]?.fontSize || defaultFontSize, |
| 123 | + tint: this.document.flags[MODULE_ID]?.tint || "#ffffff", |
| 124 | + textColor: this.document.flags[MODULE_ID]?.textColor || "#000000", |
| 125 | + stickyTints: STICKY_TINTS, |
| 126 | + inkColors: INK_COLORS, |
119 | 127 | connections: formattedConnections, |
120 | 128 | noteTypes: { |
121 | 129 | sticky: "Sticky Note", |
@@ -341,6 +349,35 @@ export class CustomDrawingSheet extends DrawingConfig { |
341 | 349 | }); |
342 | 350 | } |
343 | 351 |
|
| 352 | + // Handle color selection |
| 353 | + this.element.querySelectorAll(".color-option").forEach(opt => { |
| 354 | + opt.addEventListener("click", async (ev) => { |
| 355 | + ev.preventDefault(); |
| 356 | + const color = opt.dataset.color; |
| 357 | + const type = opt.dataset.type; // 'tint' or 'textColor' |
| 358 | + const hiddenInput = this.element.querySelector(`input[name='${type}']`); |
| 359 | + |
| 360 | + if (hiddenInput) { |
| 361 | + hiddenInput.value = color; |
| 362 | + |
| 363 | + // Update UI |
| 364 | + opt.parentElement.querySelectorAll(".color-option").forEach(o => o.classList.remove("active")); |
| 365 | + opt.classList.add("active"); |
| 366 | + |
| 367 | + // Real-time update (collaborative) |
| 368 | + await collaborativeUpdate(this.document.id, { |
| 369 | + [`flags.${MODULE_ID}.${type}`]: color |
| 370 | + }); |
| 371 | + |
| 372 | + // Refresh the drawing on canvas |
| 373 | + const drawing = canvas.drawings.get(this.document.id); |
| 374 | + if (drawing) { |
| 375 | + await drawing.refresh(); |
| 376 | + } |
| 377 | + } |
| 378 | + }); |
| 379 | + }); |
| 380 | + |
344 | 381 | const form = this.element.querySelector("form"); |
345 | 382 | if (form) { |
346 | 383 | // Handle cancel button |
@@ -418,6 +455,14 @@ export class CustomDrawingSheet extends DrawingConfig { |
418 | 455 | } |
419 | 456 | } |
420 | 457 |
|
| 458 | + if (data.tint !== undefined) { |
| 459 | + updates[`flags.${MODULE_ID}.tint`] = data.tint; |
| 460 | + } |
| 461 | + |
| 462 | + if (data.textColor !== undefined) { |
| 463 | + updates[`flags.${MODULE_ID}.textColor`] = data.textColor; |
| 464 | + } |
| 465 | + |
421 | 466 | // Process connection color changes |
422 | 467 | const connections = this.document.flags[MODULE_ID]?.connections || []; |
423 | 468 | connections.forEach((conn, index) => { |
|
0 commit comments