mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 13:41:07 +01:00
Stuff
This commit is contained in:
parent
078334096c
commit
b80d42c815
6 changed files with 110 additions and 0 deletions
|
|
@ -165,6 +165,8 @@ Hooks.on('ready', async () => {
|
||||||
if(!(ui.compendiumBrowser instanceof applications.ui.ItemBrowser))
|
if(!(ui.compendiumBrowser instanceof applications.ui.ItemBrowser))
|
||||||
ui.compendiumBrowser = new applications.ui.ItemBrowser();
|
ui.compendiumBrowser = new applications.ui.ItemBrowser();
|
||||||
|
|
||||||
|
ui.presetTemplates = new applications.ui.PresetTemplates();
|
||||||
|
|
||||||
registerCountdownHooks();
|
registerCountdownHooks();
|
||||||
socketRegistration.registerSocketHooks();
|
socketRegistration.registerSocketHooks();
|
||||||
registerRollDiceHooks();
|
registerRollDiceHooks();
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,6 @@ export { default as DhChatLog } from './chatLog.mjs';
|
||||||
export { default as DhCombatTracker } from './combatTracker.mjs';
|
export { default as DhCombatTracker } from './combatTracker.mjs';
|
||||||
export * as DhCountdowns from './countdowns.mjs';
|
export * as DhCountdowns from './countdowns.mjs';
|
||||||
export { default as DhFearTracker } from './fearTracker.mjs';
|
export { default as DhFearTracker } from './fearTracker.mjs';
|
||||||
|
export { default as PresetTemplates } from './presetTemplates.mjs';
|
||||||
export { default as DhHotbar } from './hotbar.mjs';
|
export { default as DhHotbar } from './hotbar.mjs';
|
||||||
export { ItemBrowser } from './itemBrowser.mjs';
|
export { ItemBrowser } from './itemBrowser.mjs';
|
||||||
|
|
|
||||||
72
module/applications/ui/presetTemplates.mjs
Normal file
72
module/applications/ui/presetTemplates.mjs
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @extends ApplicationV2
|
||||||
|
* @mixes HandlebarsApplication
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default class PresetTemplates extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
|
constructor(options = {}) {
|
||||||
|
super(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
static DEFAULT_OPTIONS = {
|
||||||
|
id: 'presetTemplates',
|
||||||
|
classes: [],
|
||||||
|
tag: 'div',
|
||||||
|
window: {
|
||||||
|
frame: true,
|
||||||
|
title: 'Preset Templates',
|
||||||
|
positioned: true,
|
||||||
|
resizable: true,
|
||||||
|
minimizable: true
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
width: 222,
|
||||||
|
height: 222
|
||||||
|
// top: "200px",
|
||||||
|
// left: "120px"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
static PARTS = {
|
||||||
|
resources: {
|
||||||
|
root: true,
|
||||||
|
template: 'systems/daggerheart/templates/ui/presetTemplates.hbs'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
/* Rendering */
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
async _prepareContext(_options) {
|
||||||
|
// Return the data for rendering
|
||||||
|
return { };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
async _preFirstRender(context, options) {
|
||||||
|
options.position =
|
||||||
|
game.user.getFlag(CONFIG.DH.id, 'app.presetTemplates.position') ?? PresetTemplates.DEFAULT_OPTIONS.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
async _preRender(context, options) {
|
||||||
|
}
|
||||||
|
|
||||||
|
_onPosition(position) {
|
||||||
|
game.user.setFlag(CONFIG.DH.id, 'app.presetTemplates.position', position);
|
||||||
|
}
|
||||||
|
|
||||||
|
async close(options = {}) {
|
||||||
|
if (!options.allowed) return;
|
||||||
|
else super.close(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -92,6 +92,25 @@ export default class DhTemplateLayer extends foundry.canvas.layers.TemplateLayer
|
||||||
|
|
||||||
static handlePreset(event, active) {
|
static handlePreset(event, active) {
|
||||||
console.log("Preset handling goes here, event, active is: ", event, active);
|
console.log("Preset handling goes here, event, active is: ", event, active);
|
||||||
|
if (active) {
|
||||||
|
ui.presetTemplates.open();
|
||||||
|
// if (CONFIG.ux.TemplateManager.getActivePreview()) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// const { width, height } = game.canvas.scene.dimensions;
|
||||||
|
// const data = {
|
||||||
|
// x: width / 2,
|
||||||
|
// y: height / 2,
|
||||||
|
// t: 'circle',
|
||||||
|
// distance: 30,
|
||||||
|
// fillColor: '#FF0000'
|
||||||
|
// };
|
||||||
|
|
||||||
|
// CONFIG.ux.TemplateManager.createPreview(data);
|
||||||
|
} else {
|
||||||
|
ui.presetTemplates.close();
|
||||||
|
// CONFIG.ux.TemplateManager.cancelActivePreview(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDragLeftStart(event) {
|
_onDragLeftStart(event) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@
|
||||||
export default class DhTemplateManager {
|
export default class DhTemplateManager {
|
||||||
#activePreview;
|
#activePreview;
|
||||||
|
|
||||||
|
|
||||||
|
getActivePreview() {
|
||||||
|
return this.#activePreview;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a template preview, deactivating any existing ones.
|
* Create a template preview, deactivating any existing ones.
|
||||||
* @param {object} data
|
* @param {object} data
|
||||||
|
|
@ -29,6 +34,7 @@ export default class DhTemplateManager {
|
||||||
|
|
||||||
canvas.app.view.addEventListener('wheel', this.#activePreview.events.wheel, true);
|
canvas.app.view.addEventListener('wheel', this.#activePreview.events.wheel, true);
|
||||||
canvas.app.view.addEventListener('contextmenu', this.#activePreview.events.contextmenu);
|
canvas.app.view.addEventListener('contextmenu', this.#activePreview.events.contextmenu);
|
||||||
|
return this.#activePreview;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -102,4 +108,11 @@ export default class DhTemplateManager {
|
||||||
canvas.scene.createEmbeddedDocuments('MeasuredTemplate', [this.#activePreview.document.toObject()]);
|
canvas.scene.createEmbeddedDocuments('MeasuredTemplate', [this.#activePreview.document.toObject()]);
|
||||||
this.#activePreview = undefined;
|
this.#activePreview = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cancelActivePreview(event) {
|
||||||
|
if (this.#activePreview) {
|
||||||
|
this.#cancelTemplate(event);
|
||||||
|
this.#activePreview = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
templates/ui/presetTemplates.hbs
Normal file
3
templates/ui/presetTemplates.hbs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div>
|
||||||
|
Preset Template stuff.
|
||||||
|
</div>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue