Implement the buttons spinbuttons for the inventory area
This commit is contained in:
parent
1c737b3dc4
commit
4544516c5c
8 changed files with 131 additions and 71 deletions
|
|
@ -34,11 +34,11 @@ export const icons = [
|
|||
`close.svg`,
|
||||
`edit.svg`,
|
||||
`sheet.svg`,
|
||||
`minus.svg`,
|
||||
];
|
||||
|
||||
|
||||
export async function registerHandlebarsHelpers() {
|
||||
console.log(Handlebars)
|
||||
Handlebars.registerHelper(helpers);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import DOTDUNGEON from "../config.mjs";
|
||||
import { getPath } from "../utils.mjs";
|
||||
|
||||
export class GenericActorSheet extends ActorSheet {
|
||||
_expanded = new Set();
|
||||
|
|
@ -54,6 +55,10 @@ export class GenericActorSheet extends ActorSheet {
|
|||
.on(`click`, this.actor.genericSendToChat.bind(this.actor));
|
||||
html.find(`[data-embedded-edit]`)
|
||||
.on(`click`, this.actor.openEmbeddedSheet.bind(this.actor));
|
||||
html.find(`button[data-increment]`)
|
||||
.on(`click`, this._incrementValue.bind(this));
|
||||
html.find(`button[data-decrement]`)
|
||||
.on(`click`, this._decrementValue.bind(this));
|
||||
};
|
||||
|
||||
async _handleRoll($e) {
|
||||
|
|
@ -73,7 +78,27 @@ export class GenericActorSheet extends ActorSheet {
|
|||
});
|
||||
};
|
||||
|
||||
_handleSummaryToggle($e) {
|
||||
async _incrementValue($e) {
|
||||
const target = $e.currentTarget;
|
||||
const data = target.dataset;
|
||||
const value = getPath(data.increment, this.actor);
|
||||
if (typeof value != "number") {
|
||||
return;
|
||||
};
|
||||
this.actor.update({ [data.increment]: value + 1 });
|
||||
};
|
||||
|
||||
async _decrementValue($e) {
|
||||
const target = $e.currentTarget;
|
||||
const data = target.dataset;
|
||||
const value = getPath(data.decrement, this.actor);
|
||||
if (typeof value != "number") {
|
||||
return;
|
||||
};
|
||||
this.actor.update({ [data.decrement]: value - 1 });
|
||||
};
|
||||
|
||||
async _handleSummaryToggle($e) {
|
||||
let data = $e.currentTarget.dataset;
|
||||
let open = $e.currentTarget.parentNode.open;
|
||||
console.debug(`.dungeon | Collapse ID: ${data.collapseId} (open: ${open})`);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
export function reloadWindows(type = null) {
|
||||
if (!type) {
|
||||
for (const window of globalThis.ui.windows) {
|
||||
window.render(true);
|
||||
};
|
||||
return;
|
||||
};
|
||||
for (const window of globalThis.ui.windows) {
|
||||
if (window instanceof type) {
|
||||
window.render(true);
|
||||
};
|
||||
/**
|
||||
* @param {string} path
|
||||
* @param {object} data
|
||||
* @returns {unknown}
|
||||
*/
|
||||
export function getPath(path, data) {
|
||||
if (!path.includes(`.`)) {
|
||||
return data[path];
|
||||
};
|
||||
let [ key, nextPath ] = path.split(`.`, 2)
|
||||
return getPath(
|
||||
nextPath,
|
||||
data[key]
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue