Hide empty sub-menus from Foundry's settings app #31

Merged
Oliver merged 1 commit from feature/hide-empty-submenus into main 2025-12-31 07:02:03 +00:00
4 changed files with 16 additions and 2 deletions
Showing only changes of commit 9c19306cc1 - Show all commits

View file

@ -9,6 +9,7 @@ export class DevSettingsMenu extends OFTSettingsMenu {
};
static get _SETTINGS() {
if (!categories.has(`dev`)) { return [] };
const devSettings = categories.get(`dev`);
const settingIDs = [];
for (const [settingID, shown] of devSettings.entries()) {

View file

@ -9,6 +9,7 @@ export class HotbarSettingsMenu extends OFTSettingsMenu {
};
static get _SETTINGS() {
if (!categories.has(`hotbar`)) { return [] };
const settings = categories.get(`hotbar`);
const settingIDs = [];
for (const [settingID, shown] of settings.entries()) {

View file

@ -47,6 +47,10 @@ export class OFTSettingsMenu extends HAM(ApplicationV2) {
};
static _SETTINGS = [];
static get isEmpty() {
return this._SETTINGS.length === 0;
};
// #endregion Options
// #region Data Prep

View file

@ -6,11 +6,19 @@ prevent it from being as attention-grabbing compared to being at the top of the
list.
*/
Hooks.on(`renderSettingsConfig`, (app) => {
// MARK: Hide empty menus
for (const [key, config] of game.settings.menus) {
if (!key.startsWith(__ID__)) { continue };
if (config.type.isEmpty) {
const entry = app.element.querySelector(`.form-group:has(button[data-key="${key}"])`);
entry?.remove();
};
};
// MARK: devSettings Menu
/** @type {Node | undefined} */
const settingList = app.element.querySelector(`.tab[data-group="categories"][data-tab="oft"]`);
// MARK: devSettings Menu
/** @type {Node | undefined} */
const devSettingsMenu = app.element.querySelector(`.form-group:has(button[data-key="${__ID__}.devSettings"])`);
if (settingList && devSettingsMenu) {