From 05e48b61ff9a2e1314b64e9f3040f9dcd0aa059d Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 10 Jan 2023 22:11:16 +0100 Subject: [PATCH 1/6] Renommage showControlWhen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vu que la méthode est publique --- module/actor-sheet.js | 2 +- module/dialog-create-signedraconique.js | 2 +- module/dialog-item-vente.js | 2 +- module/html-utility.js | 2 +- module/item-sheet.js | 4 ++-- module/rdd-roll.js | 20 ++++++++++---------- module/rdd-tmr-dialog.js | 6 +++--- module/rdd-token-hud.js | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 803ad71c..6c43d5c1 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -111,7 +111,7 @@ export class RdDActorSheet extends RdDBaseActorSheet { activateListeners(html) { super.activateListeners(html); - HtmlUtility._showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue")); + HtmlUtility.showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue")); // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; diff --git a/module/dialog-create-signedraconique.js b/module/dialog-create-signedraconique.js index fa012e9d..7f5820be 100644 --- a/module/dialog-create-signedraconique.js +++ b/module/dialog-create-signedraconique.js @@ -98,7 +98,7 @@ export class DialogCreateSigneDraconique extends Dialog { async setEphemere(ephemere) { this.dialogData.signe.system.ephemere = ephemere; - HtmlUtility._showControlWhen(this.html.find(".signe-system-duree"), ephemere); + HtmlUtility.showControlWhen(this.html.find(".signe-system-duree"), ephemere); } async onSelectActor(event) { diff --git a/module/dialog-item-vente.js b/module/dialog-item-vente.js index ac17a001..5b6a62ce 100644 --- a/module/dialog-item-vente.js +++ b/module/dialog-item-vente.js @@ -86,6 +86,6 @@ export class DialogItemVente extends Dialog { setQuantiteIllimite(checked) { this.venteData.quantiteIllimite = checked; this.html.find(".label-quantiteIllimite").text(this.venteData.quantiteIllimite ? "Illimités" : "disponibles"); - HtmlUtility._showControlWhen(this.html.find(".quantiteNbLots"), !this.venteData.quantiteIllimite) + HtmlUtility.showControlWhen(this.html.find(".quantiteNbLots"), !this.venteData.quantiteIllimite) } } \ No newline at end of file diff --git a/module/html-utility.js b/module/html-utility.js index c4754cc5..fd76ac75 100644 --- a/module/html-utility.js +++ b/module/html-utility.js @@ -1,5 +1,5 @@ export class HtmlUtility{ - static _showControlWhen(jQuerySelector, condition) { + static showControlWhen(jQuerySelector, condition) { if (condition) { jQuerySelector.show(); } diff --git a/module/item-sheet.js b/module/item-sheet.js index c5f96b64..eb4048a3 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -156,8 +156,8 @@ export class RdDItemSheet extends ItemSheet { super.activateListeners(html); this.html = html; - HtmlUtility._showControlWhen(this.html.find(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.item.isOwned); - HtmlUtility._showControlWhen(this.html.find(".item-magique"), this.item.isMagique()); + HtmlUtility.showControlWhen(this.html.find(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.item.isOwned); + HtmlUtility.showControlWhen(this.html.find(".item-magique"), this.item.isMagique()); // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 57c5ff70..22a8368f 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -276,11 +276,11 @@ export class RdDRoll extends Dialog { const diffVariable = RdDItemSort.isDifficulteVariable(sort); const coutVariable = RdDItemSort.isCoutVariable(sort); - HtmlUtility._showControlWhen(this.html.find(".div-sort-non-rituel"), !sort.system.isrituel); - HtmlUtility._showControlWhen(this.html.find(".div-sort-difficulte-var"), diffVariable); - HtmlUtility._showControlWhen(this.html.find(".div-sort-difficulte-fixe"), !diffVariable); - HtmlUtility._showControlWhen(this.html.find(".div-sort-ptreve-var"), coutVariable); - HtmlUtility._showControlWhen(this.html.find(".div-sort-ptreve-fixe"), !coutVariable); + HtmlUtility.showControlWhen(this.html.find(".div-sort-non-rituel"), !sort.system.isrituel); + HtmlUtility.showControlWhen(this.html.find(".div-sort-difficulte-var"), diffVariable); + HtmlUtility.showControlWhen(this.html.find(".div-sort-difficulte-fixe"), !diffVariable); + HtmlUtility.showControlWhen(this.html.find(".div-sort-ptreve-var"), coutVariable); + HtmlUtility.showControlWhen(this.html.find(".div-sort-ptreve-fixe"), !coutVariable); } async setSelectedSigneDraconique(signe) { @@ -311,11 +311,11 @@ export class RdDRoll extends Dialog { const resolutionTable = await RdDResolutionTable.buildHTMLTable(RdDResolutionTable.subTable(rollData.caracValue, rollData.finalLevel)) const adjustements = await this.buildAjustements(rollData); - HtmlUtility._showControlWhen(this.html.find(".use-encTotal"), rollData.ajustements.encTotal.visible && RdDCarac.isAgiliteOuDerivee(rollData.selectedCarac)); - HtmlUtility._showControlWhen(this.html.find(".use-surenc"), rollData.ajustements.surenc.visible && RdDCarac.isActionPhysique(rollData.selectedCarac)); - HtmlUtility._showControlWhen(this.html.find(".utilisation-moral"), rollData.use.appelAuMoral); - HtmlUtility._showControlWhen(this.html.find(".diffMoral"), rollData.ajustements.moralTotal.used); - HtmlUtility._showControlWhen(this.html.find(".divAppelAuMoral"), rollData.use.appelAuMoral); + HtmlUtility.showControlWhen(this.html.find(".use-encTotal"), rollData.ajustements.encTotal.visible && RdDCarac.isAgiliteOuDerivee(rollData.selectedCarac)); + HtmlUtility.showControlWhen(this.html.find(".use-surenc"), rollData.ajustements.surenc.visible && RdDCarac.isActionPhysique(rollData.selectedCarac)); + HtmlUtility.showControlWhen(this.html.find(".utilisation-moral"), rollData.use.appelAuMoral); + HtmlUtility.showControlWhen(this.html.find(".diffMoral"), rollData.ajustements.moralTotal.used); + HtmlUtility.showControlWhen(this.html.find(".divAppelAuMoral"), rollData.use.appelAuMoral); // Mise à jour valeurs this.html.find(".dialog-roll-title").text(this._getTitle(rollData)); diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index c6c9f5d9..51120319 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -208,8 +208,8 @@ export class RdDTMRDialog extends Dialog { return; } - HtmlUtility._showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue")); - HtmlUtility._showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord())); + HtmlUtility.showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue")); + HtmlUtility.showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord())); // Roll Sort this.html.find('.lancer-sort').click((event) => { @@ -246,7 +246,7 @@ export class RdDTMRDialog extends Dialog { } const coord = this._getActorCoord(); - HtmlUtility._showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(coord)); + HtmlUtility.showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(coord)); let ptsreve = document.getElementById("tmr-pointsreve-value"); ptsreve.innerHTML = this.actor.system.reve.reve.value; diff --git a/module/rdd-token-hud.js b/module/rdd-token-hud.js index f141caae..6d29ecab 100644 --- a/module/rdd-token-hud.js +++ b/module/rdd-token-hud.js @@ -111,6 +111,6 @@ export class RdDTokenHud { static _toggleHudListActive(hud, list) { hud.toggleClass('active'); - HtmlUtility._showControlWhen(list, hud.hasClass('active')); + HtmlUtility.showControlWhen(list, hud.hasClass('active')); } } \ No newline at end of file From 03f84eb3f7cfa8bdd7d5eff0580f31caa316f372 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 10 Jan 2023 22:17:20 +0100 Subject: [PATCH 2/6] Chronologie +/- MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quand le journal est sélectionné, la fenêtre de chronologie s'ouvre avec les informations présaisies masquées. Le bouton + permet de les afficher. Le bouton - de les masquer. --- module/dialog-chronologie.js | 52 +++++++++++++++++++------------ templates/dialog-chronologie.html | 26 ++++++++++------ 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/module/dialog-chronologie.js b/module/dialog-chronologie.js index 374c1f9e..e30efdc5 100644 --- a/module/dialog-chronologie.js +++ b/module/dialog-chronologie.js @@ -1,5 +1,6 @@ import { SYSTEM_RDD } from "./constants.js"; import { Grammar } from "./grammar.js"; +import { HtmlUtility } from "./html-utility.js"; import { RdDTimestamp } from "./rdd-timestamp.js"; @@ -27,27 +28,10 @@ export class DialogChronologie extends Dialog { dateReel: DialogChronologie.getCurrentDateTime() }; const html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/dialog-chronologie.html", dialogData); - const dialog = new DialogChronologie(html); + const dialog = new DialogChronologie(html, dialogData); dialog.render(true); } - constructor(html) { - const options = { - classes: ["DialogChronologie"], - width: 500, - height: 'fit-content', - 'z-index': 99999 - }; - const conf = { - title: "Chronologie", - content: html, - buttons: { - ajout: { label: "Ajouter", callback: it => this.ajouter() }, - } - }; - super(conf, options); - } - static getCurrentDateTime() { return new Date().toLocaleString("sv-SE", { year: "numeric", @@ -58,9 +42,38 @@ export class DialogChronologie extends Dialog { }).replace(" ", "T"); } + constructor(html, dialogData) { + const options = { + classes: ["DialogChronologie"], + width: 500, + height: 'fit-content', + 'z-index': 99999 + }; + const timeData = dialogData.timestamp.toCalendrier() + const conf = { + title: `Chronologie - ${timeData.jourDuMois} ${timeData.mois.label} - Heure ${timeData.heure.label}`, + content: html, + buttons: { + ajout: { label: "Ajouter", callback: it => this.ajouter() }, + } + }; + super(conf, options); + this.dialogData = dialogData; + } + activateListeners(html) { - super.activateListeners(html); this.html = html; + super.activateListeners(html); + this.showChronologiePreset(!game.journal.get(this.dialogData.journalId).canUserModify(game.user)) + + this.html.find("a.chronologie-preset-show").click(event => this.showChronologiePreset(true)); + this.html.find("a.chronologie-preset-hide").click(event => this.showChronologiePreset(false)); + } + + showChronologiePreset(showPreset) { + HtmlUtility.showControlWhen(this.html.find(".chronologie-preset-show"), !showPreset); + HtmlUtility.showControlWhen(this.html.find(".chronologie-preset-hide"), showPreset); + HtmlUtility.showControlWhen(this.html.find(".chronologie-preset"), showPreset); } async ajouter() { @@ -68,7 +81,6 @@ export class DialogChronologie extends Dialog { const { journalId, journalEntry } = this.findJournal(); // ajouter à la page ou créer une page this.addContentToJournal(journalEntry, await this.prepareChronologieEntry()); - this.storeLatestUsedJournalEntry(journalId); } diff --git a/templates/dialog-chronologie.html b/templates/dialog-chronologie.html index b50e105d..756b1195 100644 --- a/templates/dialog-chronologie.html +++ b/templates/dialog-chronologie.html @@ -1,23 +1,23 @@
- +
-
+
{{>"systems/foundryvtt-reve-de-dragon/templates/common/timestamp.hbs" - (timestamp-extract timestamp) - path='chronologie' - label='Date en jeu' + (timestamp-extract timestamp) + path='chronologie' + label='Date en jeu' disabled='' }}
-
- +
+
-
- +
+
+
+
+
- +
From f9fd8a1e24519dd023dd2d38a8c36d79f20ac108 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 10 Jan 2023 22:45:23 +0100 Subject: [PATCH 3/6] Message si le journal est inaccessible --- module/dialog-chronologie.js | 15 +++++++++++---- templates/dialog-chronologie.html | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/module/dialog-chronologie.js b/module/dialog-chronologie.js index e30efdc5..91ab353d 100644 --- a/module/dialog-chronologie.js +++ b/module/dialog-chronologie.js @@ -54,7 +54,6 @@ export class DialogChronologie extends Dialog { title: `Chronologie - ${timeData.jourDuMois} ${timeData.mois.label} - Heure ${timeData.heure.label}`, content: html, buttons: { - ajout: { label: "Ajouter", callback: it => this.ajouter() }, } }; super(conf, options); @@ -68,6 +67,7 @@ export class DialogChronologie extends Dialog { this.html.find("a.chronologie-preset-show").click(event => this.showChronologiePreset(true)); this.html.find("a.chronologie-preset-hide").click(event => this.showChronologiePreset(false)); + this.html.find("button.chronologie-ajouter").click(event => this.ajouter()); } showChronologiePreset(showPreset) { @@ -79,9 +79,16 @@ export class DialogChronologie extends Dialog { async ajouter() { await this.forceValidation(); const { journalId, journalEntry } = this.findJournal(); - // ajouter à la page ou créer une page - this.addContentToJournal(journalEntry, await this.prepareChronologieEntry()); - this.storeLatestUsedJournalEntry(journalId); + if (journalEntry?.canUserModify(game.user)) { + // ajouter à la page ou créer une page + this.addContentToJournal(journalEntry, await this.prepareChronologieEntry()); + this.storeLatestUsedJournalEntry(journalId); + this.close(); + } + else { + const journal = this.html.find("form.rdddialogchrono select[name='journalId']").val(); + ui.notifications.warn(`Le journal ${journal} n'est pas accessible`); + } } async forceValidation() { diff --git a/templates/dialog-chronologie.html b/templates/dialog-chronologie.html index 756b1195..9bc7aa9f 100644 --- a/templates/dialog-chronologie.html +++ b/templates/dialog-chronologie.html @@ -45,5 +45,8 @@
+
+ +
\ No newline at end of file From 9c0d08cb6f1ec1ee4e12ebd91fa96caf5a7f57a5 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 10 Jan 2023 22:45:56 +0100 Subject: [PATCH 4/6] Organiser la chronologie par date --- module/dialog-chronologie.js | 25 ++++++++++++++++--------- templates/chronologie-entry.html | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/module/dialog-chronologie.js b/module/dialog-chronologie.js index 91ab353d..59ba9542 100644 --- a/module/dialog-chronologie.js +++ b/module/dialog-chronologie.js @@ -80,8 +80,15 @@ export class DialogChronologie extends Dialog { await this.forceValidation(); const { journalId, journalEntry } = this.findJournal(); if (journalEntry?.canUserModify(game.user)) { + const journalParameters = this.extractJournalParameters(); + + const jour = journalParameters.dateRdD.jour; + const mois = journalParameters.dateRdD.mois.label; + const annee = journalParameters.dateRdD.annee; + const section = `${jour} ${mois} ${annee}` + const content = await this.prepareChronologieEntry(journalParameters); // ajouter à la page ou créer une page - this.addContentToJournal(journalEntry, await this.prepareChronologieEntry()); + this.addContentToJournal(journalEntry, section, content); this.storeLatestUsedJournalEntry(journalId); this.close(); } @@ -101,8 +108,8 @@ export class DialogChronologie extends Dialog { return { journalId, journalEntry }; } - async prepareChronologieEntry() { - return await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/chronologie-entry.html", this.extractJournalParameters()); + async prepareChronologieEntry(journalParameters) { + return await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/chronologie-entry.html", journalParameters); } extractJournalParameters() { @@ -120,19 +127,19 @@ export class DialogChronologie extends Dialog { } } - addContentToJournal(journalEntry, content) { - let page = journalEntry.pages.find(p => p.type == 'text' && Grammar.equalsInsensitive(p.name, 'Chronologie')); + addContentToJournal(journalEntry, section, content) { + let page = journalEntry.pages.find(p => p.type == 'text' && Grammar.equalsInsensitive(p.name, section)); if (page) { - page.update({ 'text.content': content + '\n' + page.text.content }); + page.update({ 'text.content': page.text.content + '\n' + content }); } else { - journalEntry.createEmbeddedDocuments('JournalEntryPage', [this.newPageChronologie(content)]); + journalEntry.createEmbeddedDocuments('JournalEntryPage', [this.newPageChronologie(section, content)]); } } - newPageChronologie(content) { + newPageChronologie(section, content) { return new JournalEntryPage({ - name: 'Chronologie', + name: section, type: 'text', title: { show: true, level: 1 }, text: { content: content, format: 1 } diff --git a/templates/chronologie-entry.html b/templates/chronologie-entry.html index 1e7ed124..48329f43 100644 --- a/templates/chronologie-entry.html +++ b/templates/chronologie-entry.html @@ -1,4 +1,4 @@ -

{{dateRdD.jour}} {{dateRdD.mois.label}} {{dateRdD.annee}}, à l'heure de {{dateRdD.heure.label}}

+

Heure de {{dateRdD.heure.label}}

{{information}}

Par {{auteur}} ({{dateReel}})


From ca304109d5f07e9d6df7577e44b10cc7be46a6f9 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 10 Jan 2023 22:46:09 +0100 Subject: [PATCH 5/6] Cleanup --- module/rdd-astrologie-editeur.js | 6 +----- module/rdd-astrologie-joueur.js | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/module/rdd-astrologie-editeur.js b/module/rdd-astrologie-editeur.js index d681af82..275e9c2b 100644 --- a/module/rdd-astrologie-editeur.js +++ b/module/rdd-astrologie-editeur.js @@ -10,7 +10,7 @@ export class RdDAstrologieEditeur extends Dialog { let myButtons = { resetButton: { label: "Re-tirer les nombres astraux", callback: html => this.resetNombreAstraux() }, - saveButton: { label: "Fermer", callback: html => this.fillData() } + saveButton: { label: "Fermer", callback: html => {} } }; // Common conf @@ -41,10 +41,6 @@ export class RdDAstrologieEditeur extends Dialog { game.system.rdd.calendrier.showAstrologieEditor(); } - /* -------------------------------------------- */ - fillData() { - } - /* -------------------------------------------- */ updateData(calendrierData) { this.calendrierData = duplicate(calendrierData); diff --git a/module/rdd-astrologie-joueur.js b/module/rdd-astrologie-joueur.js index abab8a66..e288477e 100644 --- a/module/rdd-astrologie-joueur.js +++ b/module/rdd-astrologie-joueur.js @@ -33,7 +33,7 @@ export class RdDAstrologieJoueur extends Dialog { content: html, default: "saveButton", buttons: { - saveButton: { label: "Fermer", callback: html => this.quitDialog() } + saveButton: { label: "Fermer", callback: html => {} } }, }; super(dialogConf, dialogOptions); @@ -93,8 +93,4 @@ export class RdDAstrologieJoueur extends Dialog { this.close(); } - /* -------------------------------------------- */ - quitDialog() { - } - } From 651356159aa2d59bc24a5f4e0135524bb7c8dd95 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 10 Jan 2023 22:46:47 +0100 Subject: [PATCH 6/6] =?UTF-8?q?Version=2010.5.4=20-=20le=20pense-b=C3=AAte?= =?UTF-8?q?=20d'Astrobazzarh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system.json b/system.json index 7c9e945e..3d38c53b 100644 --- a/system.json +++ b/system.json @@ -1,8 +1,8 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "10.5.3", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.5.3.zip", + "version": "10.5.4", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.5.4.zip", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "compatibility": { "minimum": "10",