Merge brnch

This commit is contained in:
2022-08-27 19:16:27 +02:00
6 changed files with 96 additions and 38 deletions

View File

@ -37,6 +37,7 @@ export class RdDActorSheet extends ActorSheet {
/* -------------------------------------------- */
async getData() {
const objectData = this.object.system
this.timerRecherche = undefined;
console.log("New actor", objectData)
let formData = {
@ -76,8 +77,8 @@ export class RdDActorSheet extends ActorSheet {
};
formData.competences.forEach(item => {
item.system.visible = this.options.cherchercompetence
? RdDItemCompetence.nomContientTexte(item, this.options.cherchercompetence)
item.visible = this.options.recherche
? RdDItemCompetence.nomContientTexte(item, this.options.recherche.text)
: (!this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item));
RdDItemCompetence.levelUp(item, formData.data.compteurs.experience.value);
});
@ -422,12 +423,28 @@ export class RdDActorSheet extends ActorSheet {
this.options.editCaracComp = !this.options.editCaracComp;
this.render(true);
});
html.find('.cherchercompetence').change(async event => {
this.options.cherchercompetence = event.currentTarget.value;
this.render(true);
});
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 => {
this.options.recherche = this._optionRecherche(event.currentTarget)
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)
);
html.find('.vue-detaillee').click(async event => {
console.log("CONTROLS", this.options.vueDetaillee)
this.options.vueDetaillee = !this.options.vueDetaillee;
this.render(true);
});
@ -513,6 +530,17 @@ export class RdDActorSheet extends ActorSheet {
});
}
_optionRecherche(target) {
if (!target.value?.length){
return undefined;
}
return {
text: target.value,
start: target.selectionStart,
end: target.selectionEnd,
};
}
_getEventArmeCombat(event) {
const li = $(event.currentTarget)?.parents(".item");
let armeName = li.data("arme-name");

View File

@ -464,34 +464,32 @@ export class RdDUtility {
/** Construit la structure récursive des conteneurs, avec imbrication potentielle
*
*/
static buildConteneur(objet, niveau) {
if (!niveau) niveau = 1;
objet.niveau = niveau;
//console.log("OBJ:", objet);
let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html']({ item: objet });
if (objet.type == 'conteneur') {
const afficherContenu = this.getAfficheContenu(objet._id);
str = str + RdDUtility.buildContenu(objet, niveau, afficherContenu);
}
return str;
static buildConteneur(objet, profondeur) {
if (!profondeur) profondeur = 1;
objet.niveau = profondeur;
const isConteneur = objet.type == 'conteneur';
const isOuvert = isConteneur && this.getAfficheContenu(objet._id);
const isVide = isConteneur && Misc.templateData(objet).contenu.length == 0;
const conteneur = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html']({
item: objet,
vide: isVide,
ouvert: isOuvert
});
const contenu = isConteneur ? RdDUtility.buildContenu(objet, profondeur, isOuvert) : '';
return conteneur + contenu;
}
/* -------------------------------------------- */
static buildContenu(objet, niveau, afficherContenu) {
if (!niveau) niveau = 1;
objet.niveau = niveau;
let strContenu = "";
static buildContenu(objet, profondeur, afficherContenu) {
if (!profondeur) profondeur = 1;
objet.niveau = profondeur;
const display = afficherContenu ? 'item-display-show' : 'item-display-hide';
//console.log("ITEM DISPLAYED", objet );
if (afficherContenu) {
strContenu = "<ul class='item-list alterne-list item-display-show list-item-margin" + niveau + "'>";
} else {
strContenu = "<ul class='item-list alterne-list item-display-hide list-item-margin" + niveau + "'>";
}
let strContenu = `<ul class='item-list alterne-list ${display} list-item-margin${profondeur}'>`;
for (let subItem of objet.subItems) {
strContenu = strContenu + this.buildConteneur(subItem, niveau + 1);
strContenu += this.buildConteneur(subItem, profondeur + 1);
}
strContenu = strContenu + "</ul>";
return strContenu;
return strContenu + "</ul>";
}
/* -------------------------------------------- */