Tweaked reverse the token's bar on fatigue and colorize in red the strife bar if compromise
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
- Added a booster for loading compendium's core items (speed up 20Q)
|
- Added a booster for loading compendium's core items (speed up 20Q)
|
||||||
- Added confirm dialog on item's deletion (Hold "ctrl" on the click, if you want to bypass it)
|
- Added confirm dialog on item's deletion (Hold "ctrl" on the click, if you want to bypass it)
|
||||||
- Added "Sleep" & "Scene End" buttons in "GM ToolBox" (old "difficulty" box)
|
- Added "Sleep" & "Scene End" buttons in "GM ToolBox" (old "difficulty" box)
|
||||||
|
- Added an option to reverse the token's bar on fatigue (thanks to Jzrzmy), and colorize in red the strife bar if compromise
|
||||||
|
|
||||||
## 1.1.2 - One Compendium to bring them all
|
## 1.1.2 - One Compendium to bring them all
|
||||||
- Added compendiums (Thanks to Stéfano Fara for the English version !) Partial for French as PoW and CR are not translated yet
|
- Added compendiums (Thanks to Stéfano Fara for the English version !) Partial for French as PoW and CR are not translated yet
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
},
|
},
|
||||||
"SETTINGS": {
|
"SETTINGS": {
|
||||||
"None": "Sin opción",
|
"None": "Sin opción",
|
||||||
|
|
||||||
"ReverseFatigueBar": "Invertir la barra de fatiga de los token",
|
"ReverseFatigueBar": "Invertir la barra de fatiga de los token",
|
||||||
"RollNKeep": {
|
"RollNKeep": {
|
||||||
"DeleteOldMessage": "RnK Delete previous chat message",
|
"DeleteOldMessage": "RnK Delete previous chat message",
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
"None": "Aucune option",
|
"None": "Aucune option",
|
||||||
"ReverseFatigueBar": "Inverser la barre de fatigue des token",
|
"ReverseFatigueBar": "Inverser la barre de fatigue des token",
|
||||||
"RollNKeep": {
|
"RollNKeep": {
|
||||||
"DeleteOldMessage": "RnK Delete previous chat message",
|
"DeleteOldMessage": "RnK Supprime le précédent message du chat",
|
||||||
"DeleteOldMessageHint": "Choose to keep or delete the previous message for a RnK series"
|
"DeleteOldMessageHint": "Si coché, on supprime le message précédent pour la série de jets via le RnK"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ACTOR": {
|
"ACTOR": {
|
||||||
|
|||||||
@@ -116,30 +116,36 @@ Hooks.once("init", async () => {
|
|||||||
|
|
||||||
// Override the default Token _drawBar function to allow fatigue bar reversing.
|
// Override the default Token _drawBar function to allow fatigue bar reversing.
|
||||||
Token.prototype._drawBar = function (number, bar, data) {
|
Token.prototype._drawBar = function (number, bar, data) {
|
||||||
let val = Number(data.value);
|
const reverseBar = data.attribute === "fatigue" && game.settings.get("l5r5e", "token.reverseFatigueBar");
|
||||||
const reverseFatigue = game.settings.get("l5r5e", "token.reversefatiguebar");
|
|
||||||
|
// Bar value
|
||||||
// Bar value reversing.
|
const pct = Math.clamped(Number(data.value), 0, data.max) / data.max;
|
||||||
if (data.attribute === "fatigue" && reverseFatigue) {
|
|
||||||
val = Number(data.max - data.value);
|
// Modify color
|
||||||
|
let color = number === 0 ? [pct / 1.2, 1 - pct, 0] : [0.5 * pct, 0.7 * pct, 0.5 + pct / 2];
|
||||||
|
|
||||||
|
// Red if compromised
|
||||||
|
if (data.attribute === "strife" && data.value > data.max) {
|
||||||
|
color = [1, 0.1, 0.1];
|
||||||
}
|
}
|
||||||
|
|
||||||
const pct = Math.clamped(val, 0, data.max) / data.max;
|
// Enlarge the bar for large tokens
|
||||||
let h = Math.max(canvas.dimensions.size / 12, 8);
|
let h = Math.max(canvas.dimensions.size / 12, 8);
|
||||||
if (this.data.height >= 2) h *= 1.6; // Enlarge the bar for large tokens
|
if (this.data.height >= 2) {
|
||||||
|
h *= 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the bar
|
// Draw the bar
|
||||||
let color = number === 0 ? [1 - pct / 2, pct, 0] : [0.5 * pct, 0.7 * pct, 0.5 + pct / 2];
|
bar.clear()
|
||||||
bar
|
.beginFill(0x000000, 0.5)
|
||||||
.clear()
|
.lineStyle(2, 0x000000, 0.9)
|
||||||
.beginFill(0x000000, 0.5)
|
.drawRoundedRect(0, 0, this.w, h, 3)
|
||||||
.lineStyle(2, 0x000000, 0.9)
|
.beginFill(PIXI.utils.rgb2hex(color), 0.8)
|
||||||
.drawRoundedRect(0, 0, this.w, h, 3)
|
.lineStyle(1, 0x000000, 0.8)
|
||||||
.beginFill(PIXI.utils.rgb2hex(color), 0.8)
|
.drawRoundedRect(1, 1, (reverseBar ? 1 - pct : pct) * (this.w - 2), h - 2, 2);
|
||||||
.lineStyle(1, 0x000000, 0.8)
|
|
||||||
.drawRoundedRect(1, 1, pct * (this.w - 2), h - 2, 2);
|
|
||||||
// Set position
|
// Set position
|
||||||
let posY = number === 0 ? this.h - h : 0;
|
bar.position.set(0, number === 0 ? this.h - h : 0);
|
||||||
bar.position.set(0, posY);
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ export const RegisterSettings = function () {
|
|||||||
|
|
||||||
/* ------------------------------------ */
|
/* ------------------------------------ */
|
||||||
/* Token bars */
|
/* Token bars */
|
||||||
/* ------------------------------------ */
|
/* ------------------------------------ */
|
||||||
game.settings.register("l5r5e", "token.reversefatiguebar", {
|
game.settings.register("l5r5e", "token.reverseFatigueBar", {
|
||||||
name: game.i18n.localize("SETTINGS.ReverseFatigueBar"),
|
name: game.i18n.localize("SETTINGS.ReverseFatigueBar"),
|
||||||
scope: "world",
|
scope: "world",
|
||||||
config: true,
|
config: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user