diff --git a/CHANGELOG.md b/CHANGELOG.md
index b3eee65..0201ee0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,7 @@
# Changelog
## 1.3.3 - TODO
-- Added "send to chat" button on items sheets.
+- Added "send to chat" header button on Item and Journal sheets.
- Added Opportunity usage helper Compendium.
- Fixed Compendium entries thanks to TesserWract :
- Utaku Battle Maiden: Replace "Striking as Air" with "Courtier's Resolve".
diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json
index 3a06cc4..c1659d8 100644
--- a/system/lang/fr-fr.json
+++ b/system/lang/fr-fr.json
@@ -42,7 +42,7 @@
"edit": "Modifier",
"delete_confirm": "Etes-vous sûr de vouloir supprimer '{name}' ?",
"drop_here": "Déposez ici",
- "send_to_chat": "Env. dans la Conv.",
+ "send_to_chat": "Env. dans la conv.",
"edge_translation_disclaimer": ""
},
"logo": {
diff --git a/system/scripts/helpers.js b/system/scripts/helpers.js
index 9bf1958..e88382d 100644
--- a/system/scripts/helpers.js
+++ b/system/scripts/helpers.js
@@ -483,4 +483,29 @@ export class HelpersL5r5e {
}
return item;
}
+
+ /**
+ * Send the description of this Item to chat
+ * @param {JournalL5r5e|ItemSheetL5r5e} object
+ * @return {Promise<*>}
+ */
+ static async sendToChat(object) {
+ const tpl = await object.renderTextTemplate();
+ if (!tpl) {
+ return;
+ }
+
+ let link = null;
+ if (object.data.flags.core?.sourceId) {
+ link = object.data.flags.core?.sourceId.replace(/(\w+)\.(.+)/, "@$1[$2]");
+ } else if (object.pack) {
+ link = `@Compendium[${object.pack}.${object.id}]{${object.name}}`;
+ } else if (!object.actor) {
+ link = object.link;
+ }
+
+ return ChatMessage.create({
+ content: (link ? link + `
` : "") + tpl,
+ });
+ }
}
diff --git a/system/scripts/items/item-sheet.js b/system/scripts/items/item-sheet.js
index adad52e..a1bded3 100644
--- a/system/scripts/items/item-sheet.js
+++ b/system/scripts/items/item-sheet.js
@@ -24,38 +24,14 @@ export class ItemSheetL5r5e extends ItemSheet {
// Send To Chat
buttons.unshift({
label: game.i18n.localize("l5r5e.global.send_to_chat"),
- class: "twenty-questions",
+ class: "send-to-chat",
icon: "fas fa-comment-dots",
- onclick: async () => this.sendToChat(),
+ onclick: async () => game.l5r5e.HelpersL5r5e.sendToChat(this.object),
});
return buttons;
}
- /**
- * Send the description of this Item to chat
- * @return {Promise<*>}
- */
- async sendToChat() {
- const tpl = await this.object.renderTextTemplate();
- if (!tpl) {
- return;
- }
-
- let link = null;
- if (this.object.data.flags.core?.sourceId) {
- link = this.object.data.flags.core?.sourceId.replace(/(\w+)\.(.+)/, "@$1[$2]");
- } else if (this.object.pack) {
- link = `@Compendium[${this.object.pack}.${this.object.id}]{${this.object.name}}`;
- } else if (!this.object.actor) {
- link = this.object.link;
- }
-
- return ChatMessage.create({
- content: (link ? link + `
` : "") + tpl,
- });
- }
-
/**
* @return {Object|Promise}
*/
diff --git a/system/scripts/journal.js b/system/scripts/journal.js
index c05f99b..b148501 100644
--- a/system/scripts/journal.js
+++ b/system/scripts/journal.js
@@ -1,4 +1,16 @@
/**
* Extends the JournalEntity to process special things from L5R.
*/
-export class JournalL5r5e extends JournalEntry {}
+export class JournalL5r5e extends JournalEntry {
+ /**
+ * Render the text template for this Journal (tooltips and chat)
+ * @return {Promise}
+ */
+ async renderTextTemplate() {
+ const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}journal/journal-text.html`, this);
+ if (!tpl) {
+ return null;
+ }
+ return tpl;
+ }
+}
diff --git a/system/scripts/journals/base-journal-sheet.js b/system/scripts/journals/base-journal-sheet.js
index 6aa1a69..e45f267 100644
--- a/system/scripts/journals/base-journal-sheet.js
+++ b/system/scripts/journals/base-journal-sheet.js
@@ -3,6 +3,35 @@
* @extends {JournalSheet}
*/
export class BaseJournalSheetL5r5e extends JournalSheet {
+ // /** @override */
+ // static get defaultOptions() {
+ // return foundry.utils.mergeObject(super.defaultOptions, {
+ // classes: ["l5r5e", "sheet", "journal"], // app window-app sheet journal-sheet
+ // template: CONFIG.l5r5e.paths.templates + "journal/journal-sheet.html",
+ // width: 520,
+ // height: 480,
+ // tabs: [{ navSelector: ".journal-tabs", contentSelector: ".journal-body", initial: "description" }],
+ // });
+ // }
+
+ /**
+ * Add the SendToChat button on top of sheet
+ * @override
+ */
+ _getHeaderButtons() {
+ let buttons = super._getHeaderButtons();
+
+ // Send To Chat
+ buttons.unshift({
+ label: game.i18n.localize("l5r5e.global.send_to_chat"),
+ class: "send-to-chat",
+ icon: "fas fa-comment-dots",
+ onclick: async () => game.l5r5e.HelpersL5r5e.sendToChat(this.object),
+ });
+
+ return buttons;
+ }
+
/**
* Activate a named TinyMCE text editor
* @param {string} name The named data field which the editor modifies.
@@ -25,7 +54,6 @@ export class BaseJournalSheetL5r5e extends JournalSheet {
* @override
*/
async _updateObject(event, formData) {
- // event.type = mcesave / submit
if (formData.content) {
formData.content = game.l5r5e.HelpersL5r5e.convertSymbols(formData.content, true);
}
diff --git a/system/templates/journal/journal-text.html b/system/templates/journal/journal-text.html
new file mode 100644
index 0000000..531ed2d
--- /dev/null
+++ b/system/templates/journal/journal-text.html
@@ -0,0 +1,10 @@
+