Preparation soins HUD
This commit is contained in:
parent
2598ae3489
commit
acc880b53f
@ -18,29 +18,36 @@ export class RdDTokenHud {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async addExtensionHud(app, html, tokenId) {
|
static async addExtensionHud(app, html, tokenId, isCombat) {
|
||||||
|
|
||||||
let token = canvas.tokens.get(tokenId);
|
let token = canvas.tokens.get(tokenId);
|
||||||
let actor = token.actor;
|
let actor = token.actor;
|
||||||
let combatant = game.combat.combatants.find(c => c.tokenId == tokenId);
|
app.hasExtension = true;
|
||||||
if (! (combatant?.actor) ) {
|
if (isCombat) {
|
||||||
|
let combatant = game.combat.combatants.find(c => c.tokenId == tokenId);
|
||||||
|
if (!(combatant?.actor)) {
|
||||||
ui.notifications.warn(`Le combatant ${token.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
|
ui.notifications.warn(`Le combatant ${token.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
let actions = RdDCombatManager.listActionsCombat(combatant);
|
||||||
|
// initiative
|
||||||
|
await RdDTokenHud.addExtensionHudInit(html, combatant, actions);
|
||||||
|
// combat
|
||||||
|
await RdDTokenHud.addExtensionHudCombat(html, combatant, actions);
|
||||||
}
|
}
|
||||||
app.hasExtension = true;
|
|
||||||
|
|
||||||
let actionsCombat = RdDCombatManager.listActionsCombat(combatant);
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static async addExtensionHudInit(html, combatant, actions) {
|
||||||
const hudData = {
|
const hudData = {
|
||||||
combatant: combatant,
|
combatant, actions,
|
||||||
actions: actionsCombat,
|
|
||||||
commandes: [
|
commandes: [
|
||||||
{ name: "Autre action", command: 'autre' },
|
{ name: "Autre action", command: 'autre' },
|
||||||
{ name: 'Initiative +1', command: 'inc', value: 0.01 },
|
{ name: 'Initiative +1', command: 'inc', value: 0.01 },
|
||||||
{ name: 'Initiative -1', command: 'dec', value: -0.01 }]
|
{ name: 'Initiative -1', command: 'dec', value: -0.01 }]
|
||||||
};
|
};
|
||||||
|
|
||||||
const controlIconCombat = html.find('.control-icon[data-action=combat]');
|
const controlIconCombat = html.find('.control-icon[data-action=combat]');
|
||||||
// initiative
|
|
||||||
await RdDTokenHud._configureSubMenu(controlIconCombat,
|
await RdDTokenHud._configureSubMenu(controlIconCombat,
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html',
|
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html',
|
||||||
hudData,
|
hudData,
|
||||||
@ -51,22 +58,25 @@ export class RdDTokenHud {
|
|||||||
RdDTokenHud._initiativeCommand(initCommand, combatantId);
|
RdDTokenHud._initiativeCommand(initCommand, combatantId);
|
||||||
} else {
|
} else {
|
||||||
let index = event.currentTarget.attributes['data-action-index'].value;
|
let index = event.currentTarget.attributes['data-action-index'].value;
|
||||||
let action = actionsCombat[index];
|
let action = hudData.actions[index];
|
||||||
RdDCombatManager.rollInitiativeAction(combatantId, action);
|
RdDCombatManager.rollInitiativeAction(combatantId, action);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static async addExtensionHudCombat(html, combatant, actions) {
|
||||||
|
const hudData = { combatant, actions, commandes: [] };
|
||||||
const controlIconTarget = html.find('.control-icon[data-action=target]');
|
const controlIconTarget = html.find('.control-icon[data-action=target]');
|
||||||
// combat
|
|
||||||
await RdDTokenHud._configureSubMenu(controlIconTarget, 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', hudData,
|
await RdDTokenHud._configureSubMenu(controlIconTarget, 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', hudData,
|
||||||
(event) => {
|
(event) => {
|
||||||
const actionIndex = event.currentTarget.attributes['data-action-index']?.value;
|
const actionIndex = event.currentTarget.attributes['data-action-index']?.value;
|
||||||
const action = actionsCombat[actionIndex];
|
const action = hudData.actions[actionIndex];
|
||||||
if (action.action == 'conjurer') {
|
if (action.action == 'conjurer') {
|
||||||
actor.conjurerPossession(actor.getPossession(action.system.possessionid));
|
const possession = combatant.actor.getPossession(action.system.possessionid);
|
||||||
|
combatant.actor.conjurerPossession(possession);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
actor.rollArme(action);
|
combatant.actor.rollArme(action);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -75,24 +85,25 @@ export class RdDTokenHud {
|
|||||||
switch (initCommand) {
|
switch (initCommand) {
|
||||||
case 'inc': return RdDCombatManager.incDecInit(combatantId, 0.01);
|
case 'inc': return RdDCombatManager.incDecInit(combatantId, 0.01);
|
||||||
case 'dec': return RdDCombatManager.incDecInit(combatantId, -0.01);
|
case 'dec': return RdDCombatManager.incDecInit(combatantId, -0.01);
|
||||||
case 'autre': return RdDCombatManager.rollInitiativeAction(combatantId,
|
case 'autre': return RdDCombatManager.rollInitiativeAction(combatantId,
|
||||||
{ name: "Autre action", action: 'autre', system: { initOnly: true, competence: "Autre action" } });
|
{ name: "Autre action", action: 'autre', system: { initOnly: true, competence: "Autre action" } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async addTokenHudExtensions(app, html, tokenId) {
|
static async addTokenHudExtensions(app, html, tokenId) {
|
||||||
const controlIconCombat = html.find('.control-icon[data-action=combat]');
|
const controlIconCombat = html.find('.control-icon[data-action=combat]');
|
||||||
controlIconCombat.click(event => {
|
if (controlIconCombat.length > 0) {
|
||||||
if (event.currentTarget.className.includes('active')) {
|
controlIconCombat.click(event => {
|
||||||
RdDTokenHud.removeExtensionHud(app, html, tokenId);
|
if (event.currentTarget.className.includes('active')) {
|
||||||
} else {
|
RdDTokenHud.removeExtensionHud(app, html, tokenId);
|
||||||
setTimeout(function () { RdDTokenHud.addExtensionHud(app, html, tokenId) }, 200);
|
} else {
|
||||||
}
|
setTimeout(() => RdDTokenHud.addExtensionHud(app, html, tokenId), 200);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (controlIconCombat.length>0 && controlIconCombat[0].className.includes('active')) {
|
const isCombat = controlIconCombat[0].className.includes('active');
|
||||||
RdDTokenHud.addExtensionHud(app, html, tokenId);
|
RdDTokenHud.addExtensionHud(app, html, tokenId, isCombat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,9 +111,9 @@ export class RdDTokenHud {
|
|||||||
static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) {
|
static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) {
|
||||||
const hud = $(await renderTemplate(template, hudData));
|
const hud = $(await renderTemplate(template, hudData));
|
||||||
const list = hud.find('div.rdd-hud-list');
|
const list = hud.find('div.rdd-hud-list');
|
||||||
|
|
||||||
RdDTokenHud._toggleHudListActive(hud, list);
|
RdDTokenHud._toggleHudListActive(hud, list);
|
||||||
|
|
||||||
hud.find('img.rdd-hud-togglebutton').click(event => RdDTokenHud._toggleHudListActive(hud, list));
|
hud.find('img.rdd-hud-togglebutton').click(event => RdDTokenHud._toggleHudListActive(hud, list));
|
||||||
list.find('.rdd-hud-menu').click(onMenuItem);
|
list.find('.rdd-hud-menu').click(onMenuItem);
|
||||||
|
|
||||||
|
@ -1390,27 +1390,27 @@ table.table-nombres-astraux tr:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ======================================== */
|
/* ======================================== */
|
||||||
.tokenhudext {
|
.token-hud-ext {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 0 !important;
|
flex: 0 !important;
|
||||||
font-family: CaslonPro;
|
font-family: CaslonPro;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.tokenhudext.left {
|
.token-hud-ext.left {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 2.75rem;
|
top: 2.75rem;
|
||||||
right: 4rem;
|
right: 4rem;
|
||||||
}
|
}
|
||||||
.tokenhudext.right {
|
.token-hud-ext.right {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 2.75rem;
|
top: 2.75rem;
|
||||||
left: 4rem;
|
left: 4rem;
|
||||||
}
|
}
|
||||||
.control-icon.tokenhudicon {
|
.control-icon.token-hud-icon {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
min-width: 6rem;
|
min-width: 6rem;
|
||||||
@ -1419,7 +1419,7 @@ table.table-nombres-astraux tr:hover {
|
|||||||
line-height: 1rem;
|
line-height: 1rem;
|
||||||
margin: 0.2rem;
|
margin: 0.2rem;
|
||||||
}
|
}
|
||||||
.control-icon.tokenhudicon.right {
|
.control-icon.token-hud-icon.right {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
.rdd-hud-menu label {
|
.rdd-hud-menu label {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<div class="control-icon rdd-combat ">
|
<div class="control-icon rdd-combat ">
|
||||||
<img class="rdd-hud-togglebutton" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd06.svg" width="36" height="36" title="Attaque"/>
|
<img class="rdd-hud-togglebutton" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd06.svg" width="36" height="36" title="Attaque"/>
|
||||||
<div class="rdd-hud-list tokenhudext left">
|
<div class="rdd-hud-list token-hud-ext left">
|
||||||
{{#each actions as |action key|}}
|
{{#each actions as |action key|}}
|
||||||
{{#unless action.system.initOnly}}
|
{{#unless action.system.initOnly}}
|
||||||
<div class="control-icon tokenhudicon rdd-hud-menu rdd-attaque"
|
<div class="control-icon token-hud-icon rdd-hud-menu rdd-attaque"
|
||||||
data-combatant-id="{{../combatant.id}}"
|
data-combatant-id="{{../combatant.id}}"
|
||||||
data-action-index="{{action.index}}"
|
data-action-index="{{action.index}}"
|
||||||
title="{{action.name}}">
|
title="{{action.name}}">
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<div class="control-icon rdd-initiative ">
|
<div class="control-icon rdd-initiative ">
|
||||||
<img class="rdd-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Initiative" />
|
<img class="rdd-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Initiative" />
|
||||||
<div class="rdd-hud-list tokenhudext right">
|
<div class="rdd-hud-list token-hud-ext right">
|
||||||
{{#each actions as |action key|}}
|
{{#each actions as |action key|}}
|
||||||
<div class="control-icon tokenhudicon rdd-hud-menu"
|
<div class="control-icon token-hud-icon rdd-hud-menu"
|
||||||
data-combatant-id="{{../combatant.id}}"
|
data-combatant-id="{{../combatant.id}}"
|
||||||
data-action-index="{{action.index}}"
|
data-action-index="{{action.index}}"
|
||||||
title="{{action.name}}">
|
title="{{action.name}}">
|
||||||
@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#each commandes as |commande key|}}
|
{{#each commandes as |commande key|}}
|
||||||
<div class="control-icon tokenhudicon rdd-hud-menu"
|
<div class="control-icon token-hud-icon rdd-hud-menu"
|
||||||
data-command="{{commande.command}}"
|
data-command="{{commande.command}}"
|
||||||
data-combatant-id="{{../combatant.id}}"
|
data-combatant-id="{{../combatant.id}}"
|
||||||
data-action-index="{{commande.index}}"
|
data-action-index="{{commande.index}}"
|
||||||
|
Loading…
Reference in New Issue
Block a user