mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 04:01:06 +01:00
Merged with development
This commit is contained in:
commit
379398f2c7
46 changed files with 968 additions and 73 deletions
|
|
@ -5,4 +5,5 @@ 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 { default as DhSceneNavigation } from './sceneNavigation.mjs';
|
||||
export { ItemBrowser } from './itemBrowser.mjs';
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
|
|||
resource,
|
||||
active: index === combat.turn,
|
||||
canPing: combatant.sceneId === canvas.scene?.id && game.user.hasPermission('PING_CANVAS'),
|
||||
type: combatant.actor.system.type,
|
||||
type: combatant.actor?.system?.type,
|
||||
img: await this._getCombatantThumbnail(combatant)
|
||||
};
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
|
|||
|
||||
if (this.viewed.turn !== toggleTurn) {
|
||||
const { updateCountdowns } = game.system.api.applications.ui.DhCountdowns;
|
||||
if (combatant.actor.type === 'character') {
|
||||
if (combatant.actor?.type === 'character') {
|
||||
await updateCountdowns(
|
||||
CONFIG.DH.GENERAL.countdownProgressionTypes.spotlight.id,
|
||||
CONFIG.DH.GENERAL.countdownProgressionTypes.characterSpotlight.id
|
||||
|
|
|
|||
89
module/applications/ui/sceneNavigation.mjs
Normal file
89
module/applications/ui/sceneNavigation.mjs
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
import { emitAsGM, GMUpdateEvent } from '../../systemRegistration/socket.mjs';
|
||||
|
||||
export default class DhSceneNavigation extends foundry.applications.ui.SceneNavigation {
|
||||
/** @inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
...super.DEFAULT_OPTIONS,
|
||||
classes: ['faded-ui', 'flexcol', 'scene-navigation'],
|
||||
actions: {
|
||||
openSceneEnvironment: DhSceneNavigation.#openSceneEnvironment
|
||||
}
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
static PARTS = {
|
||||
scenes: {
|
||||
root: true,
|
||||
template: 'systems/daggerheart/templates/ui/sceneNavigation/scene-navigation.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
||||
const extendScenes = scenes =>
|
||||
scenes.map(x => {
|
||||
const scene = game.scenes.get(x.id);
|
||||
if (!scene.flags.daggerheart) return x;
|
||||
|
||||
const daggerheartInfo = new game.system.api.data.scenes.DHScene(scene.flags.daggerheart);
|
||||
const environments = daggerheartInfo.sceneEnvironments.filter(
|
||||
x => x && x.testUserPermission(game.user, 'LIMITED')
|
||||
);
|
||||
const hasEnvironments = environments.length > 0;
|
||||
return {
|
||||
...x,
|
||||
hasEnvironments,
|
||||
environmentImage: hasEnvironments ? environments[0].img : null,
|
||||
environments: environments
|
||||
};
|
||||
});
|
||||
context.scenes.active = extendScenes(context.scenes.active);
|
||||
context.scenes.inactive = extendScenes(context.scenes.inactive);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static async #openSceneEnvironment(event, button) {
|
||||
const scene = game.scenes.get(button.dataset.sceneId);
|
||||
const sceneEnvironments = new game.system.api.data.scenes.DHScene(
|
||||
scene.flags.daggerheart
|
||||
).sceneEnvironments.filter(x => x.testUserPermission(game.user, 'LIMITED'));
|
||||
|
||||
if (sceneEnvironments.length === 1 || event.shiftKey) {
|
||||
sceneEnvironments[0].sheet.render(true);
|
||||
} else {
|
||||
new foundry.applications.ux.ContextMenu.implementation(
|
||||
button,
|
||||
'.scene-environment',
|
||||
sceneEnvironments.map(environment => ({
|
||||
name: environment.name,
|
||||
callback: () => {
|
||||
if (scene.flags.daggerheart.sceneEnvironments[0] !== environment.uuid) {
|
||||
const newEnvironments = scene.flags.daggerheart.sceneEnvironments;
|
||||
const newFirst = newEnvironments.splice(
|
||||
newEnvironments.findIndex(x => x === environment.uuid)
|
||||
)[0];
|
||||
newEnvironments.unshift(newFirst);
|
||||
emitAsGM(
|
||||
GMUpdateEvent.UpdateDocument,
|
||||
scene.update.bind(scene),
|
||||
{ 'flags.daggerheart.sceneEnvironments': newEnvironments },
|
||||
scene.uuid
|
||||
);
|
||||
}
|
||||
|
||||
environment.sheet.render({ force: true });
|
||||
}
|
||||
})),
|
||||
{
|
||||
jQuery: false,
|
||||
fixed: true
|
||||
}
|
||||
);
|
||||
|
||||
CONFIG.ux.ContextMenu.triggerContextMenu(event, '.scene-environment');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue