Move the tweak prevention into a helper function and rename the module hooks w/ compatibility code
This commit is contained in:
parent
3d4376aa81
commit
9c8b6f37f9
20 changed files with 102 additions and 102 deletions
35
module/tweaks/startSidebarExpanded.mjs
Normal file
35
module/tweaks/startSidebarExpanded.mjs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { SettingStatusEnum, status } from "../utils/SettingStatus.mjs";
|
||||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { preventTweakRegistration } from "../utils/preRegisterTweak.mjs";
|
||||
|
||||
const key = `startSidebarExpanded`;
|
||||
|
||||
export function startSidebarExpanded() {
|
||||
status[key] = SettingStatusEnum.Unknown;
|
||||
if (preventTweakRegistration(key)) { return };
|
||||
|
||||
// #region Registration
|
||||
Logger.log(`Registering setting: ${key}`);
|
||||
game.settings.register(__ID__, key, {
|
||||
name: `OFT.setting.${key}.name`,
|
||||
hint: `OFT.setting.${key}.hint`,
|
||||
scope: `user`,
|
||||
type: Boolean,
|
||||
default: true,
|
||||
config: true,
|
||||
requiresReload: false,
|
||||
});
|
||||
// #endregion Registration
|
||||
|
||||
// #region Implementation
|
||||
Hooks.once(`renderSidebar`, (app) => {
|
||||
if (game.settings.get(__ID__, key) && !game.ready) {
|
||||
Logger.debug(`setting:${key} | Expanding sidebar`);
|
||||
app.toggleExpanded(true);
|
||||
};
|
||||
});
|
||||
// #endregion Implementation
|
||||
|
||||
status[key] = SettingStatusEnum.Registered;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue