add renderer framework for actor dropper.
This commit is contained in:
parent
ce9a9ca16d
commit
2465106010
@ -1,4 +1,25 @@
|
||||
[
|
||||
{
|
||||
"name": "MB - Ground Shadow",
|
||||
"library": "tmfx-main",
|
||||
"params": [
|
||||
{
|
||||
"filterType": "shadow",
|
||||
"filterId": "dropshadow",
|
||||
"rotation": 35,
|
||||
"blur": 2,
|
||||
"quality": 5,
|
||||
"distance": 5,
|
||||
"alpha": 0.7,
|
||||
"padding": 10,
|
||||
"shadowOnly": false,
|
||||
"color": 0,
|
||||
"animated": {},
|
||||
"rank": 10000,
|
||||
"enabled": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MB - Tree Shadow",
|
||||
"library": "tmfx-main",
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
const enrichers = [
|
||||
{
|
||||
id: "mb-actor-drop-enricher",
|
||||
pattern:
|
||||
/@ActorDrop\[(?<uuid>\S+)(?:\s+(?<qty>\d+))?\](?:\{(?<label>[^}]+)\})?/g,
|
||||
enricher: _actorDropper,
|
||||
},
|
||||
];
|
||||
|
||||
function _actorDropper(match, options) {
|
||||
if (!match.groups) return null;
|
||||
const groups = match.groups;
|
||||
const uuid = groups.uuid;
|
||||
const qty = Number(groups.qty) || 1;
|
||||
const label =
|
||||
groups.label || foundry.utils.fromUuidSync(uuid)?.name || "Unknown";
|
||||
const dataset = {
|
||||
uuid,
|
||||
qty,
|
||||
};
|
||||
const anchor = document.createElement("a");
|
||||
anchor.classList.add("mb-assets-actor-drop-link");
|
||||
for (let [k, v] of Object.entries(dataset)) {
|
||||
anchor.dataset[k] = v;
|
||||
}
|
||||
anchor.innerHTML = `<i class="fas fa-user"></i> ${qty} × ${label}`;
|
||||
return anchor;
|
||||
}
|
||||
|
||||
function _onClickActorDropperLink(ev) {
|
||||
console.log(ev);
|
||||
}
|
||||
|
||||
Hooks.once("ready", async () => {
|
||||
for (const enricher of enrichers) {
|
||||
CONFIG.TextEditor.enrichers.push(enricher);
|
||||
}
|
||||
TokenMagic.importPresetLibraryFromPath(
|
||||
"modules/mb-assets/config/tmfx-presets.json",
|
||||
);
|
||||
});
|
||||
|
||||
Hooks.on("renderJournalSheet", (sheet, html, data) => {
|
||||
console.log("journal", sheet, html, data);
|
||||
// links = html.querySelectorAll()
|
||||
// $("a.mb-assets-actor-drop-link", html)
|
||||
// .unbind("click")
|
||||
// .click(_onClickActorDropperLink);
|
||||
});
|
||||
|
||||
Hooks.on("renderJournalPageSheet", (sheet, html, data) => {
|
||||
console.log("journal page", sheet, html, data);
|
||||
// links = html.querySelectorAll()
|
||||
// $("a.mb-assets-actor-drop-link", html)
|
||||
// .unbind("click")
|
||||
// .click(_onClickActorDropperLink);
|
||||
});
|
||||
|
||||
Hooks.on("renderJournalEntryPageSheet", (sheet, html, data) => {
|
||||
console.log("JournalEntryPage", sheet, html, data);
|
||||
// links = html.querySelectorAll()
|
||||
// $("a.mb-assets-actor-drop-link", html)
|
||||
// .unbind("click")
|
||||
// .click(_onClickActorDropperLink);
|
||||
});
|
||||
|
||||
Hooks.on("renderItemSheet", (sheet, html, data) => {
|
||||
console.log("item", sheet, html, data);
|
||||
// links = html.querySelectorAll()
|
||||
// $("a.mb-assets-actor-drop-link", html)
|
||||
// .unbind("click")
|
||||
// .click(_onClickActorDropperLink);
|
||||
});
|
||||
|
||||
Hooks.on("renderJournalPageSheet", (sheet, html, data) => {
|
||||
console.log(sheet, html, data);
|
||||
// links = html.querySelectorAll()
|
||||
// $("a.mb-assets-actor-drop-link", html)
|
||||
// .unbind("click")
|
||||
// .click(_onClickActorDropperLink);
|
||||
});
|
||||
@ -0,0 +1,14 @@
|
||||
a.mb-assets-actor-drop-link {
|
||||
background: #ddd;
|
||||
color: #000;
|
||||
padding: 1px 4px;
|
||||
border: 1px solid #4b4a44;
|
||||
border-radius: 2px;
|
||||
white-space: nowrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
a.mb-assets-actor-drop-link i {
|
||||
color: #003300;
|
||||
margin-right: 2px;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user