mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Merged with main
This commit is contained in:
parent
4510deae96
commit
01dd5ced94
10 changed files with 165 additions and 5 deletions
|
|
@ -61,6 +61,7 @@ CONFIG.Token.hudClass = applications.hud.DHTokenHUD;
|
|||
|
||||
CONFIG.ui.combat = applications.ui.DhCombatTracker;
|
||||
CONFIG.ui.chat = applications.ui.DhChatLog;
|
||||
CONFIG.ui.effectsDisplay = applications.ui.DhEffectsDisplay;
|
||||
CONFIG.ui.hotbar = applications.ui.DhHotbar;
|
||||
CONFIG.ui.sidebar = applications.sidebar.DhSidebar;
|
||||
CONFIG.ui.daggerheartMenu = applications.sidebar.DaggerheartMenu;
|
||||
|
|
@ -167,6 +168,9 @@ Hooks.on('ready', async () => {
|
|||
ui.countdowns.render({ force: true });
|
||||
}
|
||||
|
||||
ui.effectsDisplay = new CONFIG.ui.effectsDisplay();
|
||||
ui.effectsDisplay.render({ force: true });
|
||||
|
||||
if (!(ui.compendiumBrowser instanceof applications.ui.ItemBrowser))
|
||||
ui.compendiumBrowser = new applications.ui.ItemBrowser();
|
||||
|
||||
|
|
|
|||
|
|
@ -2585,6 +2585,9 @@
|
|||
"decreasingLoop": "Decreasing Looping",
|
||||
"increasingLoop": "Increasing Looping"
|
||||
},
|
||||
"EffectsDisplay": {
|
||||
"title": ""
|
||||
},
|
||||
"ItemBrowser": {
|
||||
"title": "Daggerheart Compendium Browser",
|
||||
"hint": "Select a Folder in sidebar to start browsing through the compendium",
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
}
|
||||
|
||||
.daggerheart.dh-style.countdowns {
|
||||
position: initial;
|
||||
position: relative;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
box-shadow: none;
|
||||
|
|
@ -24,6 +24,10 @@
|
|||
font-family: @font-body;
|
||||
}
|
||||
|
||||
&.effects-present {
|
||||
right: 180px;
|
||||
}
|
||||
|
||||
&.icon-only {
|
||||
width: 180px;
|
||||
min-width: 180px;
|
||||
|
|
|
|||
23
styles/less/ui/effects-display/sheet.less
Normal file
23
styles/less/ui/effects-display/sheet.less
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
.daggerheart.dh-style.effects-display {
|
||||
position: absolute;
|
||||
width: 68px;
|
||||
max-height: 300px;
|
||||
overflow: hidden;
|
||||
|
||||
.window-content {
|
||||
> div {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.effects-display-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
.effect-container {
|
||||
img {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -31,3 +31,5 @@
|
|||
@import './sidebar/daggerheartMenu.less';
|
||||
|
||||
@import './scene-config/scene-config.less';
|
||||
|
||||
@import './effects-display/sheet.less';
|
||||
|
|
|
|||
7
templates/ui/effects-display.hbs
Normal file
7
templates/ui/effects-display.hbs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<div class="effects-display-container">
|
||||
{{#each effects as | effect |}}
|
||||
<div class="effect-container">
|
||||
<img src="{{effect.img}}" />
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue