From 5969009eb1c58633a01d4ee655469515506790a7 Mon Sep 17 00:00:00 2001 From: fabres Date: Wed, 15 Jul 2026 17:32:59 +0200 Subject: [PATCH] feat(inventaire): boutons +Ration/+Eau, cartouche chat compact MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Boutons +Ration et +Eau dans l'onglet Équipement - Incrémente la quantité si l'item existe déjà, sinon le crée - Nouveau template post-item-compact.hbs pour l'aperçu chat - _MONTRER utilise désormais le cartouche compact - postItemToChatCompact() awaitable, champs filtrés par type d'inventaire --- css/foundryvtt-reve-de-dragon.css | 9 +++++++++ less/foundryvtt-reve-de-dragon.less | 11 +++++++++++ module/actor/base-actor-sheet.js | 26 ++++++++++++++++++++++++++ module/item.js | 23 +++++++++++++++++++++++ module/item/item-actions.js | 2 +- templates/actor/inventaire.hbs | 2 ++ templates/post-item-compact.hbs | 16 ++++++++++++++++ 7 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 templates/post-item-compact.hbs diff --git a/css/foundryvtt-reve-de-dragon.css b/css/foundryvtt-reve-de-dragon.css index 85c83b5f..cff8e358 100644 --- a/css/foundryvtt-reve-de-dragon.css +++ b/css/foundryvtt-reve-de-dragon.css @@ -2504,6 +2504,15 @@ body { height: 100%; object-fit: contain; } +.system-foundryvtt-reve-de-dragon .post-item-compact .tag { + display: inline-block; + background: rgba(0, 0, 0, 0.05); + border-radius: 3px; + padding: 0 0.35rem; + margin: 0.1rem; + font-size: 0.75rem; + white-space: nowrap; +} .system-foundryvtt-reve-de-dragon .chat-inline-icon { border: 0; padding: 0 0.2rem; diff --git a/less/foundryvtt-reve-de-dragon.less b/less/foundryvtt-reve-de-dragon.less index e56a2713..774dd9ca 100644 --- a/less/foundryvtt-reve-de-dragon.less +++ b/less/foundryvtt-reve-de-dragon.less @@ -1889,6 +1889,17 @@ height: 100%; object-fit: contain; } + .post-item-compact { + .tag { + display: inline-block; + background: rgba(0,0,0,0.05); + border-radius: 3px; + padding: 0 0.35rem; + margin: 0.1rem; + font-size: 0.75rem; + white-space: nowrap; + } + } .chat-inline-icon { border: 0; padding: 0 0.2rem; diff --git a/module/actor/base-actor-sheet.js b/module/actor/base-actor-sheet.js index ef77ec94..ef10d397 100644 --- a/module/actor/base-actor-sheet.js +++ b/module/actor/base-actor-sheet.js @@ -166,6 +166,32 @@ export class RdDBaseActorSheet extends foundry.appv1.sheets.ActorSheet { this.html.find('.creer-un-objet').click(async event => await this.selectObjetTypeToCreate()) this.html.find('.nettoyer-conteneurs').click(async event => await this.actor.nettoyerConteneurs()) + this.html.find('.quick-add-ration').click(async event => { + const existante = this.actor.items.find(it => it.type === "nourritureboisson" && it.name === "Ration") + if (existante) { + await existante.update({ "system.quantite": Math.max(0, Number(existante.system.quantite) + 1) }) + } else { + await this.actor.createEmbeddedDocuments('Item', [{ + name: "Ration", type: "nourritureboisson", + img: "systems/foundryvtt-reve-de-dragon/icons/objets/provision_crue.webp", + system: { sust: 1, encombrement: 0.1, quantite: 1, cout: 0.1, boisson: false } + }], { renderSheet: false }) + } + this.render(true) + }) + this.html.find('.quick-add-eau').click(async event => { + const existante = this.actor.items.find(it => it.type === "nourritureboisson" && it.name === "Eau") + if (existante) { + await existante.update({ "system.quantite": Math.max(0, Number(existante.system.quantite) + 1) }) + } else { + await this.actor.createEmbeddedDocuments('Item', [{ + name: "Eau", type: "nourritureboisson", + img: "systems/foundryvtt-reve-de-dragon/icons/objets/outre.webp", + system: { desaltere: 1, encombrement: 0.1, quantite: 1, cout: 0.05, boisson: true } + }], { renderSheet: false }) + } + this.render(true) + }) this.html.find('.vue-detaillee').click(async event => { this.options.vueDetaillee = !this.options.vueDetaillee diff --git a/module/item.js b/module/item.js index 6970f518..e38d77d3 100644 --- a/module/item.js +++ b/module/item.js @@ -640,6 +640,29 @@ export class RdDItem extends Item { return 'systems/foundryvtt-reve-de-dragon/templates/post-item.hbs' } + async postItemToChatCompact(modeOverride) { + const typeLabel = game.i18n.localize(`TYPES.Item.${this.type}`) + const stats = this.getProprietes().slice(0, 3) + const isInventaire = RdDItem.getItemTypesInventaire('all').includes(this.type) + let chatData = { + doctype: 'Item', + id: this.id, + type: this.type, + img: this.img, + pack: this.pack, + name: this.name, + actor: this.actor ? { id: this.actor.id } : undefined, + typeLabel, + encombrement: isInventaire ? (this.system.encombrement ?? 0) : undefined, + cout: isInventaire ? (this.system.cout ?? 0) : undefined, + quantite: isInventaire ? (this.getQuantite() ?? 1) : undefined, + stats + } + const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/post-item-compact.hbs', chatData) + let chatOptions = RdDUtility.chatDataSetup(html, modeOverride); + await ChatMessage.create(chatOptions) + } + static propertyIfDefined(name, val, condition = true) { return condition ? `${name}: ${val}` : undefined; } diff --git a/module/item/item-actions.js b/module/item/item-actions.js index 7fc7e4fe..a16a69ed 100644 --- a/module/item/item-actions.js +++ b/module/item/item-actions.js @@ -24,7 +24,7 @@ const _ACHETER = { const _MONTRER = { code: 'item-montrer', label: 'Montrer', icon: 'fa-solid fa-comment', allowLimited: true, - action: (item, actor) => item.postItemToChat() + action: (item, actor) => item.postItemToChatCompact() } const _SPLIT = { code: 'item-split', label: 'Séparer le goupe', icon: 'fa-solid fa-unlink', diff --git a/templates/actor/inventaire.hbs b/templates/actor/inventaire.hbs index 31b43afa..bfb19e0d 100644 --- a/templates/actor/inventaire.hbs +++ b/templates/actor/inventaire.hbs @@ -1,6 +1,8 @@ {{#if options.isOwner}} Nouvel objet + + Ration + + Eau {{/if}} {{#if options.isGM}} Tout vider diff --git a/templates/post-item-compact.hbs b/templates/post-item-compact.hbs new file mode 100644 index 00000000..66bb9638 --- /dev/null +++ b/templates/post-item-compact.hbs @@ -0,0 +1,16 @@ +
+

{{name}}

+

+ {{typeLabel}} + {{#if (ne encombrement undefined)}}Enc. {{encombrement}}{{/if}} + {{#if (ne cout undefined)}}{{cout}} sols{{/if}} + {{#if (ne quantite undefined)}}x{{quantite}}{{/if}} +

+ {{#if stats.length}} +

+ {{#each stats as |s|}} + {{{s}}} + {{/each}} +

+ {{/if}} +