Image du token pour les Commerces non liés

This commit is contained in:
Vincent Vandemeulebrouck 2023-01-15 21:32:32 +01:00
parent c972913a67
commit 40fdff4057
3 changed files with 36 additions and 8 deletions

View File

@ -22,17 +22,38 @@ export class RdDCommerceSheet extends RdDBaseActorSheet {
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: undefined }] dragDrop: [{ dragSelector: ".item-list .item", dropSelector: undefined }]
}); });
} }
get title() {
if (this.actor.token && this.actor.token != this.actor.prototypeToken) {
return this.actor.token.name;
}
return super.title
}
async getData() {
const formData = await super.getData();
if (this.actor.token && this.actor.token != this.actor.prototypeToken) {
mergeObject(formData,
{
title: this.actor.token.name,
token: {
img: this.actor.token.texture.src
}
},
{ overwrite: true });
}
return formData;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html.find('a.item-acheter').click(async event => await this.vente(this.getItem(event))); this.html.find('a.item-acheter').click(async event => await this.vente(this.getItem(event)));
if (!this.options.editable) return; if (!this.options.editable) return;
this.html.find('a.item-quantite-moins').click(async event => await this.getItem(event)?.quantiteIncDec(-1, { supprimerSiZero: false})); this.html.find('a.item-quantite-moins').click(async event => await this.getItem(event)?.quantiteIncDec(-1, { supprimerSiZero: false }));
this.html.find('a.item-quantite-plus').click(async event => await this.getItem(event)?.quantiteIncDec(1)); this.html.find('a.item-quantite-plus').click(async event => await this.getItem(event)?.quantiteIncDec(1));
this.html.find('input.item-quantite').change(async event => { this.html.find('input.item-quantite').change(async event => {
const newQuantite = Math.max(0, Number.parseInt(this.html.find(event.currentTarget).val())); const newQuantite = Math.max(0, Number.parseInt(this.html.find(event.currentTarget).val()));
@ -48,7 +69,7 @@ export class RdDCommerceSheet extends RdDBaseActorSheet {
return RdDItem.getItemTypesInventaire('all'); return RdDItem.getItemTypesInventaire('all');
} }
async vente(item) { async vente(item) {
const acheteur = RdDUtility.getSelectedActor(); const acheteur = RdDUtility.getSelectedActor();
if (!acheteur) { if (!acheteur) {

View File

@ -174,11 +174,11 @@ i:is(.fas, .far) {
margin-bottom: -8px; margin-bottom: -8px;
} }
.system-foundryvtt-reve-de-dragon .sheet-header :is(.header-compteurs,.header-etats,.profile-img){ .system-foundryvtt-reve-de-dragon .sheet-header :is(.header-compteurs,.header-etats,.profile-img, .profile-img-token){
padding: 0 3%; padding: 0 3%;
} }
.system-foundryvtt-reve-de-dragon .sheet-header .profile-img { .system-foundryvtt-reve-de-dragon .sheet-header :is(.profile-img, .profile-img-token) {
-webkit-box-flex: 0; -webkit-box-flex: 0;
-ms-flex: 0 0 110px; -ms-flex: 0 0 110px;
flex: 0 0 110px; flex: 0 0 110px;
@ -492,7 +492,7 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
max-height: 1.5em; max-height: 1.5em;
border-width: 0; border-width: 0;
} }
div.dimmed .img-signe-heure { .dimmed {
opacity: 50%; opacity: 50%;
} }
.button-effect-img { .button-effect-img {
@ -844,7 +844,7 @@ form.rdddialogchrono input[type=datetime-local] {
section.sheet-body{padding: 0.25rem 0.5rem;} section.sheet-body{padding: 0.25rem 0.5rem;}
.sheet header.sheet-header .profile-img { .sheet header.sheet-header :is(.profile-img, .profile-img-token) {
object-fit: scale-down; object-fit: scale-down;
object-position: 50% 0; object-position: 50% 0;
margin: 0.5rem 0 0.5rem 0.5rem; margin: 0.5rem 0 0.5rem 0.5rem;

View File

@ -4,7 +4,14 @@
<header class="sheet-header"> <header class="sheet-header">
<div class="header-fields"> <div class="header-fields">
<div class="flexrow"> <div class="flexrow">
{{#if token}}
{{#if options.isOwner}}
<img class="profile-img dimmed" src="{{img}}" data-edit="img" title="{{name}}" />
{{/if}}
<img class="profile-img-token" src="{{token.img}}" title="{{name}}" />
{{else}}
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" /> <img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
{{/if}}
<div class="flexcol"> <div class="flexcol">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1> <h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
{{#if @root.options.isObserver}} {{#if @root.options.isObserver}}