From a8389a7cc11b4025d96c72ee56a749db56b33483 Mon Sep 17 00:00:00 2001 From: Vlyan Date: Thu, 5 Aug 2021 14:48:01 +0200 Subject: [PATCH] Added "send to chat" header button on Actor sheets --- CHANGELOG.md | 6 +++--- system/lang/en-en.json | 2 +- system/lang/es-es.json | 2 +- system/lang/fr-fr.json | 2 +- system/scripts/actor.js | 12 ++++++++++++ system/scripts/actors/base-sheet.js | 18 ++++++++++++++++++ system/templates/actors/actor-text.html | 11 +++++++++++ 7 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 system/templates/actors/actor-text.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 0201ee0..cc6ae7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Changelog -## 1.3.3 - TODO -- Added "send to chat" header button on Item and Journal sheets. -- Added Opportunity usage helper Compendium. +## 1.3.3 - Send to Chat +- Added "send to chat" header button on Actor, Item and Journal sheets. +- Added Opportunity usage helper Compendium (courteously authorized by Edge). - Fixed Compendium entries thanks to TesserWract : - Utaku Battle Maiden: Replace "Striking as Air" with "Courtier's Resolve". - Weapons: Chair, lute, sake bottle and cups, and scroll case use the "Unarmed skill" and changed the umbrella's stab grip to be 2-handed. diff --git a/system/lang/en-en.json b/system/lang/en-en.json index 3cecc5b..738755f 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -42,7 +42,7 @@ "edit": "Edit", "delete_confirm": "Are you sure you want to delete '{name}' ?", "drop_here": "Drop here", - "send_to_chat": "Send to Chat", + "send_to_chat": "To Chat", "edge_translation_disclaimer": "" }, "logo": { diff --git a/system/lang/es-es.json b/system/lang/es-es.json index d5be9a7..f6db1d0 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -42,7 +42,7 @@ "edit": "Editar", "delete_confirm": "¿Estás seguro de que quieres borrar '{name}' ?", "drop_here": "Dejar caer aquí", - "send_to_chat": "Send to Chat", + "send_to_chat": "To Chat", "edge_translation_disclaimer": "Edge Studio nos da su permiso para ofrecer este módulo a la comunidad, pero tanto los textos así como los códigos que lo constituyen no tienen su aprobación explícita." }, "logo": { diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index c1659d8..0ad550e 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": "Vers Conv.", "edge_translation_disclaimer": "" }, "logo": { diff --git a/system/scripts/actor.js b/system/scripts/actor.js index d0b85aa..8627634 100644 --- a/system/scripts/actor.js +++ b/system/scripts/actor.js @@ -186,4 +186,16 @@ export class ActorL5r5e extends Actor { }); } } + + /** + * Render the text template for this Actor (tooltips and chat) + * @return {Promise} + */ + async renderTextTemplate() { + const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}actors/actor-text.html`, this); + if (!tpl) { + return null; + } + return tpl; + } } diff --git a/system/scripts/actors/base-sheet.js b/system/scripts/actors/base-sheet.js index fb7667c..b8eedb2 100644 --- a/system/scripts/actors/base-sheet.js +++ b/system/scripts/actors/base-sheet.js @@ -16,6 +16,24 @@ export class BaseSheetL5r5e extends ActorSheet { }); } + /** + * 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; + } + /** @inheritdoc */ getData(options = {}) { const sheetData = super.getData(options); diff --git a/system/templates/actors/actor-text.html b/system/templates/actors/actor-text.html new file mode 100644 index 0000000..3af32e9 --- /dev/null +++ b/system/templates/actors/actor-text.html @@ -0,0 +1,11 @@ +
+
+

+ {{data.name}} +

+
+
+ {{#if data.img}}

{{/if}} + {{#if data.data.description}}

{{{data.data.description}}}

{{/if}} +
+