mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-14 04:31:07 +01:00
Merged with development
This commit is contained in:
commit
c32e812803
120 changed files with 2380 additions and 469 deletions
|
|
@ -10,6 +10,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
this.config = config;
|
||||
this.config.experiences = [];
|
||||
this.reactionOverride = config.actionType === 'reaction';
|
||||
this.selectedEffects = this.config.bonusEffects;
|
||||
|
||||
if (config.source?.action) {
|
||||
this.item = config.data.parent.items.get(config.source.item) ?? config.data.parent;
|
||||
|
|
@ -35,6 +36,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
selectExperience: this.selectExperience,
|
||||
toggleReaction: this.toggleReaction,
|
||||
toggleTagTeamRoll: this.toggleTagTeamRoll,
|
||||
toggleSelectedEffect: this.toggleSelectedEffect,
|
||||
submitRoll: this.submitRoll
|
||||
},
|
||||
form: {
|
||||
|
|
@ -76,6 +78,9 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
icon
|
||||
}));
|
||||
|
||||
context.hasSelectedEffects = Boolean(this.selectedEffects && Object.keys(this.selectedEffects).length);
|
||||
context.selectedEffects = this.selectedEffects;
|
||||
|
||||
this.config.costs ??= [];
|
||||
if (this.config.costs?.length) {
|
||||
const updatedCosts = game.system.api.fields.ActionFields.CostField.calcCosts.call(
|
||||
|
|
@ -208,6 +213,11 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
this.render();
|
||||
}
|
||||
|
||||
static toggleSelectedEffect(_event, button) {
|
||||
this.selectedEffects[button.dataset.key].selected = !this.selectedEffects[button.dataset.key].selected;
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async submitRoll() {
|
||||
await this.close({ submitted: true });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
|
||||
this.roll = roll;
|
||||
this.config = config;
|
||||
this.selectedEffects = this.config.bonusEffects;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
|
|
@ -20,6 +21,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
icon: 'fa-solid fa-dice'
|
||||
},
|
||||
actions: {
|
||||
toggleSelectedEffect: this.toggleSelectedEffect,
|
||||
submitRoll: this.submitRoll
|
||||
},
|
||||
form: {
|
||||
|
|
@ -57,6 +59,9 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
icon
|
||||
}));
|
||||
context.modifiers = this.config.modifiers;
|
||||
context.hasSelectedEffects = Boolean(Object.keys(this.selectedEffects).length);
|
||||
context.selectedEffects = this.selectedEffects;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
@ -69,6 +74,11 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
this.render();
|
||||
}
|
||||
|
||||
static toggleSelectedEffect(_event, button) {
|
||||
this.selectedEffects[button.dataset.key].selected = !this.selectedEffects[button.dataset.key].selected;
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async submitRoll() {
|
||||
await this.close({ submitted: true });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,27 +93,29 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
|
|||
}
|
||||
|
||||
getRefreshables() {
|
||||
const actionItems = this.actor.items.filter(x => this.actor.system.isItemAvailable(x)).reduce((acc, x) => {
|
||||
if (x.system.actions) {
|
||||
const recoverable = x.system.actions.reduce((acc, action) => {
|
||||
if (refreshIsAllowed([this.shortrest ? 'shortRest' : 'longRest'], action.uses.recovery)) {
|
||||
acc.push({
|
||||
title: x.name,
|
||||
name: action.name,
|
||||
uuid: action.uuid
|
||||
});
|
||||
const actionItems = this.actor.items
|
||||
.filter(x => this.actor.system.isItemAvailable(x))
|
||||
.reduce((acc, x) => {
|
||||
if (x.system.actions) {
|
||||
const recoverable = x.system.actions.reduce((acc, action) => {
|
||||
if (refreshIsAllowed([this.shortrest ? 'shortRest' : 'longRest'], action.uses.recovery)) {
|
||||
acc.push({
|
||||
title: x.name,
|
||||
name: action.name,
|
||||
uuid: action.uuid
|
||||
});
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
if (recoverable) {
|
||||
acc.push(...recoverable);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
if (recoverable) {
|
||||
acc.push(...recoverable);
|
||||
}
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
return acc;
|
||||
}, []);
|
||||
const resourceItems = this.actor.items.reduce((acc, x) => {
|
||||
if (
|
||||
x.system.resource &&
|
||||
|
|
@ -189,7 +191,8 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
|
|||
}));
|
||||
});
|
||||
});
|
||||
const characters = game.actors.filter(x => x.type === 'character')
|
||||
const characters = game.actors
|
||||
.filter(x => x.type === 'character')
|
||||
.filter(x => x.testUserPermission(game.user, 'LIMITED'))
|
||||
.filter(x => x.uuid !== this.actor.uuid);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,28 @@
|
|||
import { RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
|
||||
|
||||
export default class DhSceneConfigSettings extends foundry.applications.sheets.SceneConfig {
|
||||
// static DEFAULT_OPTIONS = {
|
||||
// ...super.DEFAULT_OPTIONS,
|
||||
// form: {
|
||||
// handler: this.updateData,
|
||||
// closeOnSubmit: true
|
||||
// }
|
||||
// };
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
Hooks.on(socketEvent.Refresh, ({ refreshType }) => {
|
||||
if (refreshType === RefreshType.Scene) {
|
||||
this.daggerheartFlag = new game.system.api.data.scenes.DHScene(this.document.flags.daggerheart);
|
||||
this.render();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
...super.DEFAULT_OPTIONS,
|
||||
actions: {
|
||||
...super.DEFAULT_OPTIONS.actions,
|
||||
removeSceneEnvironment: DhSceneConfigSettings.#removeSceneEnvironment
|
||||
}
|
||||
};
|
||||
|
||||
static buildParts() {
|
||||
const { footer, tabs, ...parts } = super.PARTS;
|
||||
const tmpParts = {
|
||||
// tabs,
|
||||
tabs: { template: 'systems/daggerheart/templates/scene/tabs.hbs' },
|
||||
...parts,
|
||||
dh: { template: 'systems/daggerheart/templates/scene/dh-config.hbs' },
|
||||
|
|
@ -28,27 +40,45 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
|
|||
|
||||
static TABS = DhSceneConfigSettings.buildTabs();
|
||||
|
||||
async _preRender(context, options) {
|
||||
await super._preFirstRender(context, options);
|
||||
this.daggerheartFlag = new game.system.api.data.scenes.DHScene(this.document.flags.daggerheart);
|
||||
}
|
||||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
switch (partId) {
|
||||
case 'dh':
|
||||
htmlElement.querySelector('#rangeMeasurementSetting')?.addEventListener('change', async event => {
|
||||
const flagData = foundry.utils.mergeObject(this.document.flags.daggerheart, {
|
||||
rangeMeasurement: { setting: event.target.value }
|
||||
});
|
||||
this.document.flags.daggerheart = flagData;
|
||||
this.daggerheartFlag.updateSource({ rangeMeasurement: { setting: event.target.value } });
|
||||
this.render();
|
||||
});
|
||||
|
||||
const dragArea = htmlElement.querySelector('.scene-environments');
|
||||
if (dragArea) dragArea.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') {
|
||||
await this.daggerheartFlag.updateSource({
|
||||
sceneEnvironments: [...this.daggerheartFlag.sceneEnvironments, data.uuid]
|
||||
});
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
async _preparePartContext(partId, context, options) {
|
||||
context = await super._preparePartContext(partId, context, options);
|
||||
switch (partId) {
|
||||
case 'dh':
|
||||
context.data = new game.system.api.data.scenes.DHScene(canvas.scene.flags.daggerheart);
|
||||
context.data = this.daggerheartFlag;
|
||||
context.variantRules = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules);
|
||||
break;
|
||||
}
|
||||
|
|
@ -56,8 +86,24 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
|
|||
return context;
|
||||
}
|
||||
|
||||
// static async updateData(event, _, formData) {
|
||||
// const data = foundry.utils.expandObject(formData.object);
|
||||
// this.close(data);
|
||||
// }
|
||||
static async #removeSceneEnvironment(_event, button) {
|
||||
await this.daggerheartFlag.updateSource({
|
||||
sceneEnvironments: this.daggerheartFlag.sceneEnvironments.filter(
|
||||
(_, index) => index !== Number.parseInt(button.dataset.index)
|
||||
)
|
||||
});
|
||||
this.render();
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _processSubmitData(event, form, submitData, options) {
|
||||
submitData.flags.daggerheart = this.daggerheartFlag.toObject();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
|
||||
this.action = action;
|
||||
this.openSection = null;
|
||||
this.openTrigger = this.action.triggers.length > 0 ? 0 : null;
|
||||
}
|
||||
|
||||
get title() {
|
||||
|
|
@ -15,7 +16,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ['daggerheart', 'dh-style', 'dialog', 'max-800'],
|
||||
classes: ['daggerheart', 'dh-style', 'action-config', 'dialog', 'max-800'],
|
||||
window: {
|
||||
icon: 'fa-solid fa-wrench',
|
||||
resizable: false
|
||||
|
|
@ -29,13 +30,18 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
removeElement: this.removeElement,
|
||||
editEffect: this.editEffect,
|
||||
addDamage: this.addDamage,
|
||||
removeDamage: this.removeDamage
|
||||
removeDamage: this.removeDamage,
|
||||
editDoc: this.editDoc,
|
||||
addTrigger: this.addTrigger,
|
||||
removeTrigger: this.removeTrigger,
|
||||
expandTrigger: this.expandTrigger
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false
|
||||
}
|
||||
},
|
||||
dragDrop: [{ dragSelector: null, dropSelector: '#summon-drop-zone', handlers: ['_onDrop'] }]
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
|
|
@ -55,6 +61,10 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
effect: {
|
||||
id: 'effect',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/action-settings/effect.hbs'
|
||||
},
|
||||
trigger: {
|
||||
id: 'trigger',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/action-settings/trigger.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -82,10 +92,18 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
id: 'effect',
|
||||
icon: null,
|
||||
label: 'DAGGERHEART.GENERAL.Tabs.effects'
|
||||
},
|
||||
trigger: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'trigger',
|
||||
icon: null,
|
||||
label: 'DAGGERHEART.GENERAL.Tabs.triggers'
|
||||
}
|
||||
};
|
||||
|
||||
static CLEAN_ARRAYS = ['damage.parts', 'cost', 'effects'];
|
||||
static CLEAN_ARRAYS = ['damage.parts', 'cost', 'effects', 'summon'];
|
||||
|
||||
_getTabs(tabs) {
|
||||
for (const v of Object.values(tabs)) {
|
||||
|
|
@ -96,9 +114,24 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
return tabs;
|
||||
}
|
||||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
htmlElement.querySelectorAll('.summon-count-wrapper input').forEach(element => {
|
||||
element.addEventListener('change', this.updateSummonCount.bind(this));
|
||||
});
|
||||
}
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options, 'action');
|
||||
context.source = this.action.toObject(true);
|
||||
|
||||
context.summons = [];
|
||||
for (const summon of context.source.summon ?? []) {
|
||||
const actor = await foundry.utils.fromUuid(summon.actorUUID);
|
||||
context.summons.push({ actor, count: summon.count });
|
||||
}
|
||||
|
||||
context.openSection = this.openSection;
|
||||
context.tabs = this._getTabs(this.constructor.TABS);
|
||||
context.config = CONFIG.DH;
|
||||
|
|
@ -111,6 +144,16 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
context.baseSaveDifficulty = this.action.actor?.baseSaveDifficulty;
|
||||
context.baseAttackBonus = this.action.actor?.system.attack?.roll.bonus;
|
||||
context.hasRoll = this.action.hasRoll;
|
||||
context.triggers = context.source.triggers.map((trigger, index) => {
|
||||
const { hint, returns, usesActor } = CONFIG.DH.TRIGGER.triggers[trigger.trigger];
|
||||
return {
|
||||
...trigger,
|
||||
hint,
|
||||
returns,
|
||||
usesActor,
|
||||
revealed: this.openTrigger === index
|
||||
};
|
||||
});
|
||||
|
||||
const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers;
|
||||
context.tierOptions = [
|
||||
|
|
@ -181,8 +224,9 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
const submitData = this._prepareSubmitData(event, formData),
|
||||
data = foundry.utils.mergeObject(this.action.toObject(), submitData);
|
||||
const submitData = this._prepareSubmitData(event, formData);
|
||||
|
||||
const data = foundry.utils.mergeObject(this.action.toObject(), submitData);
|
||||
this.action = await this.action.update(data);
|
||||
|
||||
this.sheetUpdate?.(this.action);
|
||||
|
|
@ -201,12 +245,26 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
static removeElement(event, button) {
|
||||
event.stopPropagation();
|
||||
const data = this.action.toObject(),
|
||||
key = event.target.closest('[data-key]').dataset.key,
|
||||
index = button.dataset.index;
|
||||
key = event.target.closest('[data-key]').dataset.key;
|
||||
|
||||
// Prefer explicit index, otherwise find by uuid
|
||||
let index = button?.dataset.index;
|
||||
if (index === undefined || index === null || index === '') {
|
||||
const uuid = button?.dataset.uuid ?? button?.dataset.itemUuid;
|
||||
index = data[key].findIndex(e => (e?.actorUUID ?? e?.uuid) === uuid);
|
||||
if (index === -1) return;
|
||||
} else index = Number(index);
|
||||
|
||||
data[key].splice(index, 1);
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
}
|
||||
|
||||
static async editDoc(_event, target) {
|
||||
const element = target.closest('[data-item-uuid]');
|
||||
const doc = (await foundry.utils.fromUuid(element.dataset.itemUuid)) ?? null;
|
||||
if (doc) return doc.sheet.render({ force: true });
|
||||
}
|
||||
|
||||
static addDamage(_event) {
|
||||
if (!this.action.damage.parts) return;
|
||||
const data = this.action.toObject(),
|
||||
|
|
@ -224,6 +282,69 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
}
|
||||
|
||||
static addTrigger() {
|
||||
const data = this.action.toObject();
|
||||
data.triggers.push({
|
||||
trigger: CONFIG.DH.TRIGGER.triggers.dualityRoll.id,
|
||||
triggeringActor: CONFIG.DH.TRIGGER.triggerActorTargetType.any.id
|
||||
});
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
}
|
||||
|
||||
static async removeTrigger(_event, button) {
|
||||
const trigger = CONFIG.DH.TRIGGER.triggers[this.action.triggers[button.dataset.index].trigger];
|
||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: {
|
||||
title: game.i18n.localize('DAGGERHEART.ACTIONS.Config.deleteTriggerTitle')
|
||||
},
|
||||
content: game.i18n.format('DAGGERHEART.ACTIONS.Config.deleteTriggerContent', {
|
||||
trigger: game.i18n.localize(trigger.label)
|
||||
})
|
||||
});
|
||||
|
||||
if (!confirmed) return;
|
||||
|
||||
const data = this.action.toObject();
|
||||
data.triggers = data.triggers.filter((_, index) => index !== Number.parseInt(button.dataset.index));
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
}
|
||||
|
||||
static async expandTrigger(_event, button) {
|
||||
const index = Number.parseInt(button.dataset.index);
|
||||
const toggle = (element, codeMirror) => {
|
||||
codeMirror.classList.toggle('revealed');
|
||||
const button = element.querySelector('a > i');
|
||||
button.classList.toggle('fa-angle-up');
|
||||
button.classList.toggle('fa-angle-down');
|
||||
};
|
||||
|
||||
const fieldset = button.closest('fieldset');
|
||||
const codeMirror = fieldset.querySelector('.code-mirror-wrapper');
|
||||
toggle(fieldset, codeMirror);
|
||||
|
||||
if (this.openTrigger !== null && this.openTrigger !== index) {
|
||||
const previouslyExpanded = fieldset
|
||||
.closest(`section`)
|
||||
.querySelector(`fieldset[data-index="${this.openTrigger}"]`);
|
||||
const codeMirror = previouslyExpanded.querySelector('.code-mirror-wrapper');
|
||||
toggle(previouslyExpanded, codeMirror);
|
||||
this.openTrigger = index;
|
||||
} else if (this.openTrigger === index) {
|
||||
this.openTrigger = null;
|
||||
} else {
|
||||
this.openTrigger = index;
|
||||
}
|
||||
}
|
||||
|
||||
updateSummonCount(event) {
|
||||
event.stopPropagation();
|
||||
const wrapper = event.target.closest('.summon-count-wrapper');
|
||||
const index = wrapper.dataset.index;
|
||||
const data = this.action.toObject();
|
||||
data.summon[index].count = event.target.value;
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
}
|
||||
|
||||
/** Specific implementation in extending classes **/
|
||||
static async addEffect(_event) {}
|
||||
static removeEffect(_event, _button) {}
|
||||
|
|
@ -233,4 +354,29 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
this.tabGroups.primary = 'base';
|
||||
await super.close(options);
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
const data = foundry.applications.ux.TextEditor.getDragEventData(event);
|
||||
const item = await foundry.utils.fromUuid(data.uuid);
|
||||
if (!(item instanceof game.system.api.documents.DhpActor)) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.summon.invalidDrop'));
|
||||
return;
|
||||
}
|
||||
|
||||
const actionData = this.action.toObject();
|
||||
let countvalue = 1;
|
||||
for (const entry of actionData.summon) {
|
||||
if (entry.actorUUID === data.uuid) {
|
||||
entry.count += 1;
|
||||
countvalue = entry.count;
|
||||
await this.constructor.updateForm.bind(this)(null, null, {
|
||||
object: foundry.utils.flattenObject(actionData)
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
actionData.summon.push({ actorUUID: data.uuid, count: countvalue });
|
||||
await this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(actionData) });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
||||
dropSelector: null
|
||||
}
|
||||
],
|
||||
]
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
|
|
@ -185,7 +185,6 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
super._onDragStart(event);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
advanceResourceDie: CharacterSheet.#advanceResourceDie,
|
||||
cancelBeastform: CharacterSheet.#cancelBeastform,
|
||||
useDowntime: this.useDowntime,
|
||||
viewParty: CharacterSheet.#viewParty,
|
||||
viewParty: CharacterSheet.#viewParty
|
||||
},
|
||||
window: {
|
||||
resizable: true,
|
||||
|
|
@ -338,15 +338,20 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
}
|
||||
const type = 'effect';
|
||||
const cls = game.system.api.models.actions.actionsTypes[type];
|
||||
const action = new cls({
|
||||
...cls.getSourceConfig(doc.system),
|
||||
type: type,
|
||||
chatDisplay: false,
|
||||
cost: [{
|
||||
key: 'stress',
|
||||
value: doc.system.recallCost
|
||||
}]
|
||||
}, { parent: doc.system });
|
||||
const action = new cls(
|
||||
{
|
||||
...cls.getSourceConfig(doc.system),
|
||||
type: type,
|
||||
chatDisplay: false,
|
||||
cost: [
|
||||
{
|
||||
key: 'stress',
|
||||
value: doc.system.recallCost
|
||||
}
|
||||
]
|
||||
},
|
||||
{ parent: doc.system }
|
||||
);
|
||||
const config = await action.use(event);
|
||||
if (config) {
|
||||
return doc.update({ 'system.inVault': false });
|
||||
|
|
@ -707,8 +712,10 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
||||
ability: abilityLabel
|
||||
}),
|
||||
effects: Array.from(await this.document.allApplicableEffects()),
|
||||
roll: {
|
||||
trait: button.dataset.attribute
|
||||
trait: button.dataset.attribute,
|
||||
type: 'trait'
|
||||
},
|
||||
hasRoll: true,
|
||||
actionType: 'action',
|
||||
|
|
@ -718,6 +725,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
})
|
||||
};
|
||||
const result = await this.document.diceRoll(config);
|
||||
if (!result) return;
|
||||
|
||||
/* This could be avoided by baking config.costs into config.resourceUpdates. Didn't feel like messing with it at the time */
|
||||
const costResources = result.costs
|
||||
|
|
@ -822,7 +830,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
static async #toggleVault(_event, button) {
|
||||
const doc = await getDocFromElement(button);
|
||||
const { available } = this.document.system.loadoutSlot;
|
||||
if (doc.system.inVault && !available) {
|
||||
if (doc.system.inVault && !available && !doc.system.loadoutIgnore) {
|
||||
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached'));
|
||||
}
|
||||
|
||||
|
|
@ -900,32 +908,32 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
return;
|
||||
}
|
||||
|
||||
const buttons = parties.map((p) => {
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.classList.add("plain");
|
||||
const img = document.createElement("img");
|
||||
const buttons = parties.map(p => {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.classList.add('plain');
|
||||
const img = document.createElement('img');
|
||||
img.src = p.img;
|
||||
button.append(img);
|
||||
const name = document.createElement("span");
|
||||
const name = document.createElement('span');
|
||||
name.textContent = p.name;
|
||||
button.append(name);
|
||||
button.addEventListener("click", () => {
|
||||
button.addEventListener('click', () => {
|
||||
p.sheet?.render({ force: true });
|
||||
game.tooltip.dismissLockedTooltips();
|
||||
});
|
||||
return button;
|
||||
});
|
||||
|
||||
const html = document.createElement("div");
|
||||
html.classList.add("party-list");
|
||||
const html = document.createElement('div');
|
||||
html.classList.add('party-list');
|
||||
html.append(...buttons);
|
||||
|
||||
|
||||
game.tooltip.dismissLockedTooltips();
|
||||
game.tooltip.activate(target, {
|
||||
html,
|
||||
locked: true,
|
||||
})
|
||||
locked: true
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ export default function DHApplicationMixin(Base) {
|
|||
const step = event.key === 'ArrowUp' ? 1 : event.key === 'ArrowDown' ? -1 : 0;
|
||||
if (step !== 0) {
|
||||
handleUpdate(step);
|
||||
deltaInput.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
deltaInput.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ export default function DHApplicationMixin(Base) {
|
|||
if (deltaInput === document.activeElement) {
|
||||
event.preventDefault();
|
||||
handleUpdate(Math.sign(-1 * event.deltaY));
|
||||
deltaInput.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
deltaInput.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
},
|
||||
{ passive: false }
|
||||
|
|
@ -236,7 +236,7 @@ export default function DHApplicationMixin(Base) {
|
|||
// Handle contenteditable
|
||||
for (const input of htmlElement.querySelectorAll('[contenteditable][data-property]')) {
|
||||
const property = input.dataset.property;
|
||||
input.addEventListener("blur", () => {
|
||||
input.addEventListener('blur', () => {
|
||||
const selection = document.getSelection();
|
||||
if (input.contains(selection.anchorNode)) {
|
||||
selection.empty();
|
||||
|
|
@ -244,12 +244,12 @@ export default function DHApplicationMixin(Base) {
|
|||
this.document.update({ [property]: input.textContent });
|
||||
});
|
||||
|
||||
input.addEventListener("keydown", event => {
|
||||
if (event.key === "Enter") input.blur();
|
||||
input.addEventListener('keydown', event => {
|
||||
if (event.key === 'Enter') input.blur();
|
||||
});
|
||||
|
||||
// Chrome sometimes add <br>, which aren't a problem for the value but are for the placeholder
|
||||
input.addEventListener("input", () => input.querySelectorAll("br").forEach((i) => i.remove()));
|
||||
input.addEventListener('input', () => input.querySelectorAll('br').forEach(i => i.remove()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -585,7 +585,9 @@ export default function DHApplicationMixin(Base) {
|
|||
if (!doc || !descriptionElement) continue;
|
||||
|
||||
// localize the description (idk if it's still necessary)
|
||||
const description = game.i18n.localize(doc.system?.description ?? doc.description);
|
||||
const description = doc.system?.getEnrichedDescription
|
||||
? await doc.system.getEnrichedDescription()
|
||||
: game.i18n.localize(doc.system?.description ?? doc.description);
|
||||
|
||||
// Enrich the description and attach it;
|
||||
const isAction = doc.documentName === 'Action';
|
||||
|
|
@ -736,7 +738,7 @@ export default function DHApplicationMixin(Base) {
|
|||
};
|
||||
if (inVault) data['system.inVault'] = true;
|
||||
if (disabled) data.disabled = true;
|
||||
if (type === "domainCard" && parent?.system.domains?.length) {
|
||||
if (type === 'domainCard' && parent?.system.domains?.length) {
|
||||
data.system.domain = parent.system.domains[0];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,16 +76,10 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
/**@inheritdoc */
|
||||
async _preparePartContext(partId, context, options) {
|
||||
await super._preparePartContext(partId, context, options);
|
||||
const { TextEditor } = foundry.applications.ux;
|
||||
|
||||
switch (partId) {
|
||||
case 'description':
|
||||
const value = foundry.utils.getProperty(this.document, 'system.description') ?? '';
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(value, {
|
||||
relativeTo: this.item,
|
||||
rollData: this.item.getRollData(),
|
||||
secrets: this.item.isOwner
|
||||
});
|
||||
context.enrichedDescription = await this.document.system.getEnrichedDescription();
|
||||
break;
|
||||
case 'effects':
|
||||
await this._prepareEffectsContext(context, 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';
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
async actionUseButton(event, message) {
|
||||
const { moveIndex, actionIndex, movePath } = event.currentTarget.dataset;
|
||||
const targetUuid = event.currentTarget.closest('.action-use-button-parent').querySelector('select')?.value;
|
||||
const parent = await foundry.utils.fromUuid(targetUuid || message.system.actor)
|
||||
const parent = await foundry.utils.fromUuid(targetUuid || message.system.actor);
|
||||
|
||||
const actionType = message.system.moves[moveIndex].actions[actionIndex];
|
||||
const cls = game.system.api.models.actions.actionsTypes[actionType.type];
|
||||
|
|
|
|||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -96,11 +96,11 @@ export default class DHContextMenu extends foundry.applications.ux.ContextMenu {
|
|||
* Trigger a context menu event in response to a normal click on a additional options button.
|
||||
* @param {PointerEvent} event
|
||||
*/
|
||||
static triggerContextMenu(event) {
|
||||
static triggerContextMenu(event, altSelector) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const { clientX, clientY } = event;
|
||||
const selector = '[data-item-uuid]';
|
||||
const selector = altSelector ?? '[data-item-uuid]';
|
||||
const target = event.target.closest(selector) ?? event.currentTarget.closest(selector);
|
||||
target?.dispatchEvent(
|
||||
new PointerEvent('contextmenu', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue