Add the startSidebarExpanded setting (closes #2)

This commit is contained in:
Eldritch-Oliver 2025-11-22 15:46:30 -07:00
parent d856f7b1c8
commit 529aa72bdf
10 changed files with 71 additions and 5 deletions

View file

@ -1,4 +1,4 @@
export const __ID = `otf`;
export const __ID = `oft`;
export function inDev() {
return game.modules.get(__ID).flags.inDev;

8
module/hooks/init.mjs Normal file
View file

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

View file

@ -1,5 +1,5 @@
import { __ID } from "../consts.mjs";
Hooks.on(`ready`, () => {
Hooks.once(`ready`, () => {
console.log(`${__ID} | Ready`);
});

View file

@ -0,0 +1,9 @@
import { startSidebarExpanded } from "../settings/startSidebarExpanded.mjs";
Hooks.once(`renderSidebar`, (app, _element, _context, _options) => {
// MARK: Sidebar Expansion
if (startSidebarExpanded.value()) {
app.toggleExpanded(true);
}
});

View file

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

View file

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

View file

@ -0,0 +1,18 @@
export function isBetweenVersions(min, target, max) {
if (min) {
const isOlderThanMin = foundry.utils.isNewerVersion(min, target);
if (isOlderThanMin) {
return false;
};
};
if (max) {
const isNewerThanMax = foundry.utils.isNewerVersion(target, max);
if (isNewerThanMax) {
return false;
};
};
return true;
};