Add a user setting to determine if the sidebar tab should be added
This commit is contained in:
parent
12ac7edbc5
commit
9b3751b281
3 changed files with 33 additions and 13 deletions
|
|
@ -14,12 +14,18 @@ import helpers from "../handlebarsHelpers/_index.mjs";
|
||||||
import { Logger } from "../utils/Logger.mjs";
|
import { Logger } from "../utils/Logger.mjs";
|
||||||
import { registerCustomComponents } from "../Apps/elements/_index.mjs";
|
import { registerCustomComponents } from "../Apps/elements/_index.mjs";
|
||||||
import { registerMetaSettings } from "../settings/meta.mjs";
|
import { registerMetaSettings } from "../settings/meta.mjs";
|
||||||
|
import { registerUserSettings } from "../settings/user.mjs";
|
||||||
import { registerWorldSettings } from "../settings/world.mjs";
|
import { registerWorldSettings } from "../settings/world.mjs";
|
||||||
|
|
||||||
Hooks.on(`init`, () => {
|
Hooks.on(`init`, () => {
|
||||||
Logger.debug(`Initializing`);
|
Logger.debug(`Initializing`);
|
||||||
|
|
||||||
|
registerMetaSettings();
|
||||||
|
registerWorldSettings();
|
||||||
|
registerUserSettings();
|
||||||
|
|
||||||
// Add a custom sidebar tab for the module
|
// Add a custom sidebar tab for the module
|
||||||
|
if (game.settings.get(__ID__, `statsSidebarTab`)) {
|
||||||
CONFIG.ui.sidebar.TABS.stats = {
|
CONFIG.ui.sidebar.TABS.stats = {
|
||||||
active: false,
|
active: false,
|
||||||
icon: `fa-solid fa-chart-line`,
|
icon: `fa-solid fa-chart-line`,
|
||||||
|
|
@ -27,13 +33,12 @@ Hooks.on(`init`, () => {
|
||||||
};
|
};
|
||||||
CONFIG.ui.stats = StatSidebar;
|
CONFIG.ui.stats = StatSidebar;
|
||||||
|
|
||||||
// Inject the tab right before settings;
|
// Inject the custom tab right before settings
|
||||||
const temp = CONFIG.ui.sidebar.TABS.settings;
|
const temp = CONFIG.ui.sidebar.TABS.settings;
|
||||||
delete CONFIG.ui.sidebar.TABS.settings;
|
delete CONFIG.ui.sidebar.TABS.settings;
|
||||||
CONFIG.ui.sidebar.TABS.settings = temp;
|
CONFIG.ui.sidebar.TABS.settings = temp;
|
||||||
|
};
|
||||||
|
|
||||||
registerMetaSettings();
|
|
||||||
registerWorldSettings();
|
|
||||||
|
|
||||||
CONFIG.stats = {
|
CONFIG.stats = {
|
||||||
db: UserFlagDatabase,
|
db: UserFlagDatabase,
|
||||||
|
|
|
||||||
11
module/settings/user.mjs
Normal file
11
module/settings/user.mjs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
export function registerUserSettings() {
|
||||||
|
game.settings.register(__ID__, `statsSidebarTab`, {
|
||||||
|
name: `STAT_TRACKER.settings.statsSidebarTab.name`,
|
||||||
|
hint: `STAT_TRACKER.settings.statsSidebarTab.hint`,
|
||||||
|
scope: `user`,
|
||||||
|
type: Boolean,
|
||||||
|
config: true,
|
||||||
|
default: true,
|
||||||
|
requiresReload: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -14,6 +14,10 @@
|
||||||
"globalAPI": {
|
"globalAPI": {
|
||||||
"name": "Global API",
|
"name": "Global API",
|
||||||
"hint": "Whether or not the module provides a global interface for interacting with the module's backend. This is convenient for macros and using the dev console."
|
"hint": "Whether or not the module provides a global interface for interacting with the module's backend. This is convenient for macros and using the dev console."
|
||||||
|
},
|
||||||
|
"statsSidebarTab": {
|
||||||
|
"name": "Stats Sidebar Tab",
|
||||||
|
"hint": "Adds a custom sidebar tab to view and control the module with ease. With the sidebar tab disabled the only way to control the module is via the public API."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue