Merge pull request '## v11.0.24 - les couleurs de Khrachtchoum' (#671) from VincentVk/foundryvtt-reve-de-dragon:v11 into v11
Reviewed-on: public/foundryvtt-reve-de-dragon#671
This commit is contained in:
commit
f08c8f93da
@ -1,4 +1,7 @@
|
||||
# v11.0
|
||||
## v11.0.24 - les couleurs de Khrachtchoum
|
||||
- nouvelle carte des TMRs
|
||||
|
||||
## v11.0.23 - la lumière de Khrachtchoum
|
||||
- ajustement automatique de la luminosité selon l'heure pour les scènes:
|
||||
- avec une vision des tokens (sinon: ce n'est pas une scène de carte pour tokens)
|
||||
|
@ -46,7 +46,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
const dialogOptions = {
|
||||
classes: ["tmrdialog"],
|
||||
width: 920, height: 980,
|
||||
width: 920, maxheight: 1024, height: 'fit-content',
|
||||
'z-index': 40
|
||||
}
|
||||
super(dialogConf, dialogOptions);
|
||||
@ -62,7 +62,6 @@ export class RdDTMRDialog extends Dialog {
|
||||
this.allTokens = [];
|
||||
this.rencontreState = 'aucune';
|
||||
this.pixiApp = new PIXI.Application({ width: 720, height: 860 });
|
||||
|
||||
this.pixiTMR = new PixiTMR(this, this.pixiApp);
|
||||
|
||||
this.callbacksOnAnimate = [];
|
||||
@ -906,15 +905,12 @@ export class RdDTMRDialog extends Dialog {
|
||||
if (this.viewOnly) {
|
||||
return;
|
||||
}
|
||||
let clickOddq = RdDTMRDialog._computeEventOddq(event.nativeEvent);
|
||||
await this._onClickTMRPos(clickOddq); // Vérifier l'état des compteurs reve/fatigue/vie
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onClickTMRPos(clickOddq) {
|
||||
let clickOddq = TMRUtility.computeEventOddq(event);
|
||||
let currentOddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
|
||||
|
||||
let targetCoord = TMRUtility.oddqToCoordTMR(clickOddq);
|
||||
let currentCoord = TMRUtility.oddqToCoordTMR(currentOddq);
|
||||
|
||||
// Validation de la case de destination (gestion du cas des rencontres qui peuvent téléporter)
|
||||
let deplacementType = this._calculDeplacement(targetCoord, currentCoord, currentOddq, clickOddq);
|
||||
|
||||
@ -946,7 +942,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
await this._messagerDemiReve(targetCoord);
|
||||
break;
|
||||
default:
|
||||
ui.notifications.error("Vous ne pouvez pas vous déplacer que sur des cases adjacentes à votre position ou valides dans le cas d'une rencontre");
|
||||
ui.notifications.error("Vous ne pouvez vous déplacer que sur des cases adjacentes à votre position ou valides dans le cas d'une rencontre");
|
||||
console.log("STATUS :", this.rencontreState, this.currentRencontre);
|
||||
}
|
||||
|
||||
@ -1049,19 +1045,6 @@ export class RdDTMRDialog extends Dialog {
|
||||
await this.postRencontre(tmr);
|
||||
return tmr;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _computeEventOddq(origEvent) {
|
||||
console.log("EVENT", origEvent)
|
||||
let canvasRect = origEvent.target.getBoundingClientRect();
|
||||
let x = origEvent.clientX - canvasRect.left;
|
||||
let y = origEvent.clientY - canvasRect.top;
|
||||
let col = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12]
|
||||
y -= col % 2 == 0 ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
let row = Math.floor(y / tmrConstants.cellh); // [From 0 -> 14]
|
||||
return { col: col, row: row };
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** Retourne les coordonnées x, h, w, h du rectangle d'une case donnée */
|
||||
_getCaseRectangleCoord(coord) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Misc } from "./misc.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
import { tmrConstants } from "./tmr-constants.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const TMRMapping = {
|
||||
@ -163,7 +164,7 @@ const TMRMapping = {
|
||||
C12: { type: "lac", label: "Lac de Fricassa" },
|
||||
D12: { type: "collines", label: "Collines d’Huaï" },
|
||||
E12: { type: "monts", label: "Monts Ajourés" },
|
||||
F12: { type: "necropole", label: "Nécropole de Troat" },
|
||||
F12: { type: "necropole", label: "Nécropole de Throat" },
|
||||
G12: { type: "plaines", label: "Plaines de Lufmil" },
|
||||
H12: { type: "collines", label: "Collines de Tooth" },
|
||||
I12: { type: "gouffre", label: "Gouffre Abimeux" },
|
||||
@ -275,10 +276,10 @@ export class TMRUtility {
|
||||
return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
|
||||
}
|
||||
|
||||
static findTMRLike(type, options = {inclusMauvaise:true}) {
|
||||
static findTMRLike(type, options = { inclusMauvaise: true }) {
|
||||
const choix = [...Object.values(TMRType)]
|
||||
if (options.inclusMauvaise){
|
||||
choix.push({name: 'Mauvaise'});
|
||||
if (options.inclusMauvaise) {
|
||||
choix.push({ name: 'Mauvaise' });
|
||||
}
|
||||
const selection = Misc.findAllLike(type, choix).map(it => it.name);
|
||||
if (selection.length == 0) {
|
||||
@ -297,7 +298,7 @@ export class TMRUtility {
|
||||
}
|
||||
|
||||
static buildSelectionTypesTMR(typesTMR) {
|
||||
typesTMR = typesTMR?? [];
|
||||
typesTMR = typesTMR ?? [];
|
||||
return Object.values(TMRType).map(value => Misc.upperFirst(value.name))
|
||||
.sort()
|
||||
.map(name => { return { name: name, selected: typesTMR.includes(name) } });
|
||||
@ -375,6 +376,33 @@ export class TMRUtility {
|
||||
return caseList;
|
||||
}
|
||||
|
||||
// /* -------------------------------------------- */
|
||||
static computeEventPosition(event) {
|
||||
const canvasRect = event.nativeEvent.target.getBoundingClientRect();
|
||||
return {
|
||||
x: event.nativeEvent.clientX - canvasRect.left,
|
||||
y: event.nativeEvent.clientY - canvasRect.top
|
||||
};
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeEventOddq(event) {
|
||||
var { x, y } = TMRUtility.computeEventPosition(event);
|
||||
return TMRUtility.computeOddq(x, y);
|
||||
}
|
||||
|
||||
static computeOddq(x, y) {
|
||||
const col = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12]
|
||||
const decallageColonne = col % 2 == 0 ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
const row = Math.floor((y - decallageColonne) / tmrConstants.cellh); // [From 0 -> 14]
|
||||
return { col, row };
|
||||
}
|
||||
|
||||
static computeEventCoord(event) {
|
||||
const oddq = TMRUtility.computeEventOddq(event);
|
||||
return TMRUtility.oddqToCoordTMR(oddq);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// https://www.redblobgames.com/grids/hexagons/#distances
|
||||
// TMR Letter-row correspond to "odd-q" grid (letter => col, numeric => row )
|
||||
@ -444,7 +472,7 @@ export class TMRUtility {
|
||||
|
||||
static axial_subtract(a, b) {
|
||||
return {
|
||||
q: a.q- b.q,
|
||||
q: a.q - b.q,
|
||||
r: a.r - b.r
|
||||
};
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import { PixiTMR } from "./pixi-tmr.js";
|
||||
export class CarteTmr extends Draconique {
|
||||
|
||||
constructor() {
|
||||
console.log("Sprite create 1!!!!")
|
||||
super();
|
||||
}
|
||||
|
||||
@ -14,9 +13,25 @@ export class CarteTmr extends Draconique {
|
||||
async onActorCreateOwned(actor, item) { }
|
||||
|
||||
code() { return 'tmr' }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/styles/img/ui/tmp_main_r1.webp' }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/styles/img/ui/tmr.webp' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.carteTmr(this.code());
|
||||
|
||||
const img = PixiTMR.getImgFromCode(this.code())
|
||||
const sprite = new PIXI.Sprite(PIXI.utils.TextureCache[img]);
|
||||
// Setup the position of the TMR
|
||||
sprite.x = 0;
|
||||
sprite.y = 0;
|
||||
sprite.width = 722;
|
||||
sprite.height = 860;
|
||||
// Rotate around the center
|
||||
sprite.anchor.set(0);
|
||||
sprite.buttonMode = true;
|
||||
sprite.tmrObject = pixiTMR;
|
||||
|
||||
pixiTMR.addTooltip(sprite, (e,s) => this.computeTooltip(e,s));
|
||||
pixiTMR.pixiApp.stage.addChild(sprite);
|
||||
return sprite;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ const registeredEffects = [
|
||||
export class Draconique {
|
||||
static isCaseTMR(item) { return item.type == TYPES.casetmr; }
|
||||
static isQueueDragon(item) { return item.isQueueDragon(); }
|
||||
static isSouffleDragon(item) {return item.type == TYPES.souffle; }
|
||||
static isSouffleDragon(item) { return item.type == TYPES.souffle; }
|
||||
static isTeteDragon(item) { return item.type == TYPES.tete; }
|
||||
static isQueueSouffle(item) { return Draconique.isQueueDragon(item) || Draconique.isSouffleDragon(item); }
|
||||
|
||||
@ -82,7 +82,7 @@ export class Draconique {
|
||||
img() { return undefined }
|
||||
|
||||
/**
|
||||
* factory d'élément graphique PIXI correpsondant à l'objet draconique
|
||||
* factory d'élément graphique PIXI correspondant à l'objet draconique
|
||||
* @param {*} pixiTMR instance de PixiTMR qui gère les tooltips, les méthodes de création de sprite standard, les clicks.
|
||||
*/
|
||||
token(pixiTMR, linkData, coordTMR, type = undefined) {
|
||||
@ -91,12 +91,32 @@ export class Draconique {
|
||||
coordTMR: coordTMR
|
||||
};
|
||||
token[type ?? this.code()] = linkData;
|
||||
console.log("SPRITE: ", token.sprite)
|
||||
//PixiTMR.getImgFromCode()
|
||||
pixiTMR.addTooltip(token.sprite, this.tooltip(linkData));
|
||||
this.linkData = linkData;
|
||||
if (this.tooltip(linkData)) {
|
||||
pixiTMR.addTooltip(token.sprite, (e, s) => this.computeTooltip(e, s));
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* methode en charge de recalculer le tooltip lorsque la souris bouge
|
||||
* @param {*} event evenement contenant les coordonnées
|
||||
* @param {*} sprite sprite pour laquelle calculer le tooltip
|
||||
*/
|
||||
computeTooltip(event, sprite) {
|
||||
if (sprite.isOver) {
|
||||
const oddq = TMRUtility.computeEventOddq(event);
|
||||
const coord = TMRUtility.oddqToCoordTMR(oddq);
|
||||
const tmr = TMRUtility.getTMR(coord)
|
||||
if (tmr){
|
||||
const label = TMRUtility.getTMRLabel(coord);
|
||||
const text = this.tooltip(this.linkData);
|
||||
return text ? `${coord}: ${label}\n${text}` : `${coord}: ${label}`
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* factory d'élément graphique PIXI correpsondant à l'objet draconique
|
||||
* @param {*} pixiTMR instance de PixiTMR qui gère les tooltips, les méthodes de création de sprite standard, les clicks.
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { RdDTMRDialog } from "../rdd-tmr-dialog.js";
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
|
||||
const tooltipStyle = new PIXI.TextStyle({
|
||||
export const tooltipStyle = new PIXI.TextStyle({
|
||||
fontFamily: 'CaslonAntique',
|
||||
fontSize: 18,
|
||||
fill: '#FFFFFF',
|
||||
@ -20,7 +22,7 @@ export class PixiTMR {
|
||||
this.callbacksOnAnimate = [];
|
||||
}
|
||||
|
||||
async load( onLoad = (loader, resources) => {} ) {
|
||||
async load(onLoad = (loader, resources) => { }) {
|
||||
// WIP - Deprecated since v7 : let loader = new PIXI.Loader();
|
||||
for (const [name, img] of Object.entries(PixiTMR.textures)) {
|
||||
const texture = await PIXI.Assets.load(img);
|
||||
@ -40,33 +42,10 @@ export class PixiTMR {
|
||||
PixiTMR.textures[name] = img;
|
||||
}
|
||||
|
||||
animate(animation = pixiApp=>{})
|
||||
{
|
||||
animate(animation = pixiApp => { }) {
|
||||
this.callbacksOnAnimate.push(() => animation(this.pixiApp));
|
||||
}
|
||||
|
||||
carteTmr(code) {
|
||||
let img = PixiTMR.getImgFromCode(code)
|
||||
const carteTmr = new PIXI.Sprite(PIXI.utils.TextureCache[img]);
|
||||
console.log(code, carteTmr)
|
||||
// Setup the position of the TMR
|
||||
carteTmr.x = 0;
|
||||
carteTmr.y = 0;
|
||||
carteTmr.width = 720;
|
||||
carteTmr.height = 860;
|
||||
// Rotate around the center
|
||||
carteTmr.anchor.set(0);
|
||||
carteTmr.eventMode = 'dynamic'; // PIXI 7 : Not sure ..
|
||||
// This one is deprecated ; carteTmr.interactive = true;
|
||||
carteTmr.buttonMode = true;
|
||||
carteTmr.tmrObject = this;
|
||||
if (!this.tmrObject.viewOnly) {
|
||||
carteTmr.on('pointerdown', event => this.onClickBackground(event));
|
||||
}
|
||||
this.pixiApp.stage.addChild(carteTmr);
|
||||
return carteTmr;
|
||||
}
|
||||
|
||||
sprite(code, options = {}) {
|
||||
let img = PixiTMR.getImgFromCode(code)
|
||||
const texture = PIXI.utils.TextureCache[img];
|
||||
@ -81,7 +60,7 @@ export class PixiTMR {
|
||||
if (options.color) {
|
||||
sprite.tint = options.color;
|
||||
}
|
||||
sprite.zIndex = options.zIndex ?? tmrTokenZIndex.casehumide+1;
|
||||
sprite.zIndex = options.zIndex ?? tmrTokenZIndex.casehumide + 1;
|
||||
sprite.alpha = options.alpha ?? 0.75;
|
||||
sprite.decallage = options.decallage ?? tmrConstants.center;
|
||||
this.pixiApp.stage.addChild(sprite);
|
||||
@ -98,27 +77,37 @@ export class PixiTMR {
|
||||
return sprite;
|
||||
}
|
||||
|
||||
addTooltip(sprite, text) {
|
||||
if (text) {
|
||||
sprite.tooltip = new PIXI.Text(text, tooltipStyle);
|
||||
addTooltip(sprite, computeTooltip) {
|
||||
sprite.tooltip = new PIXI.Text('', tooltipStyle);
|
||||
sprite.tooltip.zIndex = tmrTokenZIndex.tooltip;
|
||||
sprite.isOver = false;
|
||||
// Deprecated : sprite.interactive = true;
|
||||
sprite.eventMode = 'dynamic'; // PIXI 7 To be checked
|
||||
sprite.on('pointerdown', event => this.onClickBackground(event))
|
||||
.on('pointerover', () => this.onShowTooltip(sprite))
|
||||
.on('pointerout', () => this.onHideTooltip(sprite));
|
||||
sprite
|
||||
.on('pointermove', event => this.onPointerMove(event, sprite, computeTooltip))
|
||||
.on('pointerdown', event => this.onClickBackground(event))
|
||||
.on('pointerover', event => this.onShowTooltip(event, sprite))
|
||||
.on('pointerout', event => this.onHideTooltip(event, sprite));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onClickBackground(event) {
|
||||
if (!this.viewOnly) {
|
||||
this.tmrObject.onClickTMR(event)
|
||||
}
|
||||
}
|
||||
|
||||
onShowTooltip(sprite) {
|
||||
onPointerMove(event, sprite, computeTooltip) {
|
||||
if (sprite.isOver && sprite.tooltip) {
|
||||
var { x, y } = TMRUtility.computeEventPosition(event);
|
||||
const oddq = TMRUtility.computeOddq(x, y);
|
||||
|
||||
sprite.tooltip.x = x + (oddq.col > 8 ? - 3 * tmrConstants.full : tmrConstants.half)
|
||||
sprite.tooltip.y = y + (oddq.row > 10 ? - tmrConstants.half : tmrConstants.half)
|
||||
sprite.tooltip.text = computeTooltip(event, sprite);
|
||||
}
|
||||
}
|
||||
|
||||
onShowTooltip(event, sprite) {
|
||||
if (sprite.tooltip) {
|
||||
|
||||
if (!sprite.isOver) {
|
||||
sprite.tooltip.x = sprite.x;
|
||||
sprite.tooltip.y = sprite.y;
|
||||
@ -128,7 +117,7 @@ export class PixiTMR {
|
||||
}
|
||||
}
|
||||
|
||||
onHideTooltip(sprite) {
|
||||
onHideTooltip(event, sprite) {
|
||||
if (sprite.tooltip) {
|
||||
if (sprite.isOver) {
|
||||
this.pixiApp.stage.removeChild(sprite.tooltip);
|
||||
@ -137,7 +126,7 @@ export class PixiTMR {
|
||||
}
|
||||
}
|
||||
|
||||
setPosition( sprite, oddq) {
|
||||
setPosition(sprite, oddq) {
|
||||
let decallagePairImpair = (oddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
let dx = (sprite.decallage == undefined) ? 0 : sprite.decallage.x;
|
||||
let dy = (sprite.decallage == undefined) ? 0 : sprite.decallage.y;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 313 KiB |
BIN
styles/img/ui/tmr.webp
Normal file
BIN
styles/img/ui/tmr.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 637 KiB |
@ -171,6 +171,9 @@ i:is(.fas, .far) {
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.tmr-dialog table {
|
||||
border: none;
|
||||
}
|
||||
.system-foundryvtt-reve-de-dragon .sheet-header div.tmr-buttons {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"id": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"version": "11.0.23",
|
||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-11.0.23.zip",
|
||||
"version": "11.0.24",
|
||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-11.0.24.zip",
|
||||
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v11/system.json",
|
||||
"changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md",
|
||||
"compatibility": {
|
||||
|
@ -1,7 +1,5 @@
|
||||
<form class="tmr-dialog">
|
||||
<h2 class="comptmrdialog" id="tmrDialogTitle"></h2>
|
||||
|
||||
<table id="tmrsheet">
|
||||
<table>
|
||||
<tr id="tmrrow1">
|
||||
<td>
|
||||
{{#if (eq mode "visu")}}
|
||||
|
Loading…
Reference in New Issue
Block a user