mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Initial
This commit is contained in:
parent
bca7e0d3c9
commit
6140b4baaf
12 changed files with 345 additions and 13 deletions
|
|
@ -62,6 +62,7 @@ CONFIG.Token.rulerClass = placeables.DhTokenRuler;
|
|||
CONFIG.Token.hudClass = applications.hud.DHTokenHUD;
|
||||
|
||||
CONFIG.ui.combat = applications.ui.DhCombatTracker;
|
||||
CONFIG.ui.nav = applications.ui.DhSceneNavigation;
|
||||
CONFIG.ui.chat = applications.ui.DhChatLog;
|
||||
CONFIG.ui.effectsDisplay = applications.ui.DhEffectsDisplay;
|
||||
CONFIG.ui.hotbar = applications.ui.DhHotbar;
|
||||
|
|
|
|||
12
lang/en.json
12
lang/en.json
|
|
@ -1016,6 +1016,14 @@
|
|||
"spell": "Spell",
|
||||
"grimoire": "Grimoire"
|
||||
},
|
||||
"EnvironmentIcons": {
|
||||
"city": "City",
|
||||
"dungeon": "Dungeon",
|
||||
"mountain": "Mountain",
|
||||
"social": "Social",
|
||||
"tree": "Tree",
|
||||
"water": "Water"
|
||||
},
|
||||
"EnvironmentType": {
|
||||
"exploration": {
|
||||
"label": "Exploration",
|
||||
|
|
@ -2567,7 +2575,9 @@
|
|||
}
|
||||
},
|
||||
"disabledText": "Daggerheart Measurements are disabled in System Settings - Variant Rules",
|
||||
"rangeMeasurement": "Range Measurement"
|
||||
"rangeMeasurement": "Range Measurement",
|
||||
"sceneEnvironments": "Scene Environments",
|
||||
"noEnvironmentLinked": "Drag in an environment"
|
||||
}
|
||||
},
|
||||
"UI": {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
export default class DhSceneConfigSettings extends foundry.applications.sheets.SceneConfig {
|
||||
// static DEFAULT_OPTIONS = {
|
||||
// ...super.DEFAULT_OPTIONS,
|
||||
// form: {
|
||||
// handler: this.updateData,
|
||||
// closeOnSubmit: true
|
||||
// }
|
||||
// };
|
||||
static DEFAULT_OPTIONS = {
|
||||
...super.DEFAULT_OPTIONS,
|
||||
actions: {
|
||||
...super.DEFAULT_OPTIONS.actions,
|
||||
addSceneEnvironment: DhSceneConfigSettings.#addSceneEnvironment,
|
||||
removeSceneEnvironment: DhSceneConfigSettings.#removeSceneEnvironment
|
||||
}
|
||||
};
|
||||
|
||||
static buildParts() {
|
||||
const { footer, tabs, ...parts } = super.PARTS;
|
||||
|
|
@ -30,6 +31,7 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
|
|||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
switch (partId) {
|
||||
case 'dh':
|
||||
htmlElement.querySelector('#rangeMeasurementSetting')?.addEventListener('change', async event => {
|
||||
|
|
@ -39,10 +41,37 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
|
|||
this.document.flags.daggerheart = flagData;
|
||||
this.render();
|
||||
});
|
||||
|
||||
htmlElement.querySelectorAll('.scene-environment').forEach(element => {
|
||||
element.querySelector('select')?.addEventListener('change', async event => {
|
||||
const id = event.target.dataset.key;
|
||||
const flagData = foundry.utils.mergeObject(this.document.flags.daggerheart, {
|
||||
sceneEnvironments: { [id]: { icon: event.target.value } }
|
||||
});
|
||||
this.document.flags.daggerheart = flagData;
|
||||
this.render();
|
||||
});
|
||||
|
||||
element.ondrop = this._onDrop.bind(this);
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
const item = await foundry.utils.fromUuid(data.uuid);
|
||||
if (item instanceof game.system.api.documents.DhpActor && item.type === 'environment') {
|
||||
const element = event.target.closest('.scene-environment');
|
||||
const flagData = foundry.utils.mergeObject(this.document.flags.daggerheart, {
|
||||
sceneEnvironments: { [element.dataset.key]: { environment: data.uuid } }
|
||||
});
|
||||
this.document.flags.daggerheart = flagData;
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
async _preparePartContext(partId, context, options) {
|
||||
context = await super._preparePartContext(partId, context, options);
|
||||
|
|
@ -50,14 +79,41 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
|
|||
case 'dh':
|
||||
context.data = new game.system.api.data.scenes.DHScene(canvas.scene.flags.daggerheart);
|
||||
context.variantRules = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules);
|
||||
context.environmentIcons = CONFIG.DH.GENERAL.environmentIcons;
|
||||
break;
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
// static async updateData(event, _, formData) {
|
||||
// const data = foundry.utils.expandObject(formData.object);
|
||||
// this.close(data);
|
||||
// }
|
||||
static async #addSceneEnvironment() {
|
||||
const flagData = foundry.utils.mergeObject(this.document.flags.daggerheart, {
|
||||
sceneEnvironments: { [foundry.utils.randomID()]: { icon: CONFIG.DH.GENERAL.environmentIcons.tree.icon } }
|
||||
});
|
||||
this.document.flags.daggerheart = flagData;
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async #removeSceneEnvironment(_event, button) {
|
||||
this.document.flags.daggerheart.sceneEnvironments = Object.keys(
|
||||
this.document.flags.daggerheart.sceneEnvironments
|
||||
).reduce((acc, key) => {
|
||||
if (key !== button.dataset.key) acc[key] = this.document.flags.daggerheart.sceneEnvironments[key];
|
||||
return acc;
|
||||
}, {});
|
||||
this.render();
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _processSubmitData(event, form, submitData, options) {
|
||||
submitData.flags.daggerheart.sceneEnvironments = this.document.flags.daggerheart.sceneEnvironments;
|
||||
for (const key of Object.keys(this.document._source.flags.daggerheart.sceneEnvironments)) {
|
||||
if (!submitData.flags.daggerheart.sceneEnvironments[key]) {
|
||||
submitData.flags.daggerheart.sceneEnvironments[`-=${key}`] = null;
|
||||
}
|
||||
}
|
||||
|
||||
super._processSubmitData(event, form, submitData, options);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -731,3 +731,36 @@ export const sceneRangeMeasurementSetting = {
|
|||
label: 'Custom'
|
||||
}
|
||||
};
|
||||
|
||||
export const environmentIcons = {
|
||||
tree: {
|
||||
name: 'DAGGERHEART.CONFIG.EnvironmentIcons.tree',
|
||||
icon: 'fa-solid fa-tree',
|
||||
unicode: ''
|
||||
},
|
||||
mountain: {
|
||||
name: 'DAGGERHEART.CONFIG.EnvironmentIcons.mountain',
|
||||
icon: 'fa-solid fa-mountain',
|
||||
unicode: ''
|
||||
},
|
||||
city: {
|
||||
name: 'DAGGERHEART.CONFIG.EnvironmentIcons.city',
|
||||
icon: 'fa-solid fa-house',
|
||||
unicode: ''
|
||||
},
|
||||
dungeon: {
|
||||
name: 'DAGGERHEART.CONFIG.EnvironmentIcons.dungeon',
|
||||
icon: 'fa-solid fa-dungeon',
|
||||
unicode: ''
|
||||
},
|
||||
water: {
|
||||
name: 'DAGGERHEART.CONFIG.EnvironmentIcons.water',
|
||||
icon: 'fa-solid fa-water',
|
||||
unicode: ''
|
||||
},
|
||||
social: {
|
||||
name: 'DAGGERHEART.CONFIG.EnvironmentIcons.social',
|
||||
icon: 'fa-solid fa-masks-theater',
|
||||
unicode: ''
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
||||
|
||||
export default class DHScene extends foundry.abstract.DataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
|
|
@ -13,7 +15,16 @@ export default class DHScene extends foundry.abstract.DataModel {
|
|||
veryClose: new fields.NumberField({ integer: true, label: 'DAGGERHEART.CONFIG.Range.veryClose.name' }),
|
||||
close: new fields.NumberField({ integer: true, label: 'DAGGERHEART.CONFIG.Range.close.name' }),
|
||||
far: new fields.NumberField({ integer: true, label: 'DAGGERHEART.CONFIG.Range.far.name' })
|
||||
}),
|
||||
sceneEnvironments: new fields.TypedObjectField(
|
||||
new fields.SchemaField({
|
||||
environment: new ForeignDocumentUUIDField({ type: 'Actor' }),
|
||||
icon: new fields.StringField({
|
||||
required: true,
|
||||
initial: CONFIG.DH.GENERAL.environmentIcons.tree.icon
|
||||
})
|
||||
})
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,3 +33,5 @@
|
|||
@import './scene-config/scene-config.less';
|
||||
|
||||
@import './effects-display/sheet.less';
|
||||
|
||||
@import './scene-navigation/scene-navigation.less';
|
||||
|
|
|
|||
|
|
@ -37,4 +37,63 @@
|
|||
.helper-text {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.scene-environments {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
.scene-environment {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.scene-environment-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
flex: 1;
|
||||
|
||||
img {
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
h5 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.tags {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
padding-bottom: 0;
|
||||
|
||||
.tag {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 3px 5px;
|
||||
font-size: var(--font-size-12);
|
||||
font: @font-body;
|
||||
|
||||
background: light-dark(@dark-15, @beige-15);
|
||||
border: 1px solid light-dark(@dark, @beige);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: var(--font-size-12);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.remove-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
32
styles/less/ui/scene-navigation/scene-navigation.less
Normal file
32
styles/less/ui/scene-navigation/scene-navigation.less
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#ui-left #ui-left-column-2 {
|
||||
flex: 0 0 230px;
|
||||
|
||||
.scene-navigation {
|
||||
.scene-wrapper {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
height: var(--control-size);
|
||||
width: 100%;
|
||||
|
||||
.scene-environment {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.scene {
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
background: var(--control-bg-color);
|
||||
border: 1px solid var(--control-border-color);
|
||||
border-radius: 4px;
|
||||
color: var(--control-icon-color);
|
||||
pointer-events: all;
|
||||
transition:
|
||||
border 0.25s,
|
||||
color 0.25s;
|
||||
text-shadow: none;
|
||||
width: 200px;
|
||||
max-width: 200px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,4 +21,41 @@
|
|||
<span class="helper-text">{{localize "DAGGERHEART.SETTINGS.Scene.disabledText"}}</span>
|
||||
{{/if}}
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>
|
||||
<span>{{localize "DAGGERHEART.SETTINGS.Scene.sceneEnvironments"}}</span>
|
||||
<a data-action="addSceneEnvironment"><i class="fa-solid fa-plus"></i></a>
|
||||
</legend>
|
||||
|
||||
<div class="scene-environments">
|
||||
{{#each data.sceneEnvironments as |data key|}}
|
||||
<div class="scene-environment" data-key="{{key}}">
|
||||
{{#if data.environment}}
|
||||
<div class="scene-environment-inner">
|
||||
<img src="{{data.environment.img}}" />
|
||||
<h5>{{data.environment.name}}</h5>
|
||||
<div class="tags">
|
||||
<div class="tag">
|
||||
<span>
|
||||
{{localize (concat 'DAGGERHEART.GENERAL.Tiers.' data.environment.system.tier)}}
|
||||
</span>
|
||||
</div>
|
||||
{{#if data.environment.system.type}}
|
||||
<div class="tag">
|
||||
<span>
|
||||
{{localize (concat 'DAGGERHEART.CONFIG.EnvironmentType.' data.environment.system.type '.label')}}
|
||||
</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<span class="drag-area hint">{{localize "DAGGERHEART.SETTINGS.Scene.noEnvironmentLinked"}}</span>
|
||||
{{/if}}
|
||||
<a data-action="removeSceneEnvironment" data-key="{{key}}"><i class="fa-solid fa-trash remove-icon"></i></a>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
36
templates/ui/sceneNavigation/scene-navigation.hbs
Normal file
36
templates/ui/sceneNavigation/scene-navigation.hbs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<nav id="scene-navigation" aria-roledescription="{{localize "SCENE_NAVIGATION.LABEL"}}" data-tooltip-direction="RIGHT">
|
||||
{{#if canExpand}}
|
||||
<a id="scene-navigation-expand" class="ui-control" data-action="toggleExpand">
|
||||
<i class="fa-solid fa-caret-down" inert></i>
|
||||
</a>
|
||||
{{/if}}
|
||||
<menu id="scene-navigation-active" class="scene-navigation-menu flexcol">
|
||||
{{#each scenes.active as |scene|}}
|
||||
<li class="scene-wrapper">
|
||||
<div class="ui-control scene {{scene.cssClass}}" data-scene-id="{{scene.id}}" data-action="viewScene"
|
||||
{{#if scene.tooltip}}data-tooltip-text="{{scene.tooltip}}"{{/if}}>
|
||||
<span class="scene-name ellipsis">{{scene.name}}</span>
|
||||
{{#if scene.users}}
|
||||
<ul class="scene-players">
|
||||
{{#each scene.users as |user|}}
|
||||
<li class="scene-player" style="--color-bg:{{user.color}}; --color-border:{{user.border}}"
|
||||
data-tooltip aria-label="{{user.name}}">{{user.letter}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{#if scene.hasEnvironments}}
|
||||
<button class="ui-control scene-environment" data-action="openSceneEnvironment" data-scene-id="{{scene.id}}"><img src="{{scene.environmentImage}}" /> </button>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</menu>
|
||||
<menu id="scene-navigation-inactive" class="scene-navigation-menu flexcol">
|
||||
{{#each scenes.inactive as |scene|}}
|
||||
<li class="ui-control scene {{scene.cssClass}}" data-scene-id="{{scene.id}}" data-action="viewScene"
|
||||
{{#if scene.tooltip}}data-tooltip-text="{{scene.tooltip}}"{{/if}}>
|
||||
<span class="scene-name ellipsis">{{scene.name}}</span>
|
||||
</li>
|
||||
{{/each}}
|
||||
</menu>
|
||||
</nav>
|
||||
Loading…
Add table
Add a link
Reference in a new issue