[Feature] 688 - Token Resource Bar (#699)

* Fixed resource bar to a segmented one in one colour. Fixed handful localization

* Darkened the blue
This commit is contained in:
WBHarry 2025-08-07 17:11:32 +02:00 committed by GitHub
parent 2c8614fbd5
commit df99d0e4c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 49 additions and 13 deletions

View file

@ -156,7 +156,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
currency: {
title: game.i18n.localize('DAGGERHEART.CONFIG.Gold.title'),
coins: game.i18n.localize('DAGGERHEART.CONFIG.Gold.coins'),
handfulls: game.i18n.localize('DAGGERHEART.CONFIG.Gold.handfulls'),
handfuls: game.i18n.localize('DAGGERHEART.CONFIG.Gold.handfuls'),
bags: game.i18n.localize('DAGGERHEART.CONFIG.Gold.bags'),
chests: game.i18n.localize('DAGGERHEART.CONFIG.Gold.chests')
}

View file

@ -53,4 +53,40 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
this.effects.renderable = true;
this.renderFlags.set({ refreshEffects: true });
}
/** @inheritDoc */
_drawBar(number, bar, data) {
const val = Number(data.value);
const pct = Math.clamp(val, 0, data.max) / data.max;
// Determine sizing
const { width, height } = this.document.getSize();
const s = canvas.dimensions.uiScale;
const bw = width;
const bh = 8 * (this.document.height >= 2 ? 1.5 : 1) * s;
// Determine the color to use
const fillColor =
number === 0 ? foundry.utils.Color.fromRGB([1, 0, 0]) : foundry.utils.Color.fromString('#0032b1');
// Draw the bar
const widthUnit = bw / data.max;
bar.clear().lineStyle(s, 0x000000, 1.0);
const sections = [...Array(data.max).keys()];
for (let mark of sections) {
const x = mark * widthUnit;
const marked = mark + 1 <= data.value;
const color = marked ? fillColor : foundry.utils.Color.fromRGB([0, 0, 0]);
if (mark === 0 || mark === sections.length - 1) {
bar.beginFill(color, marked ? 1.0 : 0.5).drawRect(x, 0, widthUnit, bh, 2 * s); // Would like drawRoundedRect, but it's very troublsome with the corners. Leaving for now.
} else {
bar.beginFill(color, marked ? 1.0 : 0.5).drawRect(x, 0, widthUnit, bh, 2 * s);
}
}
// Set position
const posY = number === 0 ? height - bh : 0;
bar.position.set(0, posY);
return true;
}
}

View file

@ -857,7 +857,7 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.greedy.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.greedy.description',
img: 'icons/commodities/currency/coins-crown-stack-gold.webp',
// Should cost handfull of gold,
// Should cost handful of gold,
effects: [
{
name: 'DAGGERHEART.CONFIG.WeaponFeature.greedy.actions.greed.name',

View file

@ -73,7 +73,7 @@ export default class DhCharacter extends BaseDataActor {
),
gold: new fields.SchemaField({
coins: new fields.NumberField({ initial: 0, integer: true }),
handfulls: new fields.NumberField({ initial: 1, integer: true }),
handfuls: new fields.NumberField({ initial: 1, integer: true }),
bags: new fields.NumberField({ initial: 0, integer: true }),
chests: new fields.NumberField({ initial: 0, integer: true })
}),

View file

@ -45,10 +45,10 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
initial: 'Coins',
label: 'DAGGERHEART.SETTINGS.Homebrew.currency.coinName'
}),
handfulls: new fields.StringField({
handfuls: new fields.StringField({
required: true,
initial: 'Handfulls',
label: 'DAGGERHEART.SETTINGS.Homebrew.currency.handfullName'
initial: 'Handfuls',
label: 'DAGGERHEART.SETTINGS.Homebrew.currency.handfulName'
}),
bags: new fields.StringField({
required: true,