Compare commits

..

5 Commits

Author SHA1 Message Date
cfe8bee1c2 Merge brnch 2022-08-27 19:16:27 +02:00
8c0fbf15b6 Merge VK features 2022-08-27 19:12:44 +02:00
d4fddf8600 Merge pull request 'Arbre de conteneurs et recherche améliorée' (#546) from VincentVk/foundryvtt-reve-de-dragon:v1.5 into v1.5
Reviewed-on: #546
2022-08-27 19:11:56 +02:00
Vincent Vandemeulebrouck
4b1862fa48 Arborescence de conteneurs
Les conteneurs sont maintenant précédés d'une icone:
* pour ouvrir:  '+'
* pour fermer: '-'
* si vide: carré vide
2022-08-26 22:23:09 +02:00
Vincent Vandemeulebrouck
82115ed8d7 Amélioration recherche
La recherche de compétence fonctionne sur timer
2022-08-26 22:23:08 +02:00
6 changed files with 96 additions and 38 deletions

View File

@ -37,6 +37,7 @@ export class RdDActorSheet extends ActorSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
async getData() { async getData() {
const objectData = this.object.system const objectData = this.object.system
this.timerRecherche = undefined;
console.log("New actor", objectData) console.log("New actor", objectData)
let formData = { let formData = {
@ -76,8 +77,8 @@ export class RdDActorSheet extends ActorSheet {
}; };
formData.competences.forEach(item => { formData.competences.forEach(item => {
item.system.visible = this.options.cherchercompetence item.visible = this.options.recherche
? RdDItemCompetence.nomContientTexte(item, this.options.cherchercompetence) ? RdDItemCompetence.nomContientTexte(item, this.options.recherche.text)
: (!this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item)); : (!this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item));
RdDItemCompetence.levelUp(item, formData.data.compteurs.experience.value); RdDItemCompetence.levelUp(item, formData.data.compteurs.experience.value);
}); });
@ -422,12 +423,28 @@ export class RdDActorSheet extends ActorSheet {
this.options.editCaracComp = !this.options.editCaracComp; this.options.editCaracComp = !this.options.editCaracComp;
this.render(true); this.render(true);
}); });
html.find('.cherchercompetence').change(async event => {
this.options.cherchercompetence = event.currentTarget.value; 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); this.render(true);
}); }, 500);
})
.change(async event =>
this.options.recherche = this._optionRecherche(event.currentTarget)
);
html.find('.vue-detaillee').click(async event => { html.find('.vue-detaillee').click(async event => {
console.log("CONTROLS", this.options.vueDetaillee)
this.options.vueDetaillee = !this.options.vueDetaillee; this.options.vueDetaillee = !this.options.vueDetaillee;
this.render(true); 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) { _getEventArmeCombat(event) {
const li = $(event.currentTarget)?.parents(".item"); const li = $(event.currentTarget)?.parents(".item");
let armeName = li.data("arme-name"); 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 /** Construit la structure récursive des conteneurs, avec imbrication potentielle
* *
*/ */
static buildConteneur(objet, niveau) { static buildConteneur(objet, profondeur) {
if (!niveau) niveau = 1; if (!profondeur) profondeur = 1;
objet.niveau = niveau; objet.niveau = profondeur;
//console.log("OBJ:", objet); const isConteneur = objet.type == 'conteneur';
let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html']({ item: objet }); const isOuvert = isConteneur && this.getAfficheContenu(objet._id);
if (objet.type == 'conteneur') { const isVide = isConteneur && Misc.templateData(objet).contenu.length == 0;
const afficherContenu = this.getAfficheContenu(objet._id); const conteneur = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html']({
str = str + RdDUtility.buildContenu(objet, niveau, afficherContenu); item: objet,
} vide: isVide,
return str; ouvert: isOuvert
});
const contenu = isConteneur ? RdDUtility.buildContenu(objet, profondeur, isOuvert) : '';
return conteneur + contenu;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildContenu(objet, niveau, afficherContenu) { static buildContenu(objet, profondeur, afficherContenu) {
if (!niveau) niveau = 1; if (!profondeur) profondeur = 1;
objet.niveau = niveau; objet.niveau = profondeur;
let strContenu = ""; const display = afficherContenu ? 'item-display-show' : 'item-display-hide';
//console.log("ITEM DISPLAYED", objet ); //console.log("ITEM DISPLAYED", objet );
if (afficherContenu) { let strContenu = `<ul class='item-list alterne-list ${display} list-item-margin${profondeur}'>`;
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 + "'>";
}
for (let subItem of objet.subItems) { for (let subItem of objet.subItems) {
strContenu = strContenu + this.buildConteneur(subItem, niveau + 1); strContenu += this.buildConteneur(subItem, profondeur + 1);
} }
strContenu = strContenu + "</ul>"; return strContenu + "</ul>";
return strContenu;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -806,16 +806,22 @@ ul, li {
} }
.list-item-margin1 { .list-item-margin1 {
margin-left: 1rem; margin-left: 0.5rem;
} }
.list-item-margin2 { .list-item-margin2 {
margin-left: 2rem; margin-left: 1rem;
} }
.list-item-margin3 { .list-item-margin3 {
margin-left: 3rem; margin-left: 1.5rem;
} }
.list-item-margin4 { .list-item-margin4 {
margin-left: 4rem; margin-left: 2rem;
}
.list-item-margin5 {
margin-left: 2.5rem;
}
.list-item-margin6 {
margin-left: 3rem;
} }
.sheet-competence-img { .sheet-competence-img {

View File

@ -331,8 +331,14 @@
} }
], ],
"socket": true, "socket": true,
<<<<<<< HEAD
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.6.zip", "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.6.zip",
=======
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v1.5/system.json",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-1.5.86.zip",
"protected": false,
>>>>>>> origin/v1.5
"gridDistance": 1, "gridDistance": 1,
"gridUnits": "m", "gridUnits": "m",
"primaryTokenAttribute": "sante.vie", "primaryTokenAttribute": "sante.vie",

View File

@ -1,9 +1,28 @@
<li class="item flexrow list-item" data-item-id="{{item._id}}" draggable="true"> <li class="item flexrow list-item" data-item-id="{{item._id}}" draggable="true">
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
{{#if (eq item.type 'conteneur')}} {{#if (eq item.type 'conteneur')}}
<span class="item-name conteneur-name flex-grow"><a data-item-id="{{item._id}}">+{{item.name}}</a></span> <span class="sheet-competence-img conteneur-name">
{{#if vide}}
<i class="far fa-square"></i>
{{else}} {{else}}
<a data-item-id="{{item._id}}">
{{#if ouvert}}
<i class="far fa-minus-square"></i>
<!-- <i class="far fa-caret-square-down"></i> -->
{{else}}
<i class="far fa-plus-square"></i>
<!-- <i class="fas fa-caret-square-right"></i> -->
{{/if}}
</a>
{{/if}}
</span>
<span class="item-name conteneur-name flex-grow">
<a data-item-id="{{item._id}}">
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
{{item.name}}
</a>
</span>
{{else}}
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
<span class="item-name flex-grow">{{item.name}}</span> <span class="item-name flex-grow">{{item.name}}</span>
{{/if}} {{/if}}
<span class="item-quantite">{{item.system.quantite}} <span class="item-quantite">{{item.system.quantite}}
@ -30,3 +49,4 @@
{{/if}} {{/if}}
</div> </div>
</li> </li>

View File

@ -217,7 +217,7 @@
{{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}}</a></span> {{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}}</a></span>
<span class="flexrow"> <span class="flexrow">
<i class="fas fa-search"></i> <i class="fas fa-search"></i>
<input class="cherchercompetence" type="text" value="{{options.cherchercompetence}}" name="cherchercompetence" <input class="recherche" type="text" value="{{options.recherche.text}}" name="recherche"
size="8" data-dtype="String" placeholder="chercher"/> size="8" data-dtype="String" placeholder="chercher"/>
<span></span> <span></span>
</span> </span>
@ -690,7 +690,7 @@
{{#each objets as |item id|}} {{#each objets as |item id|}}
{{#unless item.estContenu}} {{#unless item.estContenu}}
{{#if (ne item.type 'conteneur')}} {{#if (ne item.type 'conteneur')}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html" item=item }} {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html" item=item vide=true ouvert=true }}
{{/if}} {{/if}}
{{/unless}} {{/unless}}
{{/each}} {{/each}}