HUD + liste de talents

This commit is contained in:
LeRatierBretonnien 2022-12-03 23:13:08 +01:00
parent 6b508c96be
commit 5ab6b99ef6
10 changed files with 196 additions and 22 deletions

View File

@ -48,6 +48,7 @@ export class HawkmoonActorSheet extends ActorSheet {
profils: duplicate(this.actor.getProfils() || {}), profils: duplicate(this.actor.getProfils() || {}),
combat: this.actor.getCombatValues(), combat: this.actor.getCombatValues(),
equipements: duplicate(this.actor.getEquipments()), equipements: duplicate(this.actor.getEquipments()),
initiative: this.actor.getFlag("world", "last-initiative") || -1,
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}), description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {async: true}), habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {async: true}),
options: this.options, options: this.options,

View File

@ -490,6 +490,11 @@ export class HawkmoonActor extends Actor {
return talents return talents
} }
/* -------------------------------------------- */
buildListeAdversites() {
return []
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getCommonRollData(attrKey = undefined, compId = undefined, compName = undefined) { getCommonRollData(attrKey = undefined, compId = undefined, compName = undefined) {
let rollData = HawkmoonUtility.getBasicRollData() let rollData = HawkmoonUtility.getBasicRollData()

71
modules/hawkmoon-hud.js Normal file
View File

@ -0,0 +1,71 @@
/* -------------------------------------------- */
/* -------------------------------------------- */
export class HawkmoonTokenHud {
static init() {
// Integration du TokenHUD
Hooks.on('renderTokenHUD', (app, html, data) => { HawkmoonTokenHud.addTokenHudExtensions(app, html, data._id) });
}
/* -------------------------------------------- */
static async removeExtensionHud(app, html, tokenId) {
html.find('.control-icon.hawkmoon-adversite').remove()
}
/* -------------------------------------------- */
static async addExtensionHud(app, html, tokenId) {
let token = canvas.tokens.get(tokenId)
let actor = token.actor
app.hasExtension = true
const hudData = { actor: actor }
const controlIconActions = html.find('.control-icon[data-action=combat]');
// initiative
await HawkmoonTokenHud._configureSubMenu(controlIconActions, 'systems/fvtt-hawkmoon-cyd/templates/hud-adversites.html', hudData,
(event) => {
let adversite = event.currentTarget.attributes['data-action-index'].value
let value = Number(event.currentTarget.attributes['data-action-value'].value)
hudData.actor.incDecAdversite( adversite, value)
} )
}
/* -------------------------------------------- */
static async addTokenHudExtensions(app, html, tokenId) {
const controlIconCombat = html.find('.control-icon[data-action=combat]')
if (controlIconCombat.length>0 ) {
HawkmoonTokenHud.addExtensionHud(app, html, tokenId);
}
}
/* -------------------------------------------- */
static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) {
const hud = $(await renderTemplate(template, hudData))
const list = hud.find('div.hawkmoon-hud-list')
HawkmoonTokenHud._toggleHudListActive(hud, list);
hud.find('img.hawkmoon-hud-togglebutton').click(event => HawkmoonTokenHud._toggleHudListActive(hud, list));
list.find('.hawkmoon-hud-adversite').click(onMenuItem);
insertionPoint.after(hud);
}
/* -------------------------------------------- */
static _showControlWhen(control, condition) {
if (condition) {
control.show()
}
else {
control.hide()
}
}
/* -------------------------------------------- */
static _toggleHudListActive(hud, list) {
hud.toggleClass('active')
HawkmoonTokenHud._showControlWhen(list, hud.hasClass('active'))
}
}

View File

@ -17,6 +17,7 @@ import { HawkmoonUtility } from "./hawkmoon-utility.js";
import { HawkmoonCombat } from "./hawkmoon-combat.js"; import { HawkmoonCombat } from "./hawkmoon-combat.js";
import { HawkmoonItem } from "./hawkmoon-item.js"; import { HawkmoonItem } from "./hawkmoon-item.js";
import { HawkmoonAutomation } from "./hawkmoon-automation.js"; import { HawkmoonAutomation } from "./hawkmoon-automation.js";
import { HawkmoonTokenHud } from "./hawkmoon-hud.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
@ -64,6 +65,7 @@ Hooks.once("init", async function () {
HawkmoonUtility.init() HawkmoonUtility.init()
HawkmoonAutomation.init() HawkmoonAutomation.init()
HawkmoonTokenHud.init()
}); });
@ -110,7 +112,8 @@ function registerUsageCount(registerKey) {
/* -------------------------------------------- */ /* -------------------------------------------- */
Hooks.once("ready", function () { Hooks.once("ready", function () {
HawkmoonUtility.ready(); HawkmoonUtility.ready()
// User warning // User warning
if (!game.user.isGM && game.user.character == undefined) { if (!game.user.isGM && game.user.character == undefined) {
ui.notifications.info("Attention ! Aucun personnage n'est relié au joueur !"); ui.notifications.info("Attention ! Aucun personnage n'est relié au joueur !");

View File

@ -154,6 +154,7 @@ export class HawkmoonUtility {
'systems/fvtt-hawkmoon-cyd/templates/partial-item-prix.html', 'systems/fvtt-hawkmoon-cyd/templates/partial-item-prix.html',
'systems/fvtt-hawkmoon-cyd/templates/partial-sante-etat.html', 'systems/fvtt-hawkmoon-cyd/templates/partial-sante-etat.html',
'systems/fvtt-hawkmoon-cyd/templates/partial-automation.html', 'systems/fvtt-hawkmoon-cyd/templates/partial-automation.html',
'systems/fvtt-hawkmoon-cyd/templates/hud-adversites.html',
] ]
return loadTemplates(templatePaths); return loadTemplates(templatePaths);
} }
@ -643,4 +644,21 @@ export class HawkmoonUtility {
d.render(true); d.render(true);
} }
/************************************************************************************/
static async __create_talents_table() {
let compName = "fvtt-hawkmoon-cyd.talents-cellule"
const compData = await HawkmoonUtility.loadCompendium(compName)
let talents = compData.map(i => i.toObject())
let htmlTab = "<table border='1'><tbody>";
for (let entryData of talents) {
console.log(entryData)
htmlTab += `<tr><td>@UUID[Compendium.${compName}.${entryData._id}]{${entryData.name}}</td>`
htmlTab += `<td>${entryData.system.description}</td>`;
//htmlTab += `<td>${entryData.system.resumebonus}</td>`;
htmlTab += "</tr>\n";
}
htmlTab += "</table>";
await JournalEntry.create({ name: 'Liste des Talents de Cellule', content: htmlTab });
}
} }

2
packs/aides-de-jeu.db Normal file

File diff suppressed because one or more lines are too long

View File

@ -790,6 +790,7 @@ ul, li {
width: fit-content; width: fit-content;
height: fit-content; height: fit-content;
min-width: 6rem; min-width: 6rem;
min-height: 1.2rem;
flex-basis: auto; flex-basis: auto;
padding: 0; padding: 0;
line-height: 1rem; line-height: 1rem;
@ -896,6 +897,22 @@ ul, li {
border: 0px; border: 0px;
} }
.hud-adversite-container {
position: relative;
text-align: center;
color: white;
width: 64px;
min-height: 64px;
}
.hud-adversite-text {
font-weight: bold;
font-size:0.9rem;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -85%);
}
.actor-icon { .actor-icon {
float: left; float: left;
width: 48px; width: 48px;

View File

@ -1,7 +1,7 @@
{ {
"id": "fvtt-hawkmoon-cyd", "id": "fvtt-hawkmoon-cyd",
"description": "Hawmoon RPG for FoundryVTT (CYD system - French)", "description": "Hawmoon RPG for FoundryVTT (CYD system - French)",
"version": "10.1.1", "version": "10.1.2",
"authors": [ "authors": [
{ {
"name": "Uberwald/LeRatierBretonnien", "name": "Uberwald/LeRatierBretonnien",
@ -35,7 +35,7 @@
"gridUnits": "m", "gridUnits": "m",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json", "manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.1.zip", "download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.2.zip",
"packs": [ "packs": [
{ {
"type": "Item", "type": "Item",
@ -117,6 +117,15 @@
"system": "fvtt-hawkmoon-cyd", "system": "fvtt-hawkmoon-cyd",
"private": false, "private": false,
"flags": {} "flags": {}
},
{
"type": "JournalEntry",
"label": "Aides de Jeu",
"name": "aides-de-jeu",
"path": "packs/aides-de-jeu.db",
"system": "fvtt-hawkmoon-cyd",
"private": false,
"flags": {}
} }
], ],
"primaryTokenAttribute": "sante.vigueur", "primaryTokenAttribute": "sante.vigueur",

View File

@ -233,7 +233,7 @@
<ul class="item-list alternate-list"> <ul class="item-list alternate-list">
<li class="item flexrow"> <li class="item flexrow">
<button class="chat-card-button roll-initiative">Initiative</button> <button class="chat-card-button roll-initiative">Initiative (actuelle : {{initiative}} )</button>
</li> </li>
</ul> </ul>

View File

@ -0,0 +1,48 @@
<div class="control-icon hawkmoon-adversite ">
<img class="hawkmoon-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Action" />
<div class="hawkmoon-hud-list tokenhudext right">
<div class="flexrow tokenhudicon">
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="-1"
data-action-index="bleue" title="Adversite Bleue">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_bleue.webp">
<div class="hud-adversite-text">&nbsp;-1</div>
</div>
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="+1"
data-action-index="bleue" title="Adversite Bleue">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_bleue.webp">
<div class="hud-adversite-text">&nbsp;+1</div>
</div>
</div>
<div class="flexrow tokenhudicon">
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="-1"
data-action-index="rouge" title="Adversite Rouge">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_rouge.webp">
<div class="hud-adversite-text">&nbsp;-1</div>
</div>
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="+1"
data-action-index="rouge" title="Adversite Rouge">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_rouge.webp">
<div class="hud-adversite-text">&nbsp;+1</div>
</div>
</div>
<div class="flexrow tokenhudicon">
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="-1"
data-action-index="noire" title="Adversite Noire">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_noire.webp">
<div class="hud-adversite-text">&nbsp;-1</div>
</div>
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="+1"
data-action-index="noire" title="Adversite Noire">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_noire.webp">
<div class="hud-adversite-text">&nbsp;+1</div>
</div>
</div>
</div>
</div>