Add setting to disable token auto-rotation (closes #12)
This commit is contained in:
parent
2484f6a598
commit
baea567f24
3 changed files with 55 additions and 1 deletions
|
|
@ -21,6 +21,10 @@
|
|||
"name": "Hotbar Button Size",
|
||||
"hint": "(v13+) Changes the size of the hotbar buttons to a size you prefer."
|
||||
},
|
||||
"preventTokenRotation": {
|
||||
"name": "Prevent Token Auto-Rotation",
|
||||
"hint": "(v13+, GM-Only) This prevents tokens from rotating while you are moving them allowing you to more easily use POG-style tokens without them being rotated automatically by Foundry."
|
||||
},
|
||||
"preventUserConfigOpen": {
|
||||
"name": "Prevent Auto User Config",
|
||||
"hint": "(v13+) Prevents Foundry from opening the User Configuration when a player loads into the world."
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { autoUnpauseOnLoad } from "./settings/autoUnpauseOnLoad.mjs";
|
|||
import { chatSidebarBackground } from "./settings/chatSidebarBackground.mjs";
|
||||
import { hotbarButtonGap } from "./settings/hotbarButtonGap.mjs";
|
||||
import { hotbarButtonSize } from "./settings/hotbarButtonSize.mjs";
|
||||
import { preventTokenRotation } from "./settings/preventTokenRotation.mjs";
|
||||
import { preventUserConfigOpen } from "./settings/preventUserConfigOpen.mjs";
|
||||
import { repositionHotbar } from "./settings/repositionHotbar.mjs";
|
||||
import { startingSidebarTab } from "./settings/startingSidebarTab.mjs";
|
||||
|
|
@ -14,10 +15,10 @@ import { startSidebarExpanded } from "./settings/startSidebarExpanded.mjs";
|
|||
|
||||
// Apps
|
||||
import { DevSettingsMenu } from "./apps/DevSettingsMenu.mjs";
|
||||
import { HotbarSettingsMenu } from "./apps/HotbarSettingsMenu.mjs";
|
||||
|
||||
// Misc
|
||||
import { __ID__ } from "./consts.mjs";
|
||||
import { HotbarSettingsMenu } from "./apps/HotbarSettingsMenu.mjs";
|
||||
|
||||
Hooks.on(`setup`, () => {
|
||||
|
||||
|
|
@ -45,5 +46,6 @@ Hooks.on(`setup`, () => {
|
|||
chatSidebarBackground();
|
||||
startSidebarExpanded();
|
||||
startingSidebarTab();
|
||||
preventTokenRotation();
|
||||
preventUserConfigOpen();
|
||||
});
|
||||
|
|
|
|||
48
module/settings/preventTokenRotation.mjs
Normal file
48
module/settings/preventTokenRotation.mjs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
|
||||
const key = `preventTokenRotation`;
|
||||
|
||||
export function preventTokenRotation() {
|
||||
|
||||
const prevented = Hooks.call(`${__ID__}.preventSetting`, key);
|
||||
if (!prevented) {
|
||||
Logger.log(`Preventing setting "${key}" from being registered`);
|
||||
return;
|
||||
};
|
||||
|
||||
/** @type {number|null} */
|
||||
let hookID = null;
|
||||
|
||||
// #region Registration
|
||||
Logger.log(`Registering setting: ${key}`);
|
||||
game.settings.register(__ID__, key, {
|
||||
name: `OFT.setting.${key}.name`,
|
||||
hint: `OFT.setting.${key}.hint`,
|
||||
scope: `world`,
|
||||
type: Boolean,
|
||||
default: true,
|
||||
config: true,
|
||||
requiresReload: false,
|
||||
onChange: (newValue) => {
|
||||
if (newValue) {
|
||||
hookID = Hooks.on(`preMoveToken`, preMoveTokenHandler);
|
||||
} else if (hookID != null) {
|
||||
Hooks.off(`preMoveToken`, hookID);
|
||||
};
|
||||
},
|
||||
});
|
||||
// #endregion Registration
|
||||
|
||||
// #region Implementation
|
||||
if (game.settings.get(__ID__, key)) {
|
||||
hookID = Hooks.on(`preMoveToken`, preMoveTokenHandler);
|
||||
};
|
||||
// #endregion Implementation
|
||||
};
|
||||
|
||||
// #region Helpers
|
||||
function preMoveTokenHandler(_token, update) {
|
||||
update.autoRotate = false;
|
||||
};
|
||||
// #endregion Helpers
|
||||
Loading…
Add table
Add a link
Reference in a new issue