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-chronologie.js b/module/dialog-chronologie.js index 374c1f9e..59ba9542 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,18 +42,60 @@ 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: { + } + }; + 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)); + this.html.find("button.chronologie-ajouter").click(event => this.ajouter()); + } + + 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() { await this.forceValidation(); const { journalId, journalEntry } = this.findJournal(); - // ajouter à la page ou créer une page - this.addContentToJournal(journalEntry, await this.prepareChronologieEntry()); + if (journalEntry?.canUserModify(game.user)) { + const journalParameters = this.extractJournalParameters(); - this.storeLatestUsedJournalEntry(journalId); + 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, section, content); + 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() { @@ -82,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() { @@ -101,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/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-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() { - } - } 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 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", 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 @@ -
{{information}}
Par {{auteur}} ({{dateReel}})