Add setting to prevent the UserConfig from opening on loading Foundry (closes #9)

This commit is contained in:
Eldritch-Oliver 2025-11-22 16:46:45 -07:00
parent c626c981aa
commit 857aca3423
5 changed files with 46 additions and 5 deletions

View file

@ -1,13 +1,17 @@
{ {
"OFT": { "OFT": {
"setting": { "setting": {
"startSidebarExpanded": {
"name": "Start Sidebar Expanded",
"hint": "(v13+) Starts the right-hand sidebar expanded when logging in."
},
"chatSidebarBackground": { "chatSidebarBackground": {
"name": "Chat Background", "name": "Chat Background",
"hint": "(v13+) Adds a background to the chat tab of the right-hand sidebar." "hint": "(v13+) Adds a background to the chat tab of the right-hand sidebar."
},
"preventUserConfigOpen": {
"name": "Prevent Auto User Config",
"hint": "(v13+) Prevents Foundry from opening the User Configuration when a player loads into the world."
},
"startSidebarExpanded": {
"name": "Start Sidebar Expanded",
"hint": "(v13+) Starts the right-hand sidebar expanded when logging in."
} }
} }
} }

View file

@ -1,10 +1,12 @@
import { __ID } from "../consts.mjs"; import { __ID } from "../consts.mjs";
import { chatSidebarBackground } from "../settings/chatSidebarBackground.mjs"; import { chatSidebarBackground } from "../settings/chatSidebarBackground.mjs";
import { preventUserConfigOpen } from "../settings/preventUserConfigOpen.mjs";
import { startSidebarExpanded } from "../settings/startSidebarExpanded.mjs"; import { startSidebarExpanded } from "../settings/startSidebarExpanded.mjs";
Hooks.once(`init`, () => { Hooks.once(`init`, () => {
console.log(`${__ID} | Initializing`); console.log(`${__ID} | Initializing`);
startSidebarExpanded.register();
chatSidebarBackground.register(); chatSidebarBackground.register();
preventUserConfigOpen.register();
startSidebarExpanded.register();
}); });

View file

@ -0,0 +1,12 @@
import { preventUserConfigOpen } from "../settings/preventUserConfigOpen.mjs";
// #region Once
Hooks.once(`renderUserConfig`, (app, element) => {
// MARK: Prevent Unready Open
if (!game.ready && preventUserConfigOpen.value()) {
element.style.display = `none`;
app.close();
};
});
// #endregion Once

View file

@ -2,3 +2,4 @@
import "./hooks/init.mjs"; import "./hooks/init.mjs";
import "./hooks/ready.mjs"; import "./hooks/ready.mjs";
import "./hooks/renderSidebar.mjs"; import "./hooks/renderSidebar.mjs";
import "./hooks/renderUserConfig.mjs";

View file

@ -0,0 +1,22 @@
import { __ID } from "../consts.mjs";
const key = `preventUserConfigOpen`;
const config = {
name: `OFT.setting.${key}.name`,
hint: `OFT.setting.${key}.hint`,
scope: `user`,
type: Boolean,
default: false,
config: true,
requiresReload: false,
};
export const preventUserConfigOpen = {
value() {
return game.settings.get(__ID, key);
},
register() {
game.settings.register(__ID, key, config);
},
};