mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 21:21:08 +01:00
add resource buttons actions methods
This commit is contained in:
parent
1a0c6f46bc
commit
5a874ae268
4 changed files with 79 additions and 13 deletions
|
|
@ -2,8 +2,16 @@ import DHBaseActorSheet from '../api/base-actor.mjs';
|
||||||
import { getDocFromElement } from '../../../helpers/utils.mjs';
|
import { getDocFromElement } from '../../../helpers/utils.mjs';
|
||||||
import { ItemBrowser } from '../../ui/itemBrowser.mjs';
|
import { ItemBrowser } from '../../ui/itemBrowser.mjs';
|
||||||
import FilterMenu from '../../ux/filter-menu.mjs';
|
import FilterMenu from '../../ux/filter-menu.mjs';
|
||||||
|
import DaggerheartMenu from '../../sidebar/tabs/daggerheartMenu.mjs';
|
||||||
|
import { socketEvent } from '../../../systemRegistration/socket.mjs';
|
||||||
|
|
||||||
export default class Party extends DHBaseActorSheet {
|
export default class Party extends DHBaseActorSheet {
|
||||||
|
constructor(options) {
|
||||||
|
super(options);
|
||||||
|
|
||||||
|
this.refreshSelections = DaggerheartMenu.defaultRefreshSelections();
|
||||||
|
}
|
||||||
|
|
||||||
/**@inheritdoc */
|
/**@inheritdoc */
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
classes: ['party'],
|
classes: ['party'],
|
||||||
|
|
@ -19,7 +27,11 @@ export default class Party extends DHBaseActorSheet {
|
||||||
toggleHitPoints: Party.#toggleHitPoints,
|
toggleHitPoints: Party.#toggleHitPoints,
|
||||||
toggleStress: Party.#toggleStress,
|
toggleStress: Party.#toggleStress,
|
||||||
toggleArmorSlot: Party.#toggleArmorSlot,
|
toggleArmorSlot: Party.#toggleArmorSlot,
|
||||||
tempBrowser: Party.#tempBrowser
|
tempBrowser: Party.#tempBrowser,
|
||||||
|
refeshActions: Party.#refeshActions,
|
||||||
|
triggerRest: Party.#triggerRest,
|
||||||
|
selectRefreshable: DaggerheartMenu.selectRefreshable,
|
||||||
|
refreshActors: DaggerheartMenu.refreshActors
|
||||||
},
|
},
|
||||||
dragDrop: [{ dragSelector: '.actors-section .inventory-item', dropSelector: null }]
|
dragDrop: [{ dragSelector: '.actors-section .inventory-item', dropSelector: null }]
|
||||||
};
|
};
|
||||||
|
|
@ -207,6 +219,55 @@ export default class Party extends DHBaseActorSheet {
|
||||||
new ItemBrowser().render({ force: true });
|
new ItemBrowser().render({ force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async #refeshActions() {
|
||||||
|
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||||
|
window: {
|
||||||
|
title: 'New Section',
|
||||||
|
icon: 'fa-solid fa-campground'
|
||||||
|
},
|
||||||
|
content: await foundry.applications.handlebars.renderTemplate(
|
||||||
|
'systems/daggerheart/templates/sidebar/daggerheart-menu/main.hbs',
|
||||||
|
{
|
||||||
|
refreshables: DaggerheartMenu.defaultRefreshSelections()
|
||||||
|
}
|
||||||
|
),
|
||||||
|
classes: ['daggerheart', 'dialog', 'dh-style', 'tab', 'sidebar-tab', 'daggerheartMenu-sidebar']
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirmed) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async #triggerRest(_, button) {
|
||||||
|
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||||
|
window: {
|
||||||
|
title: game.i18n.localize(`DAGGERHEART.APPLICATIONS.Downtime.${button.dataset.type}.title`),
|
||||||
|
icon: button.dataset.type === 'shortRest' ? 'fa-solid fa-utensils' : 'fa-solid fa-bed'
|
||||||
|
},
|
||||||
|
content: 'This will trigger a dialog to players make their downtime moves, are you sure?',
|
||||||
|
classes: ['daggerheart', 'dialog', 'dh-style']
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirmed) return;
|
||||||
|
|
||||||
|
this.document.system.partyMembers.forEach(actor => {
|
||||||
|
game.socket.emit(`system.${CONFIG.DH.id}`, {
|
||||||
|
action: socketEvent.DowntimeTrigger,
|
||||||
|
data: {
|
||||||
|
actorId: actor.uuid,
|
||||||
|
downtimeType: button.dataset.type
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static async downtimeMoveQuery({ actorId, downtimeType }) {
|
||||||
|
const actor = await foundry.utils.fromUuid(actorId);
|
||||||
|
if (!actor || !actor?.isOwner) reject();
|
||||||
|
new game.system.api.applications.dialogs.Downtime(actor, downtimeType === 'shortRest').render({
|
||||||
|
force: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the set of ContextMenu options for Consumable and Loot.
|
* Get the set of ContextMenu options for Consumable and Loot.
|
||||||
* @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} - The Array of context options passed to the ContextMenu instance
|
* @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} - The Array of context options passed to the ContextMenu instance
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
|
|
||||||
this.refreshSelections = DaggerheartMenu.#defaultRefreshSelections();
|
this.refreshSelections = DaggerheartMenu.defaultRefreshSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
static #defaultRefreshSelections() {
|
static defaultRefreshSelections() {
|
||||||
return {
|
return {
|
||||||
session: { selected: false, label: game.i18n.localize('DAGGERHEART.GENERAL.RefreshType.session') },
|
session: { selected: false, label: game.i18n.localize('DAGGERHEART.GENERAL.RefreshType.session') },
|
||||||
scene: { selected: false, label: game.i18n.localize('DAGGERHEART.GENERAL.RefreshType.scene') },
|
scene: { selected: false, label: game.i18n.localize('DAGGERHEART.GENERAL.RefreshType.scene') },
|
||||||
|
|
@ -28,8 +28,8 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
|
||||||
title: 'SIDEBAR.TabSettings'
|
title: 'SIDEBAR.TabSettings'
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
selectRefreshable: DaggerheartMenu.#selectRefreshable,
|
selectRefreshable: DaggerheartMenu.selectRefreshable,
|
||||||
refreshActors: DaggerheartMenu.#refreshActors
|
refreshActors: DaggerheartMenu.refreshActors
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -123,13 +123,13 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
|
||||||
/* Application Clicks Actions */
|
/* Application Clicks Actions */
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
static async #selectRefreshable(_event, button) {
|
static async selectRefreshable(_event, button) {
|
||||||
const { type } = button.dataset;
|
const { type } = button.dataset;
|
||||||
this.refreshSelections[type].selected = !this.refreshSelections[type].selected;
|
this.refreshSelections[type].selected = !this.refreshSelections[type].selected;
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async #refreshActors() {
|
static async refreshActors() {
|
||||||
const refreshKeys = Object.keys(this.refreshSelections).filter(key => this.refreshSelections[key].selected);
|
const refreshKeys = Object.keys(this.refreshSelections).filter(key => this.refreshSelections[key].selected);
|
||||||
await this.getRefreshables(refreshKeys);
|
await this.getRefreshables(refreshKeys);
|
||||||
const types = refreshKeys.map(x => this.refreshSelections[x].label).join(', ');
|
const types = refreshKeys.map(x => this.refreshSelections[x].label).join(', ');
|
||||||
|
|
@ -138,7 +138,7 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
|
||||||
types: `[${types}]`
|
types: `[${types}]`
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
this.refreshSelections = DaggerheartMenu.#defaultRefreshSelections();
|
this.refreshSelections = DaggerheartMenu.defaultRefreshSelections();
|
||||||
|
|
||||||
const cls = getDocumentClass('ChatMessage');
|
const cls = getDocumentClass('ChatMessage');
|
||||||
const msg = {
|
const msg = {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import DamageReductionDialog from '../applications/dialogs/damageReductionDialog.mjs';
|
import DamageReductionDialog from '../applications/dialogs/damageReductionDialog.mjs';
|
||||||
|
import Party from '../applications/sheets/actors/party.mjs';
|
||||||
|
|
||||||
export function handleSocketEvent({ action = null, data = {} } = {}) {
|
export function handleSocketEvent({ action = null, data = {} } = {}) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|
@ -11,13 +12,17 @@ export function handleSocketEvent({ action = null, data = {} } = {}) {
|
||||||
case socketEvent.Refresh:
|
case socketEvent.Refresh:
|
||||||
Hooks.call(socketEvent.Refresh, data);
|
Hooks.call(socketEvent.Refresh, data);
|
||||||
break;
|
break;
|
||||||
|
case socketEvent.DowntimeTrigger:
|
||||||
|
Party.downtimeMoveQuery(data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const socketEvent = {
|
export const socketEvent = {
|
||||||
GMUpdate: 'DhGMUpdate',
|
GMUpdate: 'DhGMUpdate',
|
||||||
Refresh: 'DhRefresh',
|
Refresh: 'DhRefresh',
|
||||||
DhpFearUpdate: 'DhFearUpdate'
|
DhpFearUpdate: 'DhFearUpdate',
|
||||||
|
DowntimeTrigger: 'DowntimeTrigger'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GMUpdateEvent = {
|
export const GMUpdateEvent = {
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,16 @@
|
||||||
data-tab='{{tabs.resources.id}}'
|
data-tab='{{tabs.resources.id}}'
|
||||||
data-group='{{tabs.resources.group}}'
|
data-group='{{tabs.resources.group}}'
|
||||||
>
|
>
|
||||||
<div class="actions-section">
|
<div data-action="triggerRest" data-type="longRest" class="actions-section">
|
||||||
<button>
|
<button data-type="longRest">
|
||||||
<i class="fa-solid fa-bed"></i>
|
<i class="fa-solid fa-bed"></i>
|
||||||
<span>{{localize "DAGGERHEART.APPLICATIONS.Downtime.longRest.title"}}</span>
|
<span>{{localize "DAGGERHEART.APPLICATIONS.Downtime.longRest.title"}}</span>
|
||||||
</button>
|
</button>
|
||||||
<button>
|
<button data-action="triggerRest" data-type="shortRest">
|
||||||
<i class="fa-solid fa-utensils"></i>
|
<i class="fa-solid fa-utensils"></i>
|
||||||
<span>{{localize "DAGGERHEART.APPLICATIONS.Downtime.shortRest.title"}}</span>
|
<span>{{localize "DAGGERHEART.APPLICATIONS.Downtime.shortRest.title"}}</span>
|
||||||
</button>
|
</button>
|
||||||
<button>
|
<button data-action="refeshActions">
|
||||||
<i class="fa-solid fa-campground"></i>
|
<i class="fa-solid fa-campground"></i>
|
||||||
<span>New Section</span>
|
<span>New Section</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue