feat(inventaire): boutons +Ration/+Eau, cartouche chat compact
- 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
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ? `<b>${name}</b>: ${val}` : undefined;
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<span class="item-name">
|
||||
{{#if options.isOwner}}
|
||||
<a class="chat-card-button creer-un-objet" data-tooltip="Créer un nouvel objet">Nouvel objet</a>
|
||||
<a class="chat-card-button quick-add-ration" data-tooltip="Ajouter une ration">+ Ration</a>
|
||||
<a class="chat-card-button quick-add-eau" data-tooltip="Ajouter une outre d'eau">+ Eau</a>
|
||||
{{/if}}
|
||||
{{#if options.isGM}}
|
||||
<a class="chat-card-button nettoyer-conteneurs" data-tooltip="Vider tous les contenants">Tout vider</a>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<div class="post-item-compact">
|
||||
<h4><img class="chat-icon" src="{{img}}" /> {{name}}</h4>
|
||||
<p>
|
||||
<span class="tag">{{typeLabel}}</span>
|
||||
{{#if (ne encombrement undefined)}}<span class="tag">Enc. {{encombrement}}</span>{{/if}}
|
||||
{{#if (ne cout undefined)}}<span class="tag">{{cout}} sols</span>{{/if}}
|
||||
{{#if (ne quantite undefined)}}<span class="tag">x{{quantite}}</span>{{/if}}
|
||||
</p>
|
||||
{{#if stats.length}}
|
||||
<p>
|
||||
{{#each stats as |s|}}
|
||||
<span class="tag">{{{s}}}</span>
|
||||
{{/each}}
|
||||
</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
Reference in New Issue
Block a user