From 1bcfba1f6875a6ae27ed8ae4588700855de0ebd6 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 19 Dec 2020 18:02:05 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Order=20messages=20accorder=20entit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le message arrivait avant le message d'attaque réussie --- module/rdd-combat.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/module/rdd-combat.js b/module/rdd-combat.js index f9d3dae6..c3fb55e0 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -238,35 +238,35 @@ export class RdDCombat { /* -------------------------------------------- */ async _onAttaqueNormale(rollData) { console.log("RdDCombat.onAttaqueNormale >>>", rollData); - if (!await this.accorderEntite('avant-defense')) { - return; - } - let explications = ""; - + rollData.dmg = RdDBonus.dmg(rollData, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar()); - + if (this.target) { explications += "
Cible : " + this.defender.data.name; } explications += "
Encaissement à " + Misc.toSignedString(rollData.dmg.total) + " (" + rollData.dmg.loc.label + ")"; - + // Save rollData for defender game.system.rdd.rollDataHandler[this.attackerId] = duplicate(rollData); - + // Message spécial pour la rapidité, qui reste difficile à gérer automatiquement if (rollData.particuliereAttaque == 'rapidite') { explications += "
Vous avez attaqué en Rapidité. Vous pourrez faire une deuxième attaque, ou utiliser votre arme pour vous défendre."; } - + // Final chat message let chatOptions = { content: "Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "" - + RdDResolutionTable.explainRollData(rollData) - + explications + + RdDResolutionTable.explainRollData(rollData) + + explications } ChatUtility.chatWithRollMode(chatOptions, this.attacker.name) - + + if (!await this.accorderEntite('avant-defense')) { + return; + } + if (this.target) { this._sendMessageDefense(rollData); } From a93b34d2ce7e2b996146b036fe7ff4d56025e83d Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 20 Dec 2020 02:05:47 +0100 Subject: [PATCH 2/3] use jQuery path for _showControlWhen --- module/actor-sheet.js | 2 +- module/html-utility.js | 4 ++-- module/rdd-calendrier.js | 2 +- module/rdd-roll.js | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index ecbbdf66..20bd8f12 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -234,7 +234,7 @@ export class RdDActorSheet extends ActorSheet { activateListeners(html) { super.activateListeners(html); - HtmlUtility._showControlWhen(".gm-only", game.user.isGM); + HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM); // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; diff --git a/module/html-utility.js b/module/html-utility.js index 28f3551d..1566039c 100644 --- a/module/html-utility.js +++ b/module/html-utility.js @@ -1,10 +1,10 @@ export class HtmlUtility{ static _showControlWhen(control, condition) { if (condition) { - $(control).show(); + control.show(); } else { - $(control).hide(); + control.hide(); } } } \ No newline at end of file diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index bd9d0dda..4d2fcaf7 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -387,7 +387,7 @@ export class RdDCalendrier extends Application { activateListeners(html) { super.activateListeners(html); - HtmlUtility._showControlWhen(".gm-only", game.user.isGM); + HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM); this.updateDisplay(); diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 3a22fc1f..156818a5 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -118,15 +118,15 @@ export class RdDRoll extends Dialog { dmgText = '(' + dmgText + ')'; } - HtmlUtility._showControlWhen(".diffMoral", rollData.selectedCarac == actor.data.data.carac.volonte); - HtmlUtility._showControlWhen(".etat-general", !dialog._isIgnoreEtatGeneral(rollData)); + HtmlUtility._showControlWhen($(".diffMoral"), rollData.selectedCarac == actor.data.data.carac.volonte); + HtmlUtility._showControlWhen($(".etat-general"), !dialog._isIgnoreEtatGeneral(rollData)); // Sort management if (rollData.selectedSort) { rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord), //console.log("Toggle show/hide", rollData.selectedSort); - HtmlUtility._showControlWhen("#div-sort-difficulte", RdDItemSort.isDifficulteVariable(rollData.selectedSort)) - HtmlUtility._showControlWhen("#div-sort-ptreve", RdDItemSort.isCoutVariable(rollData.selectedSort)) + HtmlUtility._showControlWhen($("#div-sort-difficulte"), RdDItemSort.isDifficulteVariable(rollData.selectedSort)) + HtmlUtility._showControlWhen($("#div-sort-ptreve"), RdDItemSort.isCoutVariable(rollData.selectedSort)) } // Mise à jour valeurs From ae3ac0a00fb6d65dfc8f6e6a4d15f3f5259d770b Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 20 Dec 2020 02:07:27 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Possiblilit=C3=A9=20d'afficher/masquer=20le?= =?UTF-8?q?s=20menus=20HUD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Afin de voir les "activve effects", ou autres sous menus du HUD --- module/rdd-token-hud.js | 98 +++++++++++++++++--------------- module/rdd-utility.js | 5 +- styles/simple.css | 16 +++--- templates/hud-actor-attaque.html | 13 +++++ templates/hud-actor-init.html | 11 ++++ 5 files changed, 87 insertions(+), 56 deletions(-) create mode 100644 templates/hud-actor-attaque.html create mode 100644 templates/hud-actor-init.html diff --git a/module/rdd-token-hud.js b/module/rdd-token-hud.js index 12aefdc4..d0966b44 100644 --- a/module/rdd-token-hud.js +++ b/module/rdd-token-hud.js @@ -1,62 +1,66 @@ /* -------------------------------------------- */ +import { HtmlUtility } from "./html-utility.js"; import { RdDUtility } from "./rdd-utility.js"; /* -------------------------------------------- */ export class RdDTokenHud { - - /* -------------------------------------------- */ - static addTokenHudExtensions( app, html, data ) { - let token = canvas.tokens.get(data._id); - - // Affichage seulement si le token est un combat - if ( token.inCombat) { - this.addInitiativeTokenTip(html, token); - } - } + /* -------------------------------------------- */ - static async addInitiativeTokenTip(html, token ) { - // Helper actor and sanity check - let actor = token.actor; - if (actor === undefined) return; - - // Get combatant stuff - let combatant = game.combat.data.combatants.find(c => c.tokenId == token.data._id ); - if ( combatant ) { - let armesList = RdDUtility.buildArmeList( combatant ); - // Create space for Hud Extensions next to combat icon - let htmlInit = '
'; - let htmlCombat = '
'; - console.log("Token !!!", combatant, armesList); - for( let armeIndex=0; armeIndex'; - htmlInit += '
'; - if ( !arme.data.initOnly) { - htmlCombat += '
'; - htmlCombat += '
'; - } - } - htmlInit += "
"; - htmlCombat += ""; - let hudInitiative = $(htmlInit); - html.find('.control-icon.combat').after(hudInitiative); // Add Initiative and Agility token tip - let hudCombat = $(htmlCombat); - html.find('.control-icon.combat').after(hudCombat); // Add Initiative and Agility token tip + static addTokenHudExtensions(app, html, data) { + let token = canvas.tokens.get(data._id); + let actor = token.actor; + let combatant = game.combat.data.combatants.find(c => c.tokenId == token.data._id); - // Add interactions for Initiative - hudInitiative.find('label').click(async (event) => { + // Affichage seulement si le token est un combat et a un actor + if (actor === undefined) return; + if (!token.inCombat) return; + if (!combatant) return; + + const data = { combatant: combatant, armes: RdDTokenHud.buildListeActionsCombat(combatant) }; + + // initiative + await RdDTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', data, + (event) => { let armeIndex = event.currentTarget.attributes['data-arme-id'].value; - let combatantId = event.currentTarget.attributes['data-combatant-id'].value; - let arme = armesList[armeIndex]; - RdDUtility.rollInitiativeCompetence( combatantId, arme ); + let combatantId = event.currentTarget.attributes['data-combatant-id'].value; + let arme = listeArmes[armeIndex]; + RdDUtility.rollInitiativeCompetence(combatantId, arme); }); - // Add interactions for Combat - hudCombat.find('label').click(async (event) => { + + // combat + await RdDTokenHud._configureSubMenu(html.find('.control-icon.target'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', data, + (event) => { let armeIndex = event.currentTarget.attributes['data-arme-id'].value; let arme = armesList[armeIndex]; - actor.rollArme( arme.data.competence, arme.name); + actor.rollArme(arme.data.competence, arme.name); }); - } } + + static buildListeActionsCombat(combatant) { + let armesList = RdDUtility.buildArmeList(combatant); + for (let armeIndex = 0; armeIndex < armesList.length; armeIndex++) { + armesList[armeIndex] = duplicate(armesList[armeIndex]); + armesList[armeIndex].index = armeIndex; + } + return armesList; + } + + static async _configureSubMenu(insertionPoint, template, data, onMenuItem) { + const hud = $(await renderTemplate(template, data)); + const imgHud = hud.find('img.rdd-hud-togglebutton'); + const list = hud.find('div.rdd-hud-list'); + + HtmlUtility._showControlWhen(list, hud.hasClass('active')); + + imgHud.click(event => { + hud.toggleClass('active'); + HtmlUtility._showControlWhen(list, hud.hasClass('active')); + }); + + list.find('.rdd-hud-menu').click(onMenuItem); + + insertionPoint.after(hud); + } + } \ No newline at end of file diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 18a1e430..df1b9126 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -187,7 +187,10 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/heures-select-option.html', // Conteneur/item in Actor sheet 'systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html', - 'systems/foundryvtt-reve-de-dragon/templates/editor-notes-mj.html' + 'systems/foundryvtt-reve-de-dragon/templates/editor-notes-mj.html', + // HUD + 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', + 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html' ]; return loadTemplates(templatePaths); diff --git a/styles/simple.css b/styles/simple.css index 670212f2..f6789956 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -667,6 +667,13 @@ ul, li { font-family: CaslonPro; font-weight: 600; } +.tokenhudext.left { + justify-content: flex-start; + flex-direction: column; + position: absolute; + top: 2.75rem; + right: 4rem; +} .tokenhudext.right { justify-content: flex-start; flex-direction: column; @@ -674,13 +681,6 @@ ul, li { top: 2.75rem; right: -6rem; } -.tokenhudext.rightright { - justify-content: flex-start; - flex-direction: column; - position: absolute; - top: 2.75rem; - right: -13rem; -} .control-icon.tokenhudicon { width: fit-content; height: fit-content; @@ -693,7 +693,7 @@ ul, li { .control-icon.tokenhudicon.right { margin-left: 8px; } -.hud-text-small { +.rdd-hud-menu { font-size: 0.75rem; } /* ======================================== */ diff --git a/templates/hud-actor-attaque.html b/templates/hud-actor-attaque.html new file mode 100644 index 00000000..ca06f62e --- /dev/null +++ b/templates/hud-actor-attaque.html @@ -0,0 +1,13 @@ +
+ +
+ {{#each armes as |arme key|}} + {{#unless arme.data.initOnly}} +
+ +
+ {{/unless}} + {{/each}} +
+
\ No newline at end of file diff --git a/templates/hud-actor-init.html b/templates/hud-actor-init.html new file mode 100644 index 00000000..5b021581 --- /dev/null +++ b/templates/hud-actor-init.html @@ -0,0 +1,11 @@ +
+ +
+ {{#each armes as |arme key|}} +
+ +
+ {{/each}} +
+