Merge pull request 'Version 10.5.4 - le pense-bête d'Astrobazzarh' (#608) from VincentVk/foundryvtt-reve-de-dragon:v10 into v10

Reviewed-on: #608
This commit is contained in:
uberwald 2023-01-10 23:11:49 +01:00
commit 1956fdd755
14 changed files with 100 additions and 73 deletions

View File

@ -111,7 +111,7 @@ export class RdDActorSheet extends RdDBaseActorSheet {
activateListeners(html) { activateListeners(html) {
super.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 // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;

View File

@ -1,5 +1,6 @@
import { SYSTEM_RDD } from "./constants.js"; import { SYSTEM_RDD } from "./constants.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { HtmlUtility } from "./html-utility.js";
import { RdDTimestamp } from "./rdd-timestamp.js"; import { RdDTimestamp } from "./rdd-timestamp.js";
@ -27,27 +28,10 @@ export class DialogChronologie extends Dialog {
dateReel: DialogChronologie.getCurrentDateTime() dateReel: DialogChronologie.getCurrentDateTime()
}; };
const html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/dialog-chronologie.html", dialogData); 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); 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() { static getCurrentDateTime() {
return new Date().toLocaleString("sv-SE", { return new Date().toLocaleString("sv-SE", {
year: "numeric", year: "numeric",
@ -58,18 +42,60 @@ export class DialogChronologie extends Dialog {
}).replace(" ", "T"); }).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) { activateListeners(html) {
super.activateListeners(html);
this.html = 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() { async ajouter() {
await this.forceValidation(); await this.forceValidation();
const { journalId, journalEntry } = this.findJournal(); const { journalId, journalEntry } = this.findJournal();
// ajouter à la page ou créer une page if (journalEntry?.canUserModify(game.user)) {
this.addContentToJournal(journalEntry, await this.prepareChronologieEntry()); 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, section, content);
this.storeLatestUsedJournalEntry(journalId); 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() { async forceValidation() {
@ -82,8 +108,8 @@ export class DialogChronologie extends Dialog {
return { journalId, journalEntry }; return { journalId, journalEntry };
} }
async prepareChronologieEntry() { async prepareChronologieEntry(journalParameters) {
return await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/chronologie-entry.html", this.extractJournalParameters()); return await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/chronologie-entry.html", journalParameters);
} }
extractJournalParameters() { extractJournalParameters() {
@ -101,19 +127,19 @@ export class DialogChronologie extends Dialog {
} }
} }
addContentToJournal(journalEntry, content) { addContentToJournal(journalEntry, section, content) {
let page = journalEntry.pages.find(p => p.type == 'text' && Grammar.equalsInsensitive(p.name, 'Chronologie')); let page = journalEntry.pages.find(p => p.type == 'text' && Grammar.equalsInsensitive(p.name, section));
if (page) { if (page) {
page.update({ 'text.content': content + '\n' + page.text.content }); page.update({ 'text.content': page.text.content + '\n' + content });
} }
else { else {
journalEntry.createEmbeddedDocuments('JournalEntryPage', [this.newPageChronologie(content)]); journalEntry.createEmbeddedDocuments('JournalEntryPage', [this.newPageChronologie(section, content)]);
} }
} }
newPageChronologie(content) { newPageChronologie(section, content) {
return new JournalEntryPage({ return new JournalEntryPage({
name: 'Chronologie', name: section,
type: 'text', type: 'text',
title: { show: true, level: 1 }, title: { show: true, level: 1 },
text: { content: content, format: 1 } text: { content: content, format: 1 }

View File

@ -98,7 +98,7 @@ export class DialogCreateSigneDraconique extends Dialog {
async setEphemere(ephemere) { async setEphemere(ephemere) {
this.dialogData.signe.system.ephemere = 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) { async onSelectActor(event) {

View File

@ -86,6 +86,6 @@ export class DialogItemVente extends Dialog {
setQuantiteIllimite(checked) { setQuantiteIllimite(checked) {
this.venteData.quantiteIllimite = checked; this.venteData.quantiteIllimite = checked;
this.html.find(".label-quantiteIllimite").text(this.venteData.quantiteIllimite ? "Illimités" : "disponibles"); 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)
} }
} }

View File

@ -1,5 +1,5 @@
export class HtmlUtility{ export class HtmlUtility{
static _showControlWhen(jQuerySelector, condition) { static showControlWhen(jQuerySelector, condition) {
if (condition) { if (condition) {
jQuerySelector.show(); jQuerySelector.show();
} }

View File

@ -156,8 +156,8 @@ export class RdDItemSheet extends ItemSheet {
super.activateListeners(html); super.activateListeners(html);
this.html = 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-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-magique"), this.item.isMagique());
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;

View File

@ -10,7 +10,7 @@ export class RdDAstrologieEditeur extends Dialog {
let myButtons = { let myButtons = {
resetButton: { label: "Re-tirer les nombres astraux", callback: html => this.resetNombreAstraux() }, 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 // Common conf
@ -41,10 +41,6 @@ export class RdDAstrologieEditeur extends Dialog {
game.system.rdd.calendrier.showAstrologieEditor(); game.system.rdd.calendrier.showAstrologieEditor();
} }
/* -------------------------------------------- */
fillData() {
}
/* -------------------------------------------- */ /* -------------------------------------------- */
updateData(calendrierData) { updateData(calendrierData) {
this.calendrierData = duplicate(calendrierData); this.calendrierData = duplicate(calendrierData);

View File

@ -33,7 +33,7 @@ export class RdDAstrologieJoueur extends Dialog {
content: html, content: html,
default: "saveButton", default: "saveButton",
buttons: { buttons: {
saveButton: { label: "Fermer", callback: html => this.quitDialog() } saveButton: { label: "Fermer", callback: html => {} }
}, },
}; };
super(dialogConf, dialogOptions); super(dialogConf, dialogOptions);
@ -93,8 +93,4 @@ export class RdDAstrologieJoueur extends Dialog {
this.close(); this.close();
} }
/* -------------------------------------------- */
quitDialog() {
}
} }

View File

@ -276,11 +276,11 @@ export class RdDRoll extends Dialog {
const diffVariable = RdDItemSort.isDifficulteVariable(sort); const diffVariable = RdDItemSort.isDifficulteVariable(sort);
const coutVariable = RdDItemSort.isCoutVariable(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-non-rituel"), !sort.system.isrituel);
HtmlUtility._showControlWhen(this.html.find(".div-sort-difficulte-var"), diffVariable); 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-difficulte-fixe"), !diffVariable);
HtmlUtility._showControlWhen(this.html.find(".div-sort-ptreve-var"), coutVariable); 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-ptreve-fixe"), !coutVariable);
} }
async setSelectedSigneDraconique(signe) { async setSelectedSigneDraconique(signe) {
@ -311,11 +311,11 @@ export class RdDRoll extends Dialog {
const resolutionTable = await RdDResolutionTable.buildHTMLTable(RdDResolutionTable.subTable(rollData.caracValue, rollData.finalLevel)) const resolutionTable = await RdDResolutionTable.buildHTMLTable(RdDResolutionTable.subTable(rollData.caracValue, rollData.finalLevel))
const adjustements = await this.buildAjustements(rollData); 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-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(".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(".utilisation-moral"), rollData.use.appelAuMoral);
HtmlUtility._showControlWhen(this.html.find(".diffMoral"), rollData.ajustements.moralTotal.used); HtmlUtility.showControlWhen(this.html.find(".diffMoral"), rollData.ajustements.moralTotal.used);
HtmlUtility._showControlWhen(this.html.find(".divAppelAuMoral"), rollData.use.appelAuMoral); HtmlUtility.showControlWhen(this.html.find(".divAppelAuMoral"), rollData.use.appelAuMoral);
// Mise à jour valeurs // Mise à jour valeurs
this.html.find(".dialog-roll-title").text(this._getTitle(rollData)); this.html.find(".dialog-roll-title").text(this._getTitle(rollData));

View File

@ -208,8 +208,8 @@ export class RdDTMRDialog extends Dialog {
return; return;
} }
HtmlUtility._showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue")); 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(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord()));
// Roll Sort // Roll Sort
this.html.find('.lancer-sort').click((event) => { this.html.find('.lancer-sort').click((event) => {
@ -246,7 +246,7 @@ export class RdDTMRDialog extends Dialog {
} }
const coord = this._getActorCoord(); 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"); let ptsreve = document.getElementById("tmr-pointsreve-value");
ptsreve.innerHTML = this.actor.system.reve.reve.value; ptsreve.innerHTML = this.actor.system.reve.reve.value;

View File

@ -111,6 +111,6 @@ export class RdDTokenHud {
static _toggleHudListActive(hud, list) { static _toggleHudListActive(hud, list) {
hud.toggleClass('active'); hud.toggleClass('active');
HtmlUtility._showControlWhen(list, hud.hasClass('active')); HtmlUtility.showControlWhen(list, hud.hasClass('active'));
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"id": "foundryvtt-reve-de-dragon", "id": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"version": "10.5.3", "version": "10.5.4",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.5.3.zip", "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", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",

View File

@ -1,4 +1,4 @@
<h2>{{dateRdD.jour}} {{dateRdD.mois.label}} {{dateRdD.annee}}, à l'heure de {{dateRdD.heure.label}}</h2> <h2>Heure de {{dateRdD.heure.label}}</h2>
<p>{{information}}</p> <p>{{information}}</p>
<p class="poesie-reference">Par {{auteur}} ({{dateReel}})</p> <p class="poesie-reference">Par {{auteur}} ({{dateReel}})</p>
<hr> <hr>

View File

@ -1,10 +1,10 @@
<form class="rdddialogchrono"> <form class="rdddialogchrono">
<div class="flexcol"> <div class="flexcol">
<div class="form-group"> <div class="form-group">
<label for="auteur">Auteur</label> <label class="flex-shrink" for="auteur">Auteur</label>
<input type="text" name="auteur" value="{{auteur}}" data-dtype="String" {{#unless isGM}}disabled{{/unless}}/> <input type="text" name="auteur" value="{{auteur}}" data-dtype="String" {{#unless isGM}}disabled{{/unless}}/>
</div> </div>
<div class="form-group"> <div class="form-group chronologie-preset">
{{>"systems/foundryvtt-reve-de-dragon/templates/common/timestamp.hbs" {{>"systems/foundryvtt-reve-de-dragon/templates/common/timestamp.hbs"
(timestamp-extract timestamp) (timestamp-extract timestamp)
path='chronologie' path='chronologie'
@ -12,12 +12,12 @@
disabled='' disabled=''
}} }}
</div> </div>
<div class="form-group"> <div class="form-group chronologie-preset">
<label for="dateReel">Date réelle</label> <label class="flex-shrink" for="dateReel">Date réelle</label>
<input type="datetime-local" name="dateReel" value="{{dateReel}}" data-dtype="String" /> <input type="datetime-local" name="dateReel" value="{{dateReel}}" data-dtype="String" />
</div> </div>
<div class="form-group"> <div class="form-group chronologie-preset">
<label for="journalId">Journal</label> <label class="flex-shrink" for="journalId">Journal</label>
<select type="text" name="journalId" value="{{journalId}}" data-dtype="String"> <select type="text" name="journalId" value="{{journalId}}" data-dtype="String">
{{#select journalId}} {{#select journalId}}
<option value=""></option> <option value=""></option>
@ -35,9 +35,18 @@
{{/select}} {{/select}}
</select> </select>
</div> </div>
<div class="form-group chronologie-preset">
<hr>
</div>
<div class="form-group"> <div class="form-group">
<label for="information">Information</label> <label class="flex-shrink" for="information">Information
<a class="chronologie-preset-show"><i class="fas fa-plus-square"></i></a>
<a class="chronologie-preset-hide"><i class="fas fa-minus-square"></i></a>
</label>
<textarea autocomplete="off" title="Information" name="information" autofocus>{{information}}</textarea> <textarea autocomplete="off" title="Information" name="information" autofocus>{{information}}</textarea>
</div> </div>
<div class="form-group">
<button class="chronologie-ajouter">Ajouter au journal</button>
</div>
</div> </div>
</form> </form>