mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-20 08:37:02 +01:00
Improved the config app for Downtime activities. You can now create/edit/remove actions on them
This commit is contained in:
parent
42a705a870
commit
c3d71f0c39
18 changed files with 275 additions and 196 deletions
|
|
@ -1,148 +0,0 @@
|
||||||
import { actionsTypes } from '../../../data/action/_module.mjs';
|
|
||||||
import DHActionConfig from '../../sheets-configs/action-config.mjs';
|
|
||||||
|
|
||||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
|
||||||
|
|
||||||
export default class DhSettingsActionView extends HandlebarsApplicationMixin(ApplicationV2) {
|
|
||||||
constructor(resolve, reject, title, name, icon, img, description, actions) {
|
|
||||||
super({});
|
|
||||||
|
|
||||||
this.resolve = resolve;
|
|
||||||
this.reject = reject;
|
|
||||||
this.viewTitle = title;
|
|
||||||
this.name = name;
|
|
||||||
this.icon = icon;
|
|
||||||
this.img = img;
|
|
||||||
this.description = description;
|
|
||||||
this.actions = actions;
|
|
||||||
}
|
|
||||||
|
|
||||||
get title() {
|
|
||||||
return this.viewTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
static DEFAULT_OPTIONS = {
|
|
||||||
tag: 'form',
|
|
||||||
classes: ['daggerheart', 'setting', 'dh-style'],
|
|
||||||
position: { width: 440, height: 'auto' },
|
|
||||||
actions: {
|
|
||||||
editImage: this.onEditImage,
|
|
||||||
addItem: this.addItem,
|
|
||||||
editItem: this.editItem,
|
|
||||||
removeItem: this.removeItem,
|
|
||||||
resetMoves: this.resetMoves,
|
|
||||||
saveForm: this.saveForm
|
|
||||||
},
|
|
||||||
form: { handler: this.updateData, submitOnChange: true, closeOnSubmit: false }
|
|
||||||
};
|
|
||||||
|
|
||||||
static PARTS = {
|
|
||||||
header: { template: 'systems/daggerheart/templates/settings/components/action-view-header.hbs' },
|
|
||||||
main: {
|
|
||||||
template: 'systems/daggerheart/templates/settings/components/action-view.hbs'
|
|
||||||
},
|
|
||||||
footer: { template: 'systems/daggerheart/templates/settings/components/action-view-footer.hbs' }
|
|
||||||
};
|
|
||||||
|
|
||||||
async _prepareContext(_options) {
|
|
||||||
const context = await super._prepareContext(_options);
|
|
||||||
context.name = this.name;
|
|
||||||
context.icon = this.icon;
|
|
||||||
context.img = this.img;
|
|
||||||
context.description = this.description;
|
|
||||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.enrichHTML(context.description);
|
|
||||||
context.actions = this.actions;
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
static async updateData(event, element, formData) {
|
|
||||||
const { name, icon, description } = foundry.utils.expandObject(formData.object);
|
|
||||||
this.name = name;
|
|
||||||
this.icon = icon;
|
|
||||||
this.description = description;
|
|
||||||
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
static async saveForm(event) {
|
|
||||||
this.resolve({
|
|
||||||
name: this.name,
|
|
||||||
icon: this.icon,
|
|
||||||
img: this.img,
|
|
||||||
description: this.description,
|
|
||||||
actions: this.actions
|
|
||||||
});
|
|
||||||
this.close(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
static close(fromSave) {
|
|
||||||
if (!fromSave) {
|
|
||||||
this.reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
super.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
static onEditImage() {
|
|
||||||
const fp = new foundry.applications.apps.FilePicker.implementation({
|
|
||||||
current: this.img,
|
|
||||||
type: 'image',
|
|
||||||
callback: async path => {
|
|
||||||
this.img = path;
|
|
||||||
this.render();
|
|
||||||
},
|
|
||||||
top: this.position.top + 40,
|
|
||||||
left: this.position.left + 10
|
|
||||||
});
|
|
||||||
return fp.browse();
|
|
||||||
}
|
|
||||||
|
|
||||||
async selectActionType() {
|
|
||||||
const content = await foundry.applications.handlebars.renderTemplate(
|
|
||||||
'systems/daggerheart/templates/actionTypes/actionType.hbs',
|
|
||||||
{ types: CONFIG.DH.ACTIONS.actionTypes }
|
|
||||||
),
|
|
||||||
title = 'Select Action Type',
|
|
||||||
type = 'form',
|
|
||||||
data = {};
|
|
||||||
return Dialog.prompt({
|
|
||||||
title,
|
|
||||||
label: title,
|
|
||||||
content,
|
|
||||||
type,
|
|
||||||
callback: html => {
|
|
||||||
const form = html[0].querySelector('form'),
|
|
||||||
fd = new foundry.applications.ux.FormDataExtended(form);
|
|
||||||
foundry.utils.mergeObject(data, fd.object, { inplace: true });
|
|
||||||
return data;
|
|
||||||
},
|
|
||||||
rejectClose: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static async addItem() {
|
|
||||||
const actionType = await this.selectActionType();
|
|
||||||
const cls = actionsTypes[actionType?.type] ?? actionsTypes.attack,
|
|
||||||
action = new cls({
|
|
||||||
_id: foundry.utils.randomID(),
|
|
||||||
type: actionType.type,
|
|
||||||
name: game.i18n.localize(CONFIG.DH.ACTIONS.actionTypes[actionType.type].name),
|
|
||||||
...cls.getSourceConfig(this.document)
|
|
||||||
});
|
|
||||||
|
|
||||||
this.actions.push(action);
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
static async editItem(_, button) {
|
|
||||||
await new DHActionConfig(this.actions[button.dataset.id]).render(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
static removeItem(event, button) {
|
|
||||||
this.actions = this.actions.filter((_, index) => index !== Number.parseInt(button.dataset.id));
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
static resetMoves() {}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import { DhHomebrew } from '../../data/settings/_module.mjs';
|
import { DhHomebrew } from '../../data/settings/_module.mjs';
|
||||||
import DhSettingsActionView from './components/settingsActionsView.mjs';
|
|
||||||
|
|
||||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||||
|
|
||||||
export default class DhHomebrewSettings extends HandlebarsApplicationMixin(ApplicationV2) {
|
export default class DhHomebrewSettings extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
|
|
@ -70,23 +68,20 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
|
||||||
|
|
||||||
static async editItem(_, target) {
|
static async editItem(_, target) {
|
||||||
const move = this.settings.restMoves[target.dataset.type].moves[target.dataset.id];
|
const move = this.settings.restMoves[target.dataset.type].moves[target.dataset.id];
|
||||||
new Promise((resolve, reject) => {
|
const editedMove = await game.system.api.applications.sheetConfigs.DowntimeConfig.configure(
|
||||||
new DhSettingsActionView(
|
move,
|
||||||
resolve,
|
target.dataset.id,
|
||||||
reject,
|
this.settings
|
||||||
game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.downtimeMoves'),
|
);
|
||||||
move.name,
|
if (!editedMove) return;
|
||||||
move.icon,
|
|
||||||
move.img,
|
await this.updateAction.bind(this)(editedMove, target.dataset.type, target.dataset.id);
|
||||||
move.description,
|
|
||||||
move.actions
|
|
||||||
).render(true);
|
|
||||||
}).then(data => this.updateAction.bind(this)(data, target.dataset.type, target.dataset.id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateAction(data, type, id) {
|
async updateAction(data, type, id) {
|
||||||
await this.settings.updateSource({
|
await this.settings.updateSource({
|
||||||
[`restMoves.${type}.moves.${id}`]: {
|
[`restMoves.${type}.moves.${id}`]: {
|
||||||
|
actions: data.actions,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
icon: data.icon,
|
icon: data.icon,
|
||||||
img: data.img,
|
img: data.img,
|
||||||
|
|
@ -136,7 +131,11 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
|
||||||
acc[key] = {
|
acc[key] = {
|
||||||
...move,
|
...move,
|
||||||
name: game.i18n.localize(move.name),
|
name: game.i18n.localize(move.name),
|
||||||
description: game.i18n.localize(move.description)
|
description: game.i18n.localize(move.description),
|
||||||
|
actions: move.actions.map(action => ({
|
||||||
|
...action,
|
||||||
|
name: game.i18n.localize(action.name)
|
||||||
|
}))
|
||||||
};
|
};
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
export { default as ActionConfig } from './action-config.mjs';
|
export { default as ActionConfig } from './action-config.mjs';
|
||||||
export { default as AdversarySettings } from './adversary-settings.mjs';
|
export { default as AdversarySettings } from './adversary-settings.mjs';
|
||||||
export { default as CompanionSettings } from './companion-settings.mjs';
|
export { default as CompanionSettings } from './companion-settings.mjs';
|
||||||
|
export { default as DowntimeConfig } from './downtimeConfig.mjs';
|
||||||
export { default as EnvironmentSettings } from './environment-settings.mjs';
|
export { default as EnvironmentSettings } from './environment-settings.mjs';
|
||||||
export { default as ActiveEffectConfig } from './activeEffectConfig.mjs';
|
export { default as ActiveEffectConfig } from './activeEffectConfig.mjs';
|
||||||
export { default as DhTokenConfig } from './token-config.mjs';
|
export { default as DhTokenConfig } from './token-config.mjs';
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@ import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs';
|
||||||
|
|
||||||
const { ApplicationV2 } = foundry.applications.api;
|
const { ApplicationV2 } = foundry.applications.api;
|
||||||
export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
constructor(action) {
|
constructor(action, sheetUpdate) {
|
||||||
super({});
|
super({});
|
||||||
|
|
||||||
this.action = action;
|
this.action = action;
|
||||||
|
this.sheetUpdate = sheetUpdate;
|
||||||
this.openSection = null;
|
this.openSection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,14 +184,34 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
if (!newActions.findSplice(x => x._id === data._id, data)) newActions.push(data);
|
if (!newActions.findSplice(x => x._id === data._id, data)) newActions.push(data);
|
||||||
} else newActions = data;
|
} else newActions = data;
|
||||||
|
|
||||||
const updates = await this.action.parent.parent.update({ [`system.${this.action.systemPath}`]: newActions });
|
const action = await this.updateParent(newActions, container);
|
||||||
if (!updates) return;
|
if (!action) return;
|
||||||
this.action = Array.isArray(container)
|
|
||||||
? foundry.utils.getProperty(updates.system, this.action.systemPath)[this.action.index]
|
this.action = action;
|
||||||
: foundry.utils.getProperty(updates.system, this.action.systemPath);
|
|
||||||
|
this.sheetUpdate?.(this.action);
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateParent(newActions, container) {
|
||||||
|
const isSystemPath = this.action.parent.parent?.update;
|
||||||
|
if (isSystemPath) {
|
||||||
|
const updates = await this.action.parent.parent.update({
|
||||||
|
[`system.${this.action.systemPath}`]: newActions
|
||||||
|
});
|
||||||
|
if (!updates) return null;
|
||||||
|
|
||||||
|
return Array.isArray(container)
|
||||||
|
? foundry.utils.getProperty(updates.system, this.action.systemPath)[this.action.index]
|
||||||
|
: foundry.utils.getProperty(updates.system, this.action.systemPath);
|
||||||
|
} else {
|
||||||
|
await this.action.parent.updateSource({ [this.action.systemPath]: newActions });
|
||||||
|
|
||||||
|
const updates = foundry.utils.getProperty(this.action.parent, this.action.systemPath);
|
||||||
|
return Array.isArray(container) ? updates[this.action.index] : updates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static addElement(event) {
|
static addElement(event) {
|
||||||
const data = this.action.toObject(),
|
const data = this.action.toObject(),
|
||||||
key = event.target.closest('[data-key]').dataset.key;
|
key = event.target.closest('[data-key]').dataset.key;
|
||||||
|
|
|
||||||
167
module/applications/sheets-configs/downtimeConfig.mjs
Normal file
167
module/applications/sheets-configs/downtimeConfig.mjs
Normal file
|
|
@ -0,0 +1,167 @@
|
||||||
|
import { actionsTypes } from '../../data/action/_module.mjs';
|
||||||
|
import DHActionConfig from './action-config.mjs';
|
||||||
|
|
||||||
|
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||||
|
|
||||||
|
export default class DhSettingsActionView extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
|
constructor(move, moveId, settings, options) {
|
||||||
|
super(options);
|
||||||
|
|
||||||
|
this.move = move;
|
||||||
|
|
||||||
|
this.actionsPath = `restMoves.shortRest.moves.${moveId}.actions`;
|
||||||
|
this.settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
get title() {
|
||||||
|
return game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.downtimeMoves');
|
||||||
|
}
|
||||||
|
|
||||||
|
static DEFAULT_OPTIONS = {
|
||||||
|
tag: 'form',
|
||||||
|
classes: ['daggerheart', 'setting', 'dh-style'],
|
||||||
|
position: { width: 440, height: 'auto' },
|
||||||
|
window: {
|
||||||
|
icon: 'fa-solid fa-gears'
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
editImage: this.onEditImage,
|
||||||
|
addItem: this.addItem,
|
||||||
|
editItem: this.editItem,
|
||||||
|
removeItem: this.removeItem,
|
||||||
|
resetMoves: this.resetMoves,
|
||||||
|
saveForm: this.saveForm
|
||||||
|
},
|
||||||
|
form: { handler: this.updateData, submitOnChange: true, closeOnSubmit: false }
|
||||||
|
};
|
||||||
|
|
||||||
|
static PARTS = {
|
||||||
|
header: { template: 'systems/daggerheart/templates/settings/downtime-config/header.hbs' },
|
||||||
|
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||||
|
main: { template: 'systems/daggerheart/templates/settings/downtime-config/main.hbs' },
|
||||||
|
actions: { template: 'systems/daggerheart/templates/settings/downtime-config/actions.hbs' },
|
||||||
|
footer: { template: 'systems/daggerheart/templates/settings/downtime-config/footer.hbs' }
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
|
static TABS = {
|
||||||
|
primary: {
|
||||||
|
tabs: [{ id: 'main' }, { id: 'actions' }],
|
||||||
|
initial: 'main',
|
||||||
|
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
async _prepareContext(_options) {
|
||||||
|
const context = await super._prepareContext(_options);
|
||||||
|
context.move = this.move;
|
||||||
|
context.move.enrichedDescription = await foundry.applications.ux.TextEditor.enrichHTML(
|
||||||
|
context.move.description
|
||||||
|
);
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async updateData(event, element, formData) {
|
||||||
|
const data = foundry.utils.expandObject(formData.object);
|
||||||
|
foundry.utils.mergeObject(this.move, data);
|
||||||
|
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
static async saveForm() {
|
||||||
|
this.close({ submitted: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
static onEditImage() {
|
||||||
|
const fp = new foundry.applications.apps.FilePicker.implementation({
|
||||||
|
current: this.img,
|
||||||
|
type: 'image',
|
||||||
|
callback: async path => {
|
||||||
|
this.move.img = path;
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
|
top: this.position.top + 40,
|
||||||
|
left: this.position.left + 10
|
||||||
|
});
|
||||||
|
return fp.browse();
|
||||||
|
}
|
||||||
|
|
||||||
|
async selectActionType() {
|
||||||
|
const content = await foundry.applications.handlebars.renderTemplate(
|
||||||
|
'systems/daggerheart/templates/actionTypes/actionType.hbs',
|
||||||
|
{ types: CONFIG.DH.ACTIONS.actionTypes }
|
||||||
|
),
|
||||||
|
title = 'Select Action Type',
|
||||||
|
type = 'form',
|
||||||
|
data = {};
|
||||||
|
return Dialog.prompt({
|
||||||
|
title,
|
||||||
|
label: title,
|
||||||
|
content,
|
||||||
|
type,
|
||||||
|
callback: html => {
|
||||||
|
const form = html[0].querySelector('form'),
|
||||||
|
fd = new foundry.applications.ux.FormDataExtended(form);
|
||||||
|
foundry.utils.mergeObject(data, fd.object, { inplace: true });
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
rejectClose: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static async addItem() {
|
||||||
|
const actionType = await this.selectActionType();
|
||||||
|
const cls = actionsTypes[actionType?.type] ?? actionsTypes.attack,
|
||||||
|
action = new cls(
|
||||||
|
{
|
||||||
|
_id: foundry.utils.randomID(),
|
||||||
|
type: actionType.type,
|
||||||
|
name: game.i18n.localize(CONFIG.DH.ACTIONS.actionTypes[actionType.type].name),
|
||||||
|
img: 'icons/magic/life/cross-worn-green.webp',
|
||||||
|
actionType: 'action',
|
||||||
|
systemPath: this.actionsPath
|
||||||
|
},
|
||||||
|
{
|
||||||
|
parent: this.settings
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.move.actions.push(action);
|
||||||
|
await this.settings.updateSource({ [this.actionsPath]: this.move.actions });
|
||||||
|
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
static async editItem(_, target) {
|
||||||
|
const editIndex = Number(target.dataset.id);
|
||||||
|
const action = this.move.actions.find((_, index) => index === editIndex);
|
||||||
|
await new DHActionConfig(action, async updatedMove => {
|
||||||
|
this.move.actions[editIndex] = updatedMove;
|
||||||
|
await this.settings.updateSource({ [this.actionsPath]: this.move.actions });
|
||||||
|
this.render();
|
||||||
|
}).render(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static async removeItem(_, target) {
|
||||||
|
this.move.actions = this.move.actions.filter((_, index) => index !== Number(target.dataset.id));
|
||||||
|
await this.settings.updateSource({ [this.actionsPath]: this.move.actions });
|
||||||
|
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
static resetMoves() {}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
_onClose(options = {}) {
|
||||||
|
if (!options.submitted) this.move = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async configure(move, moveId, settings, options = {}) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const app = new this(move, moveId, settings, options);
|
||||||
|
app.addEventListener('close', () => resolve(app.move), { once: true });
|
||||||
|
app.render({ force: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -140,6 +140,8 @@ export const defaultRestOptions = {
|
||||||
description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.description'),
|
description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.description'),
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
|
_id: foundry.utils.randomID(),
|
||||||
|
systemPath: 'restMoves.shortRest.moves.tendToWounds.actions',
|
||||||
type: 'healing',
|
type: 'healing',
|
||||||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.name'),
|
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.name'),
|
||||||
img: 'icons/magic/life/cross-worn-green.webp',
|
img: 'icons/magic/life/cross-worn-green.webp',
|
||||||
|
|
@ -164,6 +166,8 @@ export const defaultRestOptions = {
|
||||||
description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.description'),
|
description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.description'),
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
|
_id: foundry.utils.randomID(),
|
||||||
|
systemPath: 'restMoves.shortRest.moves.tendToWounds.actions',
|
||||||
type: 'healing',
|
type: 'healing',
|
||||||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.name'),
|
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.name'),
|
||||||
img: 'icons/magic/perception/eye-ringed-green.webp',
|
img: 'icons/magic/perception/eye-ringed-green.webp',
|
||||||
|
|
@ -188,6 +192,8 @@ export const defaultRestOptions = {
|
||||||
description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.description'),
|
description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.description'),
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
|
_id: foundry.utils.randomID(),
|
||||||
|
systemPath: 'restMoves.shortRest.moves.tendToWounds.actions',
|
||||||
type: 'healing',
|
type: 'healing',
|
||||||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.name'),
|
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.name'),
|
||||||
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
|
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
prepareData() {}
|
prepareData() {}
|
||||||
|
|
||||||
get index() {
|
get index() {
|
||||||
return foundry.utils.getProperty(this.parent, this.systemPath).indexOf(this);
|
return foundry.utils.getProperty(this.parent, this.systemPath).findIndex(x => x.id === this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
get id() {
|
get id() {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { defaultRestOptions } from '../../config/generalConfig.mjs';
|
import { defaultRestOptions } from '../../config/generalConfig.mjs';
|
||||||
|
import ActionField from '../fields/actionField.mjs';
|
||||||
|
|
||||||
export default class DhHomebrew extends foundry.abstract.DataModel {
|
export default class DhHomebrew extends foundry.abstract.DataModel {
|
||||||
static LOCALIZATION_PREFIXES = ['DAGGERHEART.SETTINGS.Homebrew']; // Doesn't work for some reason
|
static LOCALIZATION_PREFIXES = ['DAGGERHEART.SETTINGS.Homebrew']; // Doesn't work for some reason
|
||||||
|
|
@ -61,7 +62,7 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
|
||||||
base64: false
|
base64: false
|
||||||
}),
|
}),
|
||||||
description: new fields.HTMLField(),
|
description: new fields.HTMLField(),
|
||||||
actions: new fields.ArrayField(new fields.ObjectField())
|
actions: new fields.ArrayField(new ActionField())
|
||||||
}),
|
}),
|
||||||
{ initial: defaultRestOptions.longRest() }
|
{ initial: defaultRestOptions.longRest() }
|
||||||
)
|
)
|
||||||
|
|
@ -78,7 +79,7 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
|
||||||
base64: false
|
base64: false
|
||||||
}),
|
}),
|
||||||
description: new fields.HTMLField(),
|
description: new fields.HTMLField(),
|
||||||
actions: new fields.ArrayField(new fields.ObjectField())
|
actions: new fields.ArrayField(new ActionField())
|
||||||
}),
|
}),
|
||||||
{ initial: defaultRestOptions.shortRest() }
|
{ initial: defaultRestOptions.shortRest() }
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,15 @@
|
||||||
.sheet.daggerheart.dh-style {
|
.daggerheart.dh-style {
|
||||||
.tab-form-footer {
|
.tab-form-footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 0 10px;
|
gap: 8px;
|
||||||
|
|
||||||
|
&.spaced {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.padded {
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-items {
|
.settings-items {
|
||||||
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
<div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>{{localize "Icon"}}</label>
|
|
||||||
|
|
||||||
<div class="form-field">
|
|
||||||
<input type="text" name="icon" value="{{icon}}" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<fieldset>
|
|
||||||
<legend>{{localize "Description"}}</legend>
|
|
||||||
|
|
||||||
<prose-mirror name="description" value="{{description}}">
|
|
||||||
{{{ enrichedDescription }}}
|
|
||||||
</prose-mirror>
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
|
||||||
15
templates/settings/downtime-config/actions.hbs
Normal file
15
templates/settings/downtime-config/actions.hbs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<section
|
||||||
|
class='tab {{tabs.actions.cssClass}} {{tabs.actions.id}}'
|
||||||
|
data-tab='{{tabs.actions.id}}'
|
||||||
|
data-group='{{tabs.actions.group}}'
|
||||||
|
>
|
||||||
|
<fieldset class="one-column">
|
||||||
|
<legend>{{localize "DAGGERHEART.GENERAL.Action.plural"}} <a><i class="fa-solid fa-plus icon-button" data-action="addItem"></i></a></legend>
|
||||||
|
|
||||||
|
<div class="settings-items">
|
||||||
|
{{#each move.actions as |action index|}}
|
||||||
|
{{> "systems/daggerheart/templates/settings/components/settings-item-line.hbs" id=index }}
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</section>
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<section class='tab-form-footer'>
|
<section class='tab-form-footer spaced'>
|
||||||
|
<button data-action="close">{{localize "Cancel"}}</button>
|
||||||
<button data-action="saveForm"><i class="fa-solid fa-floppy-disk"></i> {{localize "Save"}}</button>
|
<button data-action="saveForm"><i class="fa-solid fa-floppy-disk"></i> {{localize "Save"}}</button>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<header class='settings-item-header'>
|
<header class='settings-item-header'>
|
||||||
<img class='profile' src='{{this.img}}' data-action='editImage' data-edit='img' />
|
<img class='profile' src='{{move.img}}' data-action='editImage' data-edit='img' />
|
||||||
<div class='item-info'>
|
<div class='item-info'>
|
||||||
<h1 class='item-name'><input type='text' name='name' value='{{this.name}}' /></h1>
|
<h1 class='item-name'><input type='text' name='name' value='{{move.name}}' /></h1>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
19
templates/settings/downtime-config/main.hbs
Normal file
19
templates/settings/downtime-config/main.hbs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<section
|
||||||
|
class='tab {{tabs.main.cssClass}} {{tabs.main.id}}'
|
||||||
|
data-tab='{{tabs.main.id}}'
|
||||||
|
data-group='{{tabs.main.group}}'
|
||||||
|
>
|
||||||
|
<fieldset class="one-column">
|
||||||
|
<legend>{{localize "Icon"}}</legend>
|
||||||
|
|
||||||
|
<input type="text" name="icon" value="{{move.icon}}" />
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="one-column">
|
||||||
|
<legend>{{localize "Description"}}</legend>
|
||||||
|
|
||||||
|
<prose-mirror name="description" value="{{move.description}}">
|
||||||
|
{{{ move.enrichedDescription }}}
|
||||||
|
</prose-mirror>
|
||||||
|
</fieldset>
|
||||||
|
</section>
|
||||||
|
|
@ -12,6 +12,6 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="action-category">
|
<fieldset class="action-category">
|
||||||
<legend>{{localize "DAGGERHEART.GENERAL.description"}}</legend>
|
<legend>{{localize "DAGGERHEART.GENERAL.description"}}</legend>
|
||||||
{{formInput fields.description value=source.description name="description" }}
|
{{formInput fields.description value=source.description name="description" enriched=source.description toggled=true }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -4,6 +4,11 @@
|
||||||
data-group='{{tabs.actions.group}}'
|
data-group='{{tabs.actions.group}}'
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<div class="item-tags">
|
||||||
|
<div class="tag">{{localize (concat 'DAGGERHEART.ACTIONS.TYPES.' item.type '.name')}}</div>
|
||||||
|
<div class="tag">{{localize (concat 'DAGGERHEART.CONFIG.ActionType.' item.actionType)}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{> 'daggerheart.inventory-items'
|
{{> 'daggerheart.inventory-items'
|
||||||
title='DAGGERHEART.GENERAL.Action.plural'
|
title='DAGGERHEART.GENERAL.Action.plural'
|
||||||
collection=document.system.actions
|
collection=document.system.actions
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
<section class='tab-form-footer'>
|
<section class='tab-form-footer padded'>
|
||||||
<button type="submit"><i class="fa-solid fa-floppy-disk"></i> {{localize "Save"}}</button>
|
<button type="submit"><i class="fa-solid fa-floppy-disk"></i> {{localize "Save"}}</button>
|
||||||
</section>
|
</section>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue