feat: Create initial Daggerheart stream overlay module with manifest, scripts, styles, templates, and localization files.
This commit is contained in:
commit
d516de52c0
8 changed files with 1693 additions and 0 deletions
1266
scripts/module.js
Normal file
1266
scripts/module.js
Normal file
File diff suppressed because it is too large
Load diff
100
scripts/settings-app.js
Normal file
100
scripts/settings-app.js
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export class StreamOverlaySettings extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: "stream-overlay-settings",
|
||||
tag: "form",
|
||||
window: {
|
||||
title: "DH_STREAM_OVERLAY.Settings.Title",
|
||||
icon: "fas fa-video",
|
||||
resizable: false,
|
||||
contentClasses: ["standard-form"]
|
||||
},
|
||||
position: {
|
||||
width: 400,
|
||||
height: "auto"
|
||||
},
|
||||
form: {
|
||||
handler: StreamOverlaySettings.#onSubmit,
|
||||
closeOnSubmit: true
|
||||
}
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
template: "modules/dh-stream-overlay/templates/settings-app.hbs"
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const actorUuid = game.settings.get("dh-stream-overlay", "partyActorUuid");
|
||||
let actor = null;
|
||||
if (actorUuid) {
|
||||
actor = await fromUuid(actorUuid);
|
||||
}
|
||||
|
||||
const dsnInstalled = game.modules.get("dice-so-nice")?.active;
|
||||
const dsnEnabled = game.settings.get("dh-stream-overlay", "enableDSN");
|
||||
|
||||
return {
|
||||
actorUuid,
|
||||
actor,
|
||||
dsnInstalled,
|
||||
dsnEnabled
|
||||
};
|
||||
}
|
||||
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options);
|
||||
const html = this.element;
|
||||
const dropZone = html.querySelector(".drop-zone");
|
||||
|
||||
if (dropZone) {
|
||||
dropZone.addEventListener("dragover", this.#onDragOver.bind(this));
|
||||
dropZone.addEventListener("dragleave", this.#onDragLeave.bind(this));
|
||||
dropZone.addEventListener("drop", this.#onDrop.bind(this));
|
||||
}
|
||||
|
||||
const clearBtn = html.querySelector(".clear-actor");
|
||||
if (clearBtn) {
|
||||
clearBtn.addEventListener("click", this.#onClear.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
#onDragOver(event) {
|
||||
event.preventDefault();
|
||||
event.currentTarget.classList.add("drag-over");
|
||||
}
|
||||
|
||||
#onDragLeave(event) {
|
||||
event.preventDefault();
|
||||
event.currentTarget.classList.remove("drag-over");
|
||||
}
|
||||
|
||||
async #onDrop(event) {
|
||||
event.preventDefault();
|
||||
event.currentTarget.classList.remove("drag-over");
|
||||
const data = foundry.applications.ux.TextEditor.getDragEventData(event);
|
||||
|
||||
if (data.type !== "Actor") return;
|
||||
|
||||
const actor = await fromUuid(data.uuid);
|
||||
if (actor) {
|
||||
await game.settings.set("dh-stream-overlay", "partyActorUuid", data.uuid);
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
async #onClear(event) {
|
||||
event.preventDefault();
|
||||
await game.settings.set("dh-stream-overlay", "partyActorUuid", "");
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async #onSubmit(event, form, formData) {
|
||||
// Handle DSN setting
|
||||
if (formData.object.enableDSN !== undefined) {
|
||||
await game.settings.set("dh-stream-overlay", "enableDSN", formData.object.enableDSN);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue