mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Initial
This commit is contained in:
parent
bca7e0d3c9
commit
6140b4baaf
12 changed files with 345 additions and 13 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';
|
||||
|
|
|
|||
54
module/applications/ui/sceneNavigation.mjs
Normal file
54
module/applications/ui/sceneNavigation.mjs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
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 environmentKeys = Object.keys(daggerheartInfo.sceneEnvironments);
|
||||
const hasEnvironments = environmentKeys.length;
|
||||
return {
|
||||
...x,
|
||||
hasEnvironments,
|
||||
environmentImage: hasEnvironments
|
||||
? daggerheartInfo.sceneEnvironments[environmentKeys[0]].environment.img
|
||||
: null,
|
||||
environments: daggerheartInfo.sceneEnvironments
|
||||
};
|
||||
});
|
||||
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 = Object.keys(scene.flags.daggerheart.sceneEnvironments);
|
||||
const environment = await foundry.utils.fromUuid(
|
||||
scene.flags.daggerheart.sceneEnvironments[sceneEnvironments[0]].environment
|
||||
);
|
||||
environment.sheet.render(true);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue