Added Send to chat to JournalEntry
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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 + `<br>` : "") + tpl,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 + `<br>` : "") + tpl,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Object|Promise}
|
||||
*/
|
||||
|
||||
@@ -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<string|null>}
|
||||
*/
|
||||
async renderTextTemplate() {
|
||||
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}journal/journal-text.html`, this);
|
||||
if (!tpl) {
|
||||
return null;
|
||||
}
|
||||
return tpl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
10
system/templates/journal/journal-text.html
Normal file
10
system/templates/journal/journal-text.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="{{cssClass}}" data-actor-id="{{actor.data._id}}" data-item-id="{{data._id}}">
|
||||
<header class="card-header">
|
||||
<h2 class="item-name">
|
||||
{{#if data.img}}<img src="{{data.img}}" title="{{data.name}}" />{{/if}} {{data.name}}
|
||||
</h2>
|
||||
</header>
|
||||
<section class="sheet-body">
|
||||
<p>{{{data.content}}}</p>
|
||||
</section>
|
||||
</div>
|
||||
Reference in New Issue
Block a user