Restructure the dev settings so that other categories can be more easily created
This commit is contained in:
parent
f90cb3dbab
commit
d71997a508
5 changed files with 26 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { devSettings } from "../utils/DevSettings.mjs";
|
||||
import { categories } from "../utils/SubMenuSettings.mjs";
|
||||
import { OFTSettingsMenu } from "./OFTSettingsMenu.mjs";
|
||||
|
||||
export class DevSettingsMenu extends OFTSettingsMenu {
|
||||
|
|
@ -9,6 +9,7 @@ export class DevSettingsMenu extends OFTSettingsMenu {
|
|||
};
|
||||
|
||||
static get _SETTINGS() {
|
||||
const devSettings = categories.get(`dev`);
|
||||
const settingIDs = [];
|
||||
for (const [settingID, shown] of devSettings.entries()) {
|
||||
if (shown) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { registerDevSetting } from "../utils/DevSettings.mjs";
|
||||
import { registerDevSetting } from "../utils/SubMenuSettings.mjs";
|
||||
|
||||
const key = `addGlobalDocReferrer`;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { registerDevSetting } from "../utils/DevSettings.mjs";
|
||||
import { registerDevSetting } from "../utils/SubMenuSettings.mjs";
|
||||
|
||||
const key = `autoUnpauseOnLoad`;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
/** @type {Map<string, boolean>} */
|
||||
export const devSettings = new Map();
|
||||
|
||||
export function registerDevSetting(namespace, key, config) {
|
||||
const visible = config.config;
|
||||
config.config = false;
|
||||
game.settings.register(namespace, key, config);
|
||||
devSettings.set(`${namespace}.${key}`, visible);
|
||||
};
|
||||
22
module/utils/SubMenuSettings.mjs
Normal file
22
module/utils/SubMenuSettings.mjs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/** @type {Map<string, Map<string, boolean>>} */
|
||||
export const categories = new Map();
|
||||
|
||||
export function registerCategorySetting(category, namespace, key, config) {
|
||||
let cat = categories.get(category);
|
||||
if (!cat) {
|
||||
cat = new Map();
|
||||
categories.set(category, cat);
|
||||
};
|
||||
const visible = config.config;
|
||||
config.config = false;
|
||||
game.settings.register(namespace, key, config);
|
||||
cat.set(`${namespace}.${key}`, visible);
|
||||
};
|
||||
|
||||
/**
|
||||
* A helper function that registers the setting to the "dev"
|
||||
* category
|
||||
*/
|
||||
export function registerDevSetting(namespace, key, config) {
|
||||
registerCategorySetting(`dev`, namespace, key, config);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue