Closed geoidesic closed 1 month ago
Specifically I want a custom type to register a component via game.settings.register e.g. a multi-select or checkbox list.
E.g. I currently have this:
game.settings.registerMenu(MODULE_ID, SettingKeys.SOURCES, {
name: 'compendiums'),
label: 'Compendiums'),
icon: 'fas fa-atlas',
type: CompendiumSourcesSubmenu,
restricted: true,
});
But I would like that CompendiumSourcesSubmenu to be a svelte component, rather than the TypeScript / Handlebars extension to FormApplication that it currently is (as it has been ported from an existing module) TyphonJS (Michael) — 05/31/2024 2:20 PM It's highly recommended to use the "dummy FormApplication" route to register an app / menu setting.
You create a fake FormApplication and launch a normal SvelteApplication instead from this fake FormApplication. You can also make this fake FormApplication be a static way to launch the settings config from elsewhere.
You can see this in the unreleased mce-everywhere package:
The fake FormApplication: https://github.com/typhonjs-fvtt/mce-everywhere/blob/main/src/view/ConfigSettingButton.js https://github.com/FaeyUmbrea/obs-utils/blob/main/src/applications/settingsShell.js https://github.com/typhonjs-fvtt/mce-everywhere/tree/main/src/view https://github.com/typhonjs-fvtt/mce-everywhere/blob/main/src/model/mceGameSettings.js#L49-L62 https://github.com/typhonjs-fvtt/mce-everywhere/blob/main/src/view/ConfigSettingButton.js
However, a better solution that likely is available on a recent v11 / v12? install is if a function can be directly registered. The fake FormApplication approach is how you do it before a version of Foundry that can accept a function for the settings menu registration. I haven't followed up when / if function registration may have been implemented in core. I know it was put in as a feature request 1-2 years ago, so might be the best way to do things now.
Morning all. Does v11 or v12 core support registering a function for the settings menu registration? (I believe it was put in as a feature request 1-2 years ago). esheyw — Today at 10:44 AM
register(namespace, key, data) {
//...
// Validate type
if ( data.type ) {
const allowedTypes = [foundry.data.fields.DataField, foundry.abstract.DataModel, Function];
if ( !allowedTypes.some(t => data.type instanceof t) ) {
throw new Error(`Setting ${key} type must be a DataField, DataModel, or callable function`);
}
from v12's client/core/settings.js the built-in type functions are functions and weren't whitelisted in v11 or anything, so it should take an arbitrary function just as well
Folder assignment for permissions gets complicated:
So to make this happen we have to first extract the folder ids from the pack and then compare the item's folder id with those
This is complicated and it obfuscates the meaning of the code, for those who don't know what Donation Tracker is. I'm starting tothink it's a bad idea to integrate it directly into Actor Studio.
I think what would be better is to make Actor Studio expect plugins by calling custom hooks at integration points. The first step is to identify all those points:
Then we publish Actor Studio Donation Tracker Integration as a separate module. This is better because it makes it more likely that other contributors can contribute to Actor Studio and understand its code.
We build it as a built-in plugin.
loadPlugins()
call
donation-tracker
module. If enabled, add game setting with button to open new applicationgame.membership.RANKS
and create a text field setting per RANK