Merge branch 'main' into feature/Character-Setup-Rework

This commit is contained in:
WBHarry 2025-07-11 23:46:39 +02:00
commit 8079dec639
42 changed files with 752 additions and 66 deletions

View file

@ -1,5 +1,6 @@
export * as characterCreation from './characterCreation/_module.mjs';
export * as dialogs from './dialogs/_module.mjs';
export * as hud from './hud/_module.mjs';
export * as levelup from './levelup/_module.mjs';
export * as settings from './settings/_module.mjs';
export * as sheets from './sheets/_module.mjs';

View file

@ -0,0 +1 @@
export { default as DHTokenHUD } from './tokenHud.mjs';

View file

@ -0,0 +1,84 @@
export default class DHTokenHUD extends TokenHUD {
static DEFAULT_OPTIONS = {
classes: ['daggerheart']
};
/** @override */
static PARTS = {
hud: {
root: true,
template: 'systems/daggerheart/templates/hud/tokenHUD.hbs'
}
};
async _prepareContext(options) {
const context = await super._prepareContext(options);
context.systemStatusEffects = Object.keys(context.statusEffects).reduce((acc, key) => {
const effect = context.statusEffects[key];
if (effect.systemEffect) acc[key] = effect;
return acc;
}, {});
const useGeneric = game.settings.get(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.appearance
).showGenericStatusEffects;
context.genericStatusEffects = useGeneric
? Object.keys(context.statusEffects).reduce((acc, key) => {
const effect = context.statusEffects[key];
if (!effect.systemEffect) acc[key] = effect;
return acc;
}, {})
: null;
return context;
}
_getStatusEffectChoices() {
// Include all HUD-enabled status effects
const choices = {};
for (const status of CONFIG.statusEffects) {
if (
status.hud === false ||
(foundry.utils.getType(status.hud) === 'Object' &&
status.hud.actorTypes?.includes(this.document.actor.type) === false)
) {
continue;
}
choices[status.id] = {
_id: status._id,
id: status.id,
systemEffect: status.systemEffect,
title: game.i18n.localize(status.name ?? /** @deprecated since v12 */ status.label),
src: status.img ?? /** @deprecated since v12 */ status.icon,
isActive: false,
isOverlay: false
};
}
// Update the status of effects which are active for the token actor
const activeEffects = this.actor?.effects || [];
for (const effect of activeEffects) {
for (const statusId of effect.statuses) {
const status = choices[statusId];
if (!status) continue;
if (status._id) {
if (status._id !== effect.id) continue;
} else {
if (effect.statuses.size !== 1) continue;
}
status.isActive = true;
if (effect.getFlag('core', 'overlay')) status.isOverlay = true;
break;
}
}
// Flag status CSS class
for (const status of Object.values(choices)) {
status.cssClass = [status.isActive ? 'active' : null, status.isOverlay ? 'overlay' : null].filterJoin(' ');
}
return choices;
}
}

View file

@ -10,6 +10,7 @@ export default class AdversarySheet extends DHBaseActorSheet {
actions: {
reactionRoll: AdversarySheet.#reactionRoll,
useItem: this.useItem,
useAction: this.useItem,
toChat: this.toChat
},
window: {

View file

@ -24,6 +24,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
levelManagement: CharacterSheet.#levelManagement,
toggleEquipItem: CharacterSheet.#toggleEquipItem,
useItem: this.useItem, //TODO Fix this
useAction: this.useAction,
toChat: this.toChat
},
window: {
@ -620,6 +621,20 @@ export default class CharacterSheet extends DHBaseActorSheet {
}
}
/**
* Use an action
* @type {ApplicationClickAction}
*/
static async useAction(event, button) {
const item = this.getItem(button);
if (!item) return;
const action = item.system.actions.find(x => x.id === button.dataset.actionId);
if (!action) return;
action.use(event);
}
/**
* Send item to Chat
* @type {ApplicationClickAction}

View file

@ -11,6 +11,7 @@ export default class DhpEnvironment extends DHBaseActorSheet {
},
actions: {
useItem: this.useItem,
useAction: this.useItem,
toChat: this.toChat
},
dragDrop: [{ dragSelector: '.action-section .inventory-item', dropSelector: null }]