remove code moved to mb-fvtt-helpers
This commit is contained in:
+2
-7
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"id": "mb-assets",
|
"id": "mb-assets",
|
||||||
"title": "MB assets",
|
"title": "MB assets",
|
||||||
"version": "2.4.0",
|
"version": "3.0.0",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "13",
|
"minimum": "13",
|
||||||
"verified": "13"
|
"verified": "14"
|
||||||
},
|
},
|
||||||
"description": "<p>A collection of useful assets in a convenient package, for personal use only</p>",
|
"description": "<p>A collection of useful assets in a convenient package, for personal use only</p>",
|
||||||
"url": "https://git.bloy.org/foundryvtt/mb-assets",
|
"url": "https://git.bloy.org/foundryvtt/mb-assets",
|
||||||
@@ -81,11 +81,6 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"compatibility": {}
|
"compatibility": {}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "wall-height",
|
|
||||||
"type": "module",
|
|
||||||
"compatibility": {}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "fxmaster",
|
"id": "fxmaster",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -1,170 +1,4 @@
|
|||||||
const enrichers = [
|
|
||||||
{
|
|
||||||
id: "mb-actor-drop-enricher",
|
|
||||||
pattern:
|
|
||||||
/@ActorDrop\[\s*(?<uuid>[\w.-]+)\s*\](?:\(\s*(?<qty>\d+)\s*\))?(?:\{(?<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;
|
|
||||||
if (!label) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const dataset = {
|
|
||||||
uuid,
|
|
||||||
qty,
|
|
||||||
};
|
|
||||||
if (!game.user.isGM) {
|
|
||||||
const span = document.createElement("span");
|
|
||||||
span.innerHTML = "";
|
|
||||||
return span;
|
|
||||||
}
|
|
||||||
const anchor = document.createElement("a");
|
|
||||||
const classes = [
|
|
||||||
"content-link",
|
|
||||||
"mb-assets-link",
|
|
||||||
"mb-assets-actor-drop-link",
|
|
||||||
];
|
|
||||||
for (const cls of classes) {
|
|
||||||
anchor.classList.add(cls);
|
|
||||||
}
|
|
||||||
for (let [k, v] of Object.entries(dataset)) {
|
|
||||||
anchor.dataset[k] = v;
|
|
||||||
}
|
|
||||||
anchor.innerHTML = `<i class="fas fa-crosshairs"></i><i class="fas fa-user"></i> ${qty} × ${label}`;
|
|
||||||
return anchor;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function _spawnTokens(actor, num) {
|
|
||||||
for (let i = 0; i < num; i++) {
|
|
||||||
const label =
|
|
||||||
num > 1
|
|
||||||
? `${actor.prototypeToken.name} #${i + 1}`
|
|
||||||
: actor.prototypeToken.name;
|
|
||||||
const location = await Sequencer.Crosshair.show({
|
|
||||||
distance: actor.prototypeToken.height / 2,
|
|
||||||
texture: actor.prototypeToken.texture.src,
|
|
||||||
snap: {
|
|
||||||
position:
|
|
||||||
CONST.GRID_SNAPPING_MODES.VERTEX | CONST.GRID_SNAPPING_MODES.CENTER,
|
|
||||||
},
|
|
||||||
label: { text: label },
|
|
||||||
});
|
|
||||||
const tokenDoc = await actor.getTokenDocument({
|
|
||||||
x: location.token.x,
|
|
||||||
y: location.token.y,
|
|
||||||
elevation: location.elevation,
|
|
||||||
});
|
|
||||||
game.scenes.viewed.createEmbeddedDocuments("Token", [tokenDoc]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _onClickActorDropperLink(ev) {
|
|
||||||
const targetElement = ev.target;
|
|
||||||
if (!targetElement.closest("a.mb-assets-actor-drop-link")) return;
|
|
||||||
ev.preventDefault();
|
|
||||||
const uuid = targetElement.dataset.uuid;
|
|
||||||
const qty = targetElement.dataset.qty || 1;
|
|
||||||
if (uuid.startsWith("Compendium")) {
|
|
||||||
game.tcal
|
|
||||||
.importTransientActor(uuid, { preferExisting: true })
|
|
||||||
.then((actor) => _spawnTokens(actor, qty));
|
|
||||||
} else {
|
|
||||||
_spawnTokens(foundry.utils.fromUuidSync(uuid), qty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Hooks.on("renderApplicationV1", (application, html, data) => {
|
|
||||||
$(html)
|
|
||||||
.find("a.mb-assets-actor-drop-link")
|
|
||||||
.each((i, el) => $(el).click(_onClickActorDropperLink));
|
|
||||||
});
|
|
||||||
|
|
||||||
Hooks.on("renderApplicationV2", (application, element, context, options) => {
|
|
||||||
element
|
|
||||||
.querySelectorAll("a.mb-assets-actor-drop-link")
|
|
||||||
.forEach((el) => el.addEventListener("click", _onClickActorDropperLink));
|
|
||||||
});
|
|
||||||
|
|
||||||
Hooks.on("renderWallConfig", async (application, element, context, options) => {
|
|
||||||
const doc = application.document;
|
|
||||||
const scope = "mb-assets";
|
|
||||||
const key = "doortile";
|
|
||||||
const defaultValue = [];
|
|
||||||
let value = doc.getFlag(scope, key) ?? defaultValue;
|
|
||||||
if (value === "null" || value === "undefined") {
|
|
||||||
value = [];
|
|
||||||
}
|
|
||||||
const name = `flags.${scope}.${key}`;
|
|
||||||
if (options.parts && !options.parts.includes("body")) return;
|
|
||||||
const dataField = new foundry.data.fields.DocumentUUIDField({
|
|
||||||
type: "Tile",
|
|
||||||
hint: "The tile that should be hidden when the secret door is opened.",
|
|
||||||
nullable: true,
|
|
||||||
required: false,
|
|
||||||
blank: false,
|
|
||||||
initial: null,
|
|
||||||
label: "Door Tile",
|
|
||||||
});
|
|
||||||
const group = dataField.toFormGroup(
|
|
||||||
{ hidden: !context.source.door },
|
|
||||||
{ disabled: !context.source.door, name, value },
|
|
||||||
);
|
|
||||||
const fieldSet = element
|
|
||||||
.querySelector('select[name="door"]')
|
|
||||||
?.closest("fieldset");
|
|
||||||
const form = fieldSet?.closest("form");
|
|
||||||
fieldSet.appendChild(group);
|
|
||||||
application.setPosition();
|
|
||||||
form.addEventListener("change", (event) => {
|
|
||||||
if (event.target.name === "door") {
|
|
||||||
const hidden = event.target.value == 0;
|
|
||||||
const fieldSet = event.target.closest("fieldset");
|
|
||||||
const formInput = fieldSet.querySelector(`[name="${name}"]`);
|
|
||||||
formInput.disabled = hidden;
|
|
||||||
formInput.closest(".form-group").hidden = hidden;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Hooks.on("updateWall", async (doc, changed, options, userId) => {
|
|
||||||
if (!game.user.isActiveGM) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!Object.hasOwn(changed, "ds")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const isOpen = doc.door !== 0 && doc.ds === 1;
|
|
||||||
const scope = "mb-assets";
|
|
||||||
const key = "doortile";
|
|
||||||
const tileUUID = doc.getFlag(scope, key);
|
|
||||||
if (!tileUUID || tileUUID == "null" || tileUUID == "undefined") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const tile = foundry.utils.fromUuidSync(tileUUID);
|
|
||||||
if (!tile || tile.parent.uuid != doc.parent.uuid) {
|
|
||||||
console.log("invalid tile data for door state change", tile, doc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await tile.update({ hidden: isOpen });
|
|
||||||
});
|
|
||||||
|
|
||||||
Hooks.on("renderChatMessageHTML", (message, html, context) => {
|
|
||||||
html
|
|
||||||
.querySelectorAll("a.mb-assets-actor-drop-link")
|
|
||||||
.forEach((el) => el.addEventListener("click", _onClickActorDropperLink));
|
|
||||||
});
|
|
||||||
|
|
||||||
Hooks.once("ready", async () => {
|
Hooks.once("ready", async () => {
|
||||||
for (const enricher of enrichers) {
|
|
||||||
CONFIG.TextEditor.enrichers.push(enricher);
|
|
||||||
}
|
|
||||||
TokenMagic.importPresetLibraryFromPath(
|
TokenMagic.importPresetLibraryFromPath(
|
||||||
"modules/mb-assets/config/tmfx-presets.json",
|
"modules/mb-assets/config/tmfx-presets.json",
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user