Add the ability to add/remove a chat background (Closes #1)

This commit is contained in:
Eldritch-Oliver 2025-11-22 16:15:02 -07:00
parent 529aa72bdf
commit c626c981aa
7 changed files with 60 additions and 3 deletions

View file

@ -4,6 +4,10 @@
"startSidebarExpanded": { "startSidebarExpanded": {
"name": "Start Sidebar Expanded", "name": "Start Sidebar Expanded",
"hint": "(v13+) Starts the right-hand sidebar expanded when logging in." "hint": "(v13+) Starts the right-hand sidebar expanded when logging in."
},
"chatSidebarBackground": {
"name": "Chat Background",
"hint": "(v13+) Adds a background to the chat tab of the right-hand sidebar."
} }
} }
} }

View file

@ -1,5 +1,5 @@
export const __ID = `oft`; export const __ID = `oft`;
export function inDev() { export function inDev() {
return game.modules.get(__ID).flags.inDev; return game.modules.get(__ID).flags.inDev ?? false;
}; };

View file

@ -1,8 +1,10 @@
import { __ID } from "../consts.mjs"; import { __ID } from "../consts.mjs";
import { chatSidebarBackground } from "../settings/chatSidebarBackground.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(); startSidebarExpanded.register();
chatSidebarBackground.register();
}); });

View file

@ -1,9 +1,15 @@
import { __ID, inDev } from "../consts.mjs";
import { startSidebarExpanded } from "../settings/startSidebarExpanded.mjs"; import { startSidebarExpanded } from "../settings/startSidebarExpanded.mjs";
Hooks.once(`renderSidebar`, (app, _element, _context, _options) => { // #region Once
Hooks.once(`renderSidebar`, (app) => {
// MARK: Sidebar Expansion // MARK: Sidebar Expansion
if (startSidebarExpanded.value()) { if (startSidebarExpanded.value()) {
app.toggleExpanded(true); if (inDev()) {
console.log(`${__ID} | setting:startSidebarExpanded | Expanding Sidebar`);
} }
app.toggleExpanded(true);
};
}); });
// #endregion Once

View file

@ -0,0 +1,35 @@
import { __ID, inDev } from "../consts.mjs";
const key = `chatSidebarBackground`;
const config = {
name: `OFT.setting.${key}.name`,
hint: `OFT.setting.${key}.hint`,
scope: `user`,
type: Boolean,
default: true,
config: true,
requiresReload: false,
onChange: (newValue) => {
if (inDev()) {
console.log(`${__ID} | setting:${key} | Setting to: ${newValue}`);
};
document.body.classList.toggle(`oft-${key}`, newValue);
},
};
export const chatSidebarBackground = {
value() {
return game.settings.get(__ID, key);
},
register() {
game.settings.register(__ID, key, config);
if (this.value()) {
if (inDev()) {
console.log(`${__ID} | setting:${key} | Adding chat background`);
};
document.body.classList.add(`oft-${key}`);
};
},
};

View file

@ -0,0 +1,6 @@
.oft-chatSidebarBackground {
.chat-sidebar:not(.sidebar-popout) {
background: var(--sidebar-background, var(--color-cool-5-90));
pointer-events: all; /* prevent click-throughs */
}
}

View file

@ -0,0 +1,4 @@
@import url("./chatSidebarBackground.css");
/* Make the chat sidebar the same width as all the other tabs */
.chat-sidebar:not(.sidebar-popout) { width: unset; }