Add the startSidebarExpanded setting (closes #2)
This commit is contained in:
parent
d856f7b1c8
commit
529aa72bdf
10 changed files with 71 additions and 5 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
|
@ -4,7 +4,7 @@
|
||||||
"foundry": true
|
"foundry": true
|
||||||
},
|
},
|
||||||
"search.exclude": {
|
"search.exclude": {
|
||||||
"foundry": true
|
"foundry": false
|
||||||
},
|
},
|
||||||
"html.customData": [
|
"html.customData": [
|
||||||
"./.vscode/foundry.html-data.json"
|
"./.vscode/foundry.html-data.json"
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export default [
|
||||||
"@stylistic/eol-last": `warn`,
|
"@stylistic/eol-last": `warn`,
|
||||||
"@stylistic/operator-linebreak": [`warn`, `before`],
|
"@stylistic/operator-linebreak": [`warn`, `before`],
|
||||||
"@stylistic/indent": [`warn`, `tab`],
|
"@stylistic/indent": [`warn`, `tab`],
|
||||||
"@stylistic/brace-style": [`warn`, `stroustrup`, { "allowSingleLine": true }],
|
"@stylistic/brace-style": [`off`],
|
||||||
"@stylistic/quotes": [`warn`, `backtick`, { "avoidEscape": true }],
|
"@stylistic/quotes": [`warn`, `backtick`, { "avoidEscape": true }],
|
||||||
"@stylistic/comma-dangle": [`warn`, { arrays: `always-multiline`, objects: `always-multiline`, imports: `always-multiline`, exports: `always-multiline`, functions: `always-multiline` }],
|
"@stylistic/comma-dangle": [`warn`, { arrays: `always-multiline`, objects: `always-multiline`, imports: `always-multiline`, exports: `always-multiline`, functions: `always-multiline` }],
|
||||||
"@stylistic/comma-style": [`warn`, `last`],
|
"@stylistic/comma-style": [`warn`, `last`],
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
{
|
{
|
||||||
"OFT": {}
|
"OFT": {
|
||||||
|
"setting": {
|
||||||
|
"startSidebarExpanded": {
|
||||||
|
"name": "Start Sidebar Expanded",
|
||||||
|
"hint": "(v13+) Starts the right-hand sidebar expanded when logging in."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
export const __ID = `otf`;
|
export const __ID = `oft`;
|
||||||
|
|
||||||
export function inDev() {
|
export function inDev() {
|
||||||
return game.modules.get(__ID).flags.inDev;
|
return game.modules.get(__ID).flags.inDev;
|
||||||
|
|
|
||||||
8
module/hooks/init.mjs
Normal file
8
module/hooks/init.mjs
Normal 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();
|
||||||
|
});
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { __ID } from "../consts.mjs";
|
import { __ID } from "../consts.mjs";
|
||||||
|
|
||||||
Hooks.on(`ready`, () => {
|
Hooks.once(`ready`, () => {
|
||||||
console.log(`${__ID} | Ready`);
|
console.log(`${__ID} | Ready`);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
9
module/hooks/renderSidebar.mjs
Normal file
9
module/hooks/renderSidebar.mjs
Normal 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
// Hooks
|
// Hooks
|
||||||
|
import "./hooks/init.mjs";
|
||||||
import "./hooks/ready.mjs";
|
import "./hooks/ready.mjs";
|
||||||
|
import "./hooks/renderSidebar.mjs";
|
||||||
|
|
|
||||||
22
module/settings/startSidebarExpanded.mjs
Normal file
22
module/settings/startSidebarExpanded.mjs
Normal 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);
|
||||||
|
},
|
||||||
|
};
|
||||||
18
module/utils/isBetweenVersions.mjs
Normal file
18
module/utils/isBetweenVersions.mjs
Normal 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;
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue