diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 221b4ae7..7103aeff 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -66,9 +66,9 @@ export class RdDActorSheet extends RdDBaseActorSheet {
formData.calc.fatigue = RdDUtility.calculFatigueHtml(formData.system.sante.fatigue.value, formData.system.sante.endurance.max);
formData.competences.forEach(item => {
- item.system.isVisible = this.options.recherche
- ? RdDItemCompetence.nomContientTexte(item, this.options.recherche.text)
- : (!this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item));
+ item.system.isHidden = this.options.recherche
+ ? !item.isNomLike(this.options.recherche.text)
+ : (this.options.showCompNiveauBase && RdDItemCompetence.isNiveauBase(item));
RdDItemCompetence.levelUp(item, formData.system.compteurs.experience.value);
});
@@ -354,29 +354,6 @@ export class RdDActorSheet extends RdDBaseActorSheet {
this.render(true);
});
- this.html.find('.recherche')
- .each((index, field) => {
- if (this.options.recherche) {
- field.focus();
- field.setSelectionRange(this.options.recherche.start, this.options.recherche.end);
- }
- })
- .keyup(async event => {
- const nouvelleRecherche = this._optionRecherche(event.currentTarget);
- if (this.options.recherche?.text != nouvelleRecherche?.text) {
- this.options.recherche = nouvelleRecherche;
- if (this.timerRecherche) {
- clearTimeout(this.timerRecherche);
- }
- this.timerRecherche = setTimeout(() => {
- this.timerRecherche = undefined;
- this.render(true);
- }, 500);
- }
- })
- .change(async event =>
- this.options.recherche = this._optionRecherche(event.currentTarget)
- );
this.html.find('.vue-detaillee').click(async event => {
this.options.vueDetaillee = !this.options.vueDetaillee;
this.render(true);
@@ -486,16 +463,6 @@ export class RdDActorSheet extends RdDBaseActorSheet {
async createEmptyTache() {
await this.actor.createItem('tache', 'Nouvelle tache');
}
- _optionRecherche(target) {
- if (!target.value?.length) {
- return undefined;
- }
- return {
- text: target.value,
- start: target.selectionStart,
- end: target.selectionEnd,
- };
- }
_getEventArmeCombat(event) {
const li = this.html.find(event.currentTarget)?.parents(".item");
diff --git a/module/actor/base-actor-sheet.js b/module/actor/base-actor-sheet.js
index e0d92bd1..c4d09424 100644
--- a/module/actor/base-actor-sheet.js
+++ b/module/actor/base-actor-sheet.js
@@ -52,10 +52,30 @@ export class RdDBaseActorSheet extends ActorSheet {
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
-
+ this._appliquerRechercheObjets(formData.objets, formData.conteneurs, this.options.recherche);
return formData;
}
+ _appliquerRechercheObjets(objets, conteneurs, recherche) {
+ if (recherche) {
+ this._setConteneursVisibles(objets, conteneurs);
+ }
+ }
+
+ _setConteneursVisibles(objets, conteneurs) {
+ const recherche = this.options.recherche;
+ const allVisible = objets.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id);
+ let addVisible = conteneurs.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id)
+ do {
+ allVisible.push(...addVisible)
+ const parentsIds = conteneurs.filter(it => it.system.contenu.find(id => allVisible.includes(id))).map(it => it.id)
+ addVisible = parentsIds.filter(id => !allVisible.includes(id))
+ }
+ while (addVisible.length > 0)
+ objets.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
+ conteneurs.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
+ }
+
/* -------------------------------------------- */
static filterItemsPerTypeForSheet(formData, itemTypes) {
formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']);
@@ -140,6 +160,38 @@ export class RdDBaseActorSheet extends ActorSheet {
this.html.find('.monnaie-moins').click(async event => {
this.actor.monnaieIncDec(this.getItemId(event), -1);
});
+ this.html.find('.recherche')
+ .each((index, field) => {
+ this._rechercheSelectArea(field);
+ })
+ .keyup(async event => {
+ this._rechercherKeyup(event);
+ })
+ .change(async event =>
+ this.options.recherche = this._optionRecherche(event.currentTarget)
+ );
+ }
+
+ _rechercherKeyup(event) {
+ const currentTarget = event.currentTarget;
+ const nouvelleRecherche = this._optionRecherche(currentTarget);
+ if (this.options.recherche?.text != nouvelleRecherche?.text) {
+ this.options.recherche = nouvelleRecherche;
+ if (this.timerRecherche) {
+ clearTimeout(this.timerRecherche);
+ }
+ this.timerRecherche = setTimeout(() => {
+ this.timerRecherche = undefined;
+ this.render(true);
+ }, 500);
+ }
+ }
+
+ _rechercheSelectArea(field) {
+ if (this.options.recherche) {
+ field.focus();
+ field.setSelectionRange(this.options.recherche.start, this.options.recherche.end);
+ }
}
getItemId(event) {
@@ -150,6 +202,16 @@ export class RdDBaseActorSheet extends ActorSheet {
return RdDSheetUtility.getItem(event, this.actor);
}
+ _optionRecherche(target) {
+ if (!target.value?.length) {
+ return undefined;
+ }
+ return {
+ text: target.value,
+ start: target.selectionStart,
+ end: target.selectionEnd,
+ };
+ }
/* -------------------------------------------- */
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
diff --git a/module/item-competence.js b/module/item-competence.js
index 8772c75b..be1039ca 100644
--- a/module/item-competence.js
+++ b/module/item-competence.js
@@ -190,15 +190,6 @@ export class RdDItemCompetence extends Item {
}
}
- /* -------------------------------------------- */
- static isVisible(item) {
- return Number(item.system.niveau) != RdDItemCompetence.getNiveauBase(item.system.categorie);
- }
-
- static nomContientTexte(item, texte) {
- return Grammar.toLowerCaseNoAccent(item.name).includes(Grammar.toLowerCaseNoAccent(texte))
- }
-
/* -------------------------------------------- */
static isNiveauBase(item) {
return Number(item.system.niveau) == RdDItemCompetence.getNiveauBase(item.system.categorie);
@@ -279,7 +270,7 @@ export class RdDItemCompetence extends Item {
/* -------------------------------------------- */
static triVisible(competences) {
- return competences.filter(it => it.system.isVisible)
+ return competences.filter(it => !it.system.isHidden)
.sort((a, b) => RdDItemCompetence.compare(a, b))
}
diff --git a/module/item.js b/module/item.js
index 11cb6614..74b59594 100644
--- a/module/item.js
+++ b/module/item.js
@@ -304,6 +304,13 @@ export class RdDItem extends Item {
return this.parent?.type == 'commerce';
}
+ isNomLike(texte) {
+ return Grammar.includesLowerCaseNoAccent(this.name, texte)
+ }
+ isNomTypeLike(texte) {
+ return this.isNomLike(texte) || Grammar.includesLowerCaseNoAccent(Misc.typeName(this.type, 'Item'), texte)
+ }
+
getQuantite() {
return this.isService() ? undefined : Math.round(this.system.quantite ?? 0)
}
diff --git a/styles/simple.css b/styles/simple.css
index 40221b90..e5999b92 100644
--- a/styles/simple.css
+++ b/styles/simple.css
@@ -1005,6 +1005,10 @@ ul, li {
max-height: 1.2rem;
}
+span.embed-inline {
+ display: inline-flex;
+}
+
.alterne-list > .list-item:hover {
background: rgba(100, 100, 50, 0.25);
}
diff --git a/system.json b/system.json
index 1ca177d7..18d4a7c5 100644
--- a/system.json
+++ b/system.json
@@ -1,8 +1,8 @@
{
"id": "foundryvtt-reve-de-dragon",
"title": "RĂªve de Dragon",
- "version": "10.6.11",
- "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.11.zip",
+ "version": "10.6.12",
+ "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.12.zip",
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"compatibility": {
"minimum": "10",
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index de44d86f..c122ea18 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -61,7 +61,7 @@
Filtrer
{{/if}}
-
+
diff --git a/templates/actor/competence.html b/templates/actor/competence.html
index d9de370a..d954ea9c 100644
--- a/templates/actor/competence.html
+++ b/templates/actor/competence.html
@@ -1,4 +1,4 @@
-{{#if system.isVisible}}
+{{#unless system.isHidden}}
@@ -49,4 +49,4 @@
{{/if}}
-{{/if}}
\ No newline at end of file
+{{/unless}}
\ No newline at end of file
diff --git a/templates/actor/inventaire-item.html b/templates/actor/inventaire-item.html
index a89f0716..71aac1ba 100644
--- a/templates/actor/inventaire-item.html
+++ b/templates/actor/inventaire-item.html
@@ -1,3 +1,4 @@
+{{#unless item.system.isHidden}}
{{#if (or options.isObserver (ne item.type 'monnaie'))}}
@@ -43,3 +44,4 @@
{{/if}}
+{{/unless}}
diff --git a/templates/actor/inventaire.html b/templates/actor/inventaire.html
index 61e13c29..bfd606fa 100644
--- a/templates/actor/inventaire.html
+++ b/templates/actor/inventaire.html
@@ -1,11 +1,14 @@
Equipement
- {{#if options.isOwned}}
+ {{#if options.isOwner}}
Nouvel objet
{{/if}}
{{#if options.isGM}}
Tout vider
{{/if}}
+
+
+
{{#if calc.surEncombrementMessage}}{{calc.surEncombrementMessage}} ‐{{/if}}
Encombrement: {{numberFormat calc.encTotal decimals=2}} (max: {{system.attributs.encombrement.value}})
{{#if (regle-optionnelle 'afficher-prix-joueurs')}}