From 593105b163afeb1fdce7bf0e2d9212284950dc24 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Wed, 4 Feb 2026 20:08:52 +0100 Subject: [PATCH] Fixed ActiveEffect create dialog options --- lang/en.json | 4 +++- module/documents/activeEffect.mjs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lang/en.json b/lang/en.json index 0186ae3e..c4b611d0 100755 --- a/lang/en.json +++ b/lang/en.json @@ -14,7 +14,9 @@ "beastform": "Beastform" }, "ActiveEffect": { - "beastform": "Beastform" + "base": "Standard", + "beastform": "Beastform", + "horde": "Horde" }, "Actor": { "character": "Character", diff --git a/module/documents/activeEffect.mjs b/module/documents/activeEffect.mjs index c36ed97e..9a326282 100644 --- a/module/documents/activeEffect.mjs +++ b/module/documents/activeEffect.mjs @@ -54,6 +54,37 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect { /* Event Handlers */ /* -------------------------------------------- */ + /** @inheritdoc */ + static async createDialog(data = {}, createOptions = {}, options = {}) { + const { folders, types, template, context = {}, ...dialogOptions } = options; + + if (types?.length === 0) { + throw new Error('The array of sub-types to restrict to must not be empty.'); + } + + const creatableEffects = ['base']; + const documentTypes = this.TYPES.filter(type => creatableEffects.includes(type)).map(type => { + const labelKey = `TYPES.ActiveEffect.${type}`; + const label = game.i18n.has(labelKey) ? game.i18n.localize(labelKey) : type; + + return { value: type, label }; + }); + + if (!documentTypes.length) { + throw new Error('No document types were permitted to be created.'); + } + + const sortedTypes = documentTypes.sort((a, b) => a.label.localeCompare(b.label, game.i18n.lang)); + + return await super.createDialog(data, createOptions, { + folders, + types, + template, + context: { types: sortedTypes, ...context }, + ...dialogOptions + }); + } + /**@inheritdoc*/ async _preCreate(data, options, user) { const update = {};