add settings registration

This commit is contained in:
2025-05-27 23:08:01 -05:00
parent ec4f3e6c63
commit e18419575c
6 changed files with 93 additions and 21 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
import { log, moduleHelpers } from './globals.js';
import { log, moduleHelpers, settingKeys } from './globals.js';
import { requestFearRollFromTokens, requestRollFromTokens } from './helpers.js';
import { powers, powerEffectsMenu } from './powers/powers.js';
import { setSummonCosts } from './powers/summonSupport.js';
+18
View File
@@ -1,5 +1,11 @@
export const moduleName = 'swade-mb-helpers';
export const settingKeys = {
summonablesCompendium: 'summonablesCompendium',
summonablesJournal: 'summonablesJournal',
morphablesCompendium: 'morphablesCompendium',
};
export function log(...args) {
console.log('SWADE MB HELPERS |', ...args);
}
@@ -11,6 +17,18 @@ export class moduleHelpers {
return moduleHelpers._socket;
}
static getSetting(key) {
return game.settings.get(moduleName, key);
}
static async setSetting(key, value) {
return game.settings.get(moduleName, key, value);
}
static async registerSetting(key, metadata) {
return game.settings.register(moduleName, key, metadata);
}
static get rulesVersion() {
if (game.modules.get('swpf-core-rules')?.active) {
return 'swpf';
+30
View File
@@ -25,6 +25,8 @@ const MAINTAIN_ICONS = [
'icons/magic/symbols/triangle-glowing-green.webp',
];
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
function _hashCode(str) {
let hash = 0;
if (str.length === 0) {
@@ -38,6 +40,34 @@ function _hashCode(str) {
return Math.abs(hash);
}
export class PowerFormApplicationV2 extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(powerEffect) {
super();
const name = powerEffect.name.replaceAll(/[^a-zA-Z]/g, '');
this.options.id = `${this.options.id}${name}`;
this.powerEffect = powerEffect;
}
static DEFAULT_OPTIONS = {
id: ['mbSwadePowerEffectsApplicationV2'],
form: {
handler: PowerFormApplicationV2.#onSubmit,
closeOnSubmit: true,
},
tag: 'form',
position: {
width: 400,
height: 'auto',
},
window: {
icon: 'fas fa-gear',
title: 'mbSwade.powerEffectsForm.title',
},
};
static #onSubmit(event, form, formData) {}
}
export class PowerFormApplication extends FormApplication {
constructor(powerEffect) {
super();
+27 -5
View File
@@ -1,7 +1,29 @@
// SPDX-FileCopyrightText: 2022 Johannes Loher
//
// SPDX-License-Identifier: MIT
import { moduleName, moduleHelpers, settingKeys } from './globals.js';
export function registerSettings() {
// Register any custom module settings here
moduleHelpers.registerSetting(settingKeys.summonablesJournal, {
name: 'mbhelpers.settings.summonablesJournalName',
hint: 'mbhelpers.settings.summonablesJournalHint',
scope: 'world',
config: true,
requiresReload: false,
type: String,
});
moduleHelpers.registerSetting(settingKeys.summonablesCompendium, {
name: 'mbhelpers.settings.summonablesCompendiumName',
hint: 'mbhelpers.settings.summonablesCompendiumHint',
scope: 'world',
config: true,
requiresReload: false,
type: String,
});
moduleHelpers.registerSetting(settingKeys.morphablesCompendium, {
name: 'mbhelpers.settings.morphablesCompendiumName',
hint: 'mbhelpers.settings.morphablesCompendiumHint',
scope: 'world',
config: true,
requiresReload: false,
type: String,
});
}