mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Merged with main
This commit is contained in:
parent
4510deae96
commit
01dd5ced94
10 changed files with 165 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ export { default as CountdownEdit } from './countdownEdit.mjs';
|
|||
export { default as DhCountdowns } from './countdowns.mjs';
|
||||
export { default as DhChatLog } from './chatLog.mjs';
|
||||
export { default as DhCombatTracker } from './combatTracker.mjs';
|
||||
export { default as DhEffectsDisplay } from './effectsDisplay.mjs';
|
||||
export { default as DhFearTracker } from './fearTracker.mjs';
|
||||
export { default as DhHotbar } from './hotbar.mjs';
|
||||
export { ItemBrowser } from './itemBrowser.mjs';
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
constructor(options = {}) {
|
||||
super(options);
|
||||
|
||||
this.sidebarCollapsed = true;
|
||||
this.setupHooks();
|
||||
}
|
||||
|
||||
|
|
@ -61,6 +60,8 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
async _renderFrame(options) {
|
||||
const frame = await super._renderFrame(options);
|
||||
|
||||
frame.classList.add('effects-present');
|
||||
|
||||
const iconOnly =
|
||||
game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode) ===
|
||||
CONFIG.DH.GENERAL.countdownAppMode.iconOnly;
|
||||
|
|
@ -98,11 +99,10 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
context.isGM = game.user.isGM;
|
||||
context.sidebarCollapsed = this.sidebarCollapsed;
|
||||
|
||||
context.iconOnly =
|
||||
game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode) ===
|
||||
CONFIG.DH.GENERAL.countdownAppMode.iconOnly;
|
||||
|
||||
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
||||
context.countdowns = this.#getCountdowns().reduce((acc, { key, countdown, ownership }) => {
|
||||
const playersWithAccess = game.users.reduce((acc, user) => {
|
||||
|
|
|
|||
116
module/applications/ui/effectsDisplay.mjs
Normal file
116
module/applications/ui/effectsDisplay.mjs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
import { emitAsGM, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
/**
|
||||
* A UI element which displays the Active Effects on a selected token.
|
||||
*
|
||||
* @extends ApplicationV2
|
||||
* @mixes HandlebarsApplication
|
||||
*/
|
||||
|
||||
export default class DhEffectsDisplay extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(options = {}) {
|
||||
super(options);
|
||||
|
||||
this.setupHooks();
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: 'effects-display',
|
||||
tag: 'div',
|
||||
classes: ['daggerheart', 'dh-style', 'effects-display'],
|
||||
window: {
|
||||
frame: false,
|
||||
positioned: false,
|
||||
resizable: false,
|
||||
minimizable: false
|
||||
},
|
||||
actions: {}
|
||||
};
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
resources: {
|
||||
root: true,
|
||||
template: 'systems/daggerheart/templates/ui/effects-display.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
get element() {
|
||||
return document.body.querySelector('.daggerheart.dh-style.effects-display');
|
||||
}
|
||||
|
||||
get hidden() {
|
||||
return this.element.classList.contains('hidden');
|
||||
}
|
||||
|
||||
// /**@inheritdoc */
|
||||
// async _renderFrame(options) {
|
||||
// const frame = await super._renderFrame(options);
|
||||
|
||||
// const header = frame.querySelector('.window-header');
|
||||
// header.querySelector('button[data-action="close"]').remove();
|
||||
|
||||
// if (game.user.isGM) {
|
||||
// const editTooltip = game.i18n.localize('DAGGERHEART.APPLICATIONS.CountdownEdit.editTitle');
|
||||
// const editButton = `<a style="margin-right: 8px;" class="header-control" data-tooltip="${editTooltip}" aria-label="${editTooltip}" data-action="editCountdowns"><i class="fa-solid fa-wrench"></i></a>`;
|
||||
// header.insertAdjacentHTML('beforeEnd', editButton);
|
||||
// }
|
||||
|
||||
// const minimizeTooltip = game.i18n.localize('DAGGERHEART.UI.Countdowns.toggleIconMode');
|
||||
// const minimizeButton = `<a class="header-control" data-tooltip="${minimizeTooltip}" aria-label="${minimizeTooltip}" data-action="toggleViewMode"><i class="fa-solid fa-down-left-and-up-right-to-center"></i></a>`;
|
||||
// header.insertAdjacentHTML('beforeEnd', minimizeButton);
|
||||
|
||||
// return frame;
|
||||
// }
|
||||
|
||||
/** @override */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
context.effects = this.getTokenEffects();
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
getTokenEffects = token => {
|
||||
const actor = token
|
||||
? token.actor
|
||||
: canvas.tokens.controlled.length === 0
|
||||
? !game.user.isGM
|
||||
? game.user.character
|
||||
: null
|
||||
: canvas.tokens.controlled[0].actor;
|
||||
return actor?.effects ?? [];
|
||||
};
|
||||
|
||||
toggleHidden(token, focused) {
|
||||
const effects = this.getTokenEffects(focused ? token : null);
|
||||
this.element.hidden = !focused || effects.size === 0;
|
||||
if (effects.size > 0) this.render();
|
||||
}
|
||||
|
||||
setupHooks() {
|
||||
Hooks.on('controlToken', this.toggleHidden.bind(this));
|
||||
// Hooks.on(socketEvent.Refresh, this.cooldownRefresh.bind());
|
||||
}
|
||||
|
||||
async close(options) {
|
||||
/* Opt out of Foundry's standard behavior of closing all application windows marked as UI when Escape is pressed */
|
||||
if (options.closeKey) return;
|
||||
|
||||
Hooks.off('controlToken', this.toggleHidden);
|
||||
// Hooks.off(socketEvent.Refresh, this.cooldownRefresh);
|
||||
return super.close(options);
|
||||
}
|
||||
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
|
||||
this.element.hidden = context.effects.length === 0;
|
||||
if (options?.force) {
|
||||
document.getElementById('ui-right-column-1')?.appendChild(this.element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ export default class EffectsField extends fields.ArrayField {
|
|||
let effects = this.effects;
|
||||
const messageTargets = [];
|
||||
targets.forEach(async baseToken => {
|
||||
if (this.hasSave && token.saved.success === true) effects = this.effects.filter(e => e.onSave === true);
|
||||
if (this.hasSave && baseToken.saved.success === true) effects = this.effects.filter(e => e.onSave === true);
|
||||
if (!effects.length) return;
|
||||
|
||||
const token =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue