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
|
|
@ -76,6 +76,11 @@
|
||||||
"name": "Hotbar Settings",
|
"name": "Hotbar Settings",
|
||||||
"hint": "Tweaks that modify Foundry's hotbar",
|
"hint": "Tweaks that modify Foundry's hotbar",
|
||||||
"label": "Configure Hotbar"
|
"label": "Configure Hotbar"
|
||||||
|
},
|
||||||
|
"rearrangeSidebarTabs": {
|
||||||
|
"name": "Rearrange Sidebar Tabs",
|
||||||
|
"hint": "(v13+) Allows you to customize the order the right-hand sidebar tabs appear in. Including module-added sidebar tabs.",
|
||||||
|
"label": "Change Tab Order"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"keybindings": {
|
"keybindings": {
|
||||||
|
|
@ -92,6 +97,9 @@
|
||||||
"no-status-effects": "No status effects detected, this is most likely due to your game system or other modules.",
|
"no-status-effects": "No status effects detected, this is most likely due to your game system or other modules.",
|
||||||
"remove-override": "Remove custom override",
|
"remove-override": "Remove custom override",
|
||||||
"select-using-image-tagger": "Select using Image Tagger"
|
"select-using-image-tagger": "Select using Image Tagger"
|
||||||
|
},
|
||||||
|
"SidebarTabRearranger": {
|
||||||
|
"title": "Rearrange Sidebar Tabs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notifs": {
|
"notifs": {
|
||||||
|
|
|
||||||
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 { hotbarButtonSize } from "../tweaks/hotbarButtonSize.mjs";
|
||||||
import { preventTokenRotation } from "../tweaks/preventTokenRotation.mjs";
|
import { preventTokenRotation } from "../tweaks/preventTokenRotation.mjs";
|
||||||
import { preventUserConfigOpen } from "../tweaks/preventUserConfigOpen.mjs";
|
import { preventUserConfigOpen } from "../tweaks/preventUserConfigOpen.mjs";
|
||||||
|
import { rearrangeSidebarTabs } from "../tweaks/rearrangeSidebarTabs.mjs";
|
||||||
import { repositionHotbar } from "../tweaks/repositionHotbar.mjs";
|
import { repositionHotbar } from "../tweaks/repositionHotbar.mjs";
|
||||||
import { startingSidebarTab } from "../tweaks/startingSidebarTab.mjs";
|
import { startingSidebarTab } from "../tweaks/startingSidebarTab.mjs";
|
||||||
import { startSidebarExpanded } from "../tweaks/startSidebarExpanded.mjs";
|
import { startSidebarExpanded } from "../tweaks/startSidebarExpanded.mjs";
|
||||||
|
|
@ -50,6 +51,7 @@ Hooks.on(`setup`, () => {
|
||||||
repositionHotbar();
|
repositionHotbar();
|
||||||
|
|
||||||
customStatusIcons();
|
customStatusIcons();
|
||||||
|
rearrangeSidebarTabs();
|
||||||
chatImageLinks();
|
chatImageLinks();
|
||||||
chatSidebarBackground();
|
chatSidebarBackground();
|
||||||
startSidebarExpanded();
|
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;
|
||||||
|
};
|
||||||
29
styles/apps/SidebarTabRearranger.css
Normal file
29
styles/apps/SidebarTabRearranger.css
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
.oft.SidebarTabRearranger {
|
||||||
|
ol {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
cursor: var(--cursor-grab);
|
||||||
|
}
|
||||||
|
|
||||||
|
.emulate-button {
|
||||||
|
--size: 32px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: var(--size);
|
||||||
|
aspect-ratio: 1;
|
||||||
|
border: 1px solid var(--color-light-5);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
@import url("./repositionHotbar.css") layer(tweaks);
|
@import url("./repositionHotbar.css") layer(tweaks);
|
||||||
|
|
||||||
@import url("./apps/common.css") layer(apps);
|
@import url("./apps/common.css") layer(apps);
|
||||||
|
@import url("./apps/SidebarTabRearranger.css") layer(apps);
|
||||||
@import url("./apps/StatusEffectIconConfig.css") layer(apps);
|
@import url("./apps/StatusEffectIconConfig.css") layer(apps);
|
||||||
|
|
||||||
/* Make the chat sidebar the same width as all the other tabs */
|
/* Make the chat sidebar the same width as all the other tabs */
|
||||||
|
|
|
||||||
3
templates/SidebarTabRearranger/footer.hbs
Normal file
3
templates/SidebarTabRearranger/footer.hbs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<footer>
|
||||||
|
<button>Submit</button>
|
||||||
|
</footer>
|
||||||
15
templates/SidebarTabRearranger/list.hbs
Normal file
15
templates/SidebarTabRearranger/list.hbs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<main>
|
||||||
|
<ol>
|
||||||
|
{{#each tabs as | tab |}}
|
||||||
|
<li>
|
||||||
|
<span class="emulate-button {{tab.icon}}"></span>
|
||||||
|
<span>{{tab.name}}</span>
|
||||||
|
<div style="flex-grow: 1"></div>
|
||||||
|
<oft-icon
|
||||||
|
name="icons/drag-handle"
|
||||||
|
var:fill="currentColor"
|
||||||
|
></oft-icon>
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
</ol>
|
||||||
|
</main>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue