mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Initial commit
This commit is contained in:
commit
aa4021d1a2
163 changed files with 26530 additions and 0 deletions
73
module/applications/sheets/daggerheart-sheet.mjs
Normal file
73
module/applications/sheets/daggerheart-sheet.mjs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default function DhpApplicationMixin(Base) {
|
||||
return class DhpSheetV2 extends HandlebarsApplicationMixin(Base) {
|
||||
constructor(options={}){
|
||||
super(options);
|
||||
|
||||
this._dragDrop = this._createDragDropHandlers();
|
||||
}
|
||||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
this._dragDrop.forEach(d => d.bind(htmlElement));
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
position: {
|
||||
width: 480,
|
||||
height: "auto"
|
||||
},
|
||||
actions: {
|
||||
onEditImage: this._onEditImage
|
||||
},
|
||||
dragDrop: [],
|
||||
};
|
||||
|
||||
async _prepareContext(_options, objectPath='document') {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.source = this[objectPath].toObject();
|
||||
context.fields = this[objectPath].schema.fields;
|
||||
context.systemFields = this[objectPath].system ? this[objectPath].system.schema.fields : {};
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static _onEditImage(event, target) {
|
||||
const attr = target.dataset.edit;
|
||||
const current = foundry.utils.getProperty(this.document, attr);
|
||||
const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {};
|
||||
const fp = new FilePicker({
|
||||
current,
|
||||
type: "image",
|
||||
redirectToRoot: img ? [img] : [],
|
||||
callback: async path => this._updateImage.bind(this)(path),
|
||||
top: this.position.top + 40,
|
||||
left: this.position.left + 10
|
||||
});
|
||||
return fp.browse();
|
||||
}
|
||||
|
||||
async _updateImage(path){
|
||||
await this.document.update({ "img": path });
|
||||
}
|
||||
|
||||
_createDragDropHandlers() {
|
||||
return this.options.dragDrop.map(d => {
|
||||
// d.permissions = {
|
||||
// dragstart: this._canDragStart.bind(this),
|
||||
// drop: this._canDragDrop.bind(this)
|
||||
// };
|
||||
d.callbacks = {
|
||||
// dragstart: this._onDragStart.bind(this),
|
||||
// dragover: this._onDragOver.bind(this),
|
||||
drop: this._onDrop.bind(this)
|
||||
};
|
||||
return new foundry.applications.ux.DragDrop.implementation(d);
|
||||
});
|
||||
}
|
||||
|
||||
_onDrop(event) {}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue