Version 10.5.4 - le pense-bête d'Astrobazzarh #608

Merged
uberwald merged 6 commits from VincentVk/foundryvtt-reve-de-dragon:v10 into v10 2023-01-10 23:11:50 +01:00
14 changed files with 100 additions and 73 deletions

View File

@ -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;

View File

@ -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 }

View File

@ -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) {

View File

@ -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)
}
}

View File

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

View File

@ -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;

View File

@ -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);

View File

@ -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() {
}
}

View File

@ -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));

View File

@ -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;

View File

@ -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'));
}
}

View File

@ -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",

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 class="poesie-reference">Par {{auteur}} ({{dateReel}})</p>
<hr>

View File

@ -1,23 +1,23 @@
<form class="rdddialogchrono">
<div class="flexcol">
<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}}/>
</div>
<div class="form-group">
<div class="form-group chronologie-preset">
{{>"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=''
}}
</div>
<div class="form-group">
<label for="dateReel">Date réelle</label>
<div class="form-group chronologie-preset">
<label class="flex-shrink" for="dateReel">Date réelle</label>
<input type="datetime-local" name="dateReel" value="{{dateReel}}" data-dtype="String" />
</div>
<div class="form-group">
<label for="journalId">Journal</label>
<div class="form-group chronologie-preset">
<label class="flex-shrink" for="journalId">Journal</label>
<select type="text" name="journalId" value="{{journalId}}" data-dtype="String">
{{#select journalId}}
<option value=""></option>
@ -35,9 +35,18 @@
{{/select}}
</select>
</div>
<div class="form-group chronologie-preset">
<hr>
</div>
<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>
</div>
<div class="form-group">
<button class="chronologie-ajouter">Ajouter au journal</button>
</div>
</div>
</form>