Add foundation of the application and templates
This commit is contained in:
parent
a014bb8e6c
commit
60034dcee2
8 changed files with 165 additions and 0 deletions
72
module/apps/SidebarTabRearranger.mjs
Normal file
72
module/apps/SidebarTabRearranger.mjs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import { __ID__, filePath } from "../consts.mjs";
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
const { getDocumentClass } = foundry.utils;
|
||||
|
||||
export class SidebarTabRearranger extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
// #region Options
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: `form`,
|
||||
classes: [
|
||||
__ID__,
|
||||
`SidebarTabRearranger`,
|
||||
],
|
||||
window: {
|
||||
title: `OFT.apps.SidebarTabRearranger.title`,
|
||||
},
|
||||
position: {},
|
||||
form: {
|
||||
handler: this.#onSubmit,
|
||||
closeOnSubmit: true,
|
||||
submitOnChange: false,
|
||||
},
|
||||
actions: {},
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
list: { template: filePath(`templates/SidebarTabRearranger/list.hbs`) },
|
||||
footer: { template: filePath(`templates/SidebarTabRearranger/footer.hbs`) },
|
||||
};
|
||||
// #endregion Options
|
||||
|
||||
// #region Instance Data
|
||||
// #endregion Instance Data
|
||||
|
||||
// #region Lifecycle
|
||||
/** @this {SidebarTabRearranger} */
|
||||
static async #onSubmit() {};
|
||||
// #endregion Lifecycle
|
||||
|
||||
// #region Data Prep
|
||||
async _prepareContext() {
|
||||
const ctx = {
|
||||
meta: {
|
||||
idp: this.id,
|
||||
},
|
||||
};
|
||||
|
||||
const tabs = ui.sidebar.constructor.TABS;
|
||||
ctx.tabs = [];
|
||||
for (const [id, tab] of Object.entries(tabs)) {
|
||||
let { documentName, gmOnly, tooltip, icon } = tab;
|
||||
if (gmOnly && !game.user.isGM) { continue };
|
||||
|
||||
if (documentName) {
|
||||
tooltip ??= getDocumentClass(documentName).metadata.labelPlural;
|
||||
icon ??= CONFIG[documentName]?.sidebarIcon;
|
||||
};
|
||||
|
||||
ctx.tabs.push({
|
||||
id,
|
||||
name: game.i18n.localize(tooltip),
|
||||
icon,
|
||||
});
|
||||
};
|
||||
|
||||
return ctx;
|
||||
};
|
||||
// #endregion Data Prep
|
||||
|
||||
// #region Actions
|
||||
// #endregion Actions
|
||||
};
|
||||
|
|
@ -10,6 +10,7 @@ import { hotbarButtonGap } from "../tweaks/hotbarButtonGap.mjs";
|
|||
import { hotbarButtonSize } from "../tweaks/hotbarButtonSize.mjs";
|
||||
import { preventTokenRotation } from "../tweaks/preventTokenRotation.mjs";
|
||||
import { preventUserConfigOpen } from "../tweaks/preventUserConfigOpen.mjs";
|
||||
import { rearrangeSidebarTabs } from "../tweaks/rearrangeSidebarTabs.mjs";
|
||||
import { repositionHotbar } from "../tweaks/repositionHotbar.mjs";
|
||||
import { startingSidebarTab } from "../tweaks/startingSidebarTab.mjs";
|
||||
import { startSidebarExpanded } from "../tweaks/startSidebarExpanded.mjs";
|
||||
|
|
@ -50,6 +51,7 @@ Hooks.on(`setup`, () => {
|
|||
repositionHotbar();
|
||||
|
||||
customStatusIcons();
|
||||
rearrangeSidebarTabs();
|
||||
chatImageLinks();
|
||||
chatSidebarBackground();
|
||||
startSidebarExpanded();
|
||||
|
|
|
|||
35
module/tweaks/rearrangeSidebarTabs.mjs
Normal file
35
module/tweaks/rearrangeSidebarTabs.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";
|
||||
import { SidebarTabRearranger } from "../apps/SidebarTabRearranger.mjs";
|
||||
|
||||
export const key = `rearrangeSidebarTabs`;
|
||||
|
||||
export function rearrangeSidebarTabs() {
|
||||
status[key] = SettingStatusEnum.Unknown;
|
||||
if (preventTweakRegistration(key)) { return };
|
||||
|
||||
// #region Registration
|
||||
Logger.log(`Registering tweak: ${key}`);
|
||||
game.settings.registerMenu(__ID__, `${key}Menu`, {
|
||||
name: `OFT.menu.${key}.name`,
|
||||
hint: `OFT.menu.${key}.hint`,
|
||||
label: `OFT.menu.${key}.label`,
|
||||
restricted: false,
|
||||
type: SidebarTabRearranger,
|
||||
});
|
||||
game.settings.register(__ID__, key, {
|
||||
scope: `user`,
|
||||
config: false,
|
||||
type: Array,
|
||||
default: [],
|
||||
});
|
||||
// #endregion Registration
|
||||
|
||||
// #region Implementation
|
||||
// TODO: do this
|
||||
// #endregion Implementation
|
||||
|
||||
status[key] = SettingStatusEnum.Registered;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue