added aura tab

This commit is contained in:
grimsace
2026-05-07 14:11:48 -05:00
parent 0c97023f59
commit 461fa28d94
4 changed files with 124 additions and 5 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
# Basic Aura Highlighting # Basic Aura Highlighting
A small, FoundryVTT system agnostic module that places a highlight around tokens in another token's aura. A small, FoundryVTT Pathfinder 2e/Starfinder 2e module that places a highlight around tokens in another token's aura.
+21
View File
@@ -0,0 +1,21 @@
{
"BASIC_AURA_HIGHLIGHTING": {
"tabs": {
"aura": "Aura",
"auraHint": "Aura controls will be added here."
},
"settings": {
"enabled": {
"name": "Enable Aura Highlight",
"hint": "Whether this token should highlight others within its aura."
},
"radius": {
"name": "Aura Radius",
"hint": "The radius of the aura in grid units."
},
"color": {
"name": "Highlight Color"
}
}
}
}
+22 -3
View File
@@ -1,5 +1,5 @@
{ {
"id": "basicaurahighlighting", "id": "basic_aura_highlighting",
"title": "Basic Aura Highlighting", "title": "Basic Aura Highlighting",
"version": "0.1.0", "version": "0.1.0",
"compatibility": { "compatibility": {
@@ -7,9 +7,28 @@
"verified": "13", "verified": "13",
"maximum": "14" "maximum": "14"
}, },
"description": "<p>A small, system agnostic module that places a highlight around tokens in another token's aura. This aura can be measured from the center of the tokens or edge to edge. See the token or prototype token menus for configuration. This module also includes integration with pathfidner 2e, to make the auras toggleable in the actions tab of a character sheet.</p>", "description": "<p>A module specifically for Pathfinder 2e that places a highlight around tokens in another token's aura. This aura can be measured from the center of the tokens or edge to edge. See the token or prototype token menus for configuration.</p>",
"relationships": {
"systems": [
{
"id": "pf2e",
"manifest": "https://github.com/foundryvtt/pf2e/releases/latest/download/system.json",
"compatibility": {
"minimum": "6.0.0"
}
}
]
},
"flags": { "flags": {
"canUpload": true "canUpload": true
}, },
"url": "https://codeberg.org/Grimsace/basic_aura_highlighting" "url": "https://codeberg.org/Grimsace/basic_aura_highlighting",
"esmodules": ["scripts/module.js"],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
}
]
} }
+79
View File
@@ -0,0 +1,79 @@
const MODULE_ID = "basic_aura_highlighting";
const AURA_TAB = "basic-aura-highlighting-aura";
Hooks.on("renderTokenConfig", injectAuraTab);
Hooks.on("renderPrototypeTokenConfig", injectAuraTab);
function injectAuraTab(app, element) {
const root = getRootElement(element);
if (!root || root.querySelector(`[data-tab="${AURA_TAB}"]`)) return;
const tabsNav = findTabsNav(root);
const existingTab = findExistingTab(root, tabsNav);
if (!tabsNav || !existingTab) {
console.warn(`${MODULE_ID} | Could not find token config tabs to add Aura tab.`);
return;
}
const group = tabsNav.dataset.group || existingTab.dataset.group || "sheet";
const auraTabButton = createAuraTabButton(group);
tabsNav.append(auraTabButton);
const auraPanel = createAuraTabPanel(group);
existingTab.after(auraPanel);
auraTabButton.addEventListener("click", (event) => {
event.preventDefault();
event.stopPropagation();
activateAuraTab(root, group);
});
}
function getRootElement(element) {
if (element instanceof HTMLElement) return element;
if (element?.[0] instanceof HTMLElement) return element[0];
return null;
}
function findTabsNav(root) {
return root.querySelector(`nav.tabs[data-group], .tabs[data-group], nav.tabs, .tabs`);
}
function findExistingTab(root, tabsNav) {
const group = tabsNav?.dataset.group;
const selector = group ? `.tab[data-group="${group}"][data-tab]` : `.tab[data-tab]`;
return root.querySelector(selector) || root.querySelector(`.tab[data-tab]`);
}
function createAuraTabButton(group) {
const button = document.createElement("a");
button.classList.add("item");
button.dataset.tab = AURA_TAB;
button.dataset.group = group;
button.dataset.action = "tab";
button.innerHTML = `<i class="fa-solid fa-bullseye"></i> ${game.i18n.localize("BASIC_AURA_HIGHLIGHTING.tabs.aura")}`;
return button;
}
function createAuraTabPanel(group) {
const panel = document.createElement("section");
panel.classList.add("tab");
panel.dataset.tab = AURA_TAB;
panel.dataset.group = group;
panel.innerHTML = `
<div class="form-group">
<p class="hint">${game.i18n.localize("BASIC_AURA_HIGHLIGHTING.tabs.auraHint")}</p>
</div>
`;
return panel;
}
function activateAuraTab(root, group) {
for (const tab of root.querySelectorAll(`.tab[data-group="${group}"], .tab[data-tab]`)) {
tab.classList.toggle("active", tab.dataset.tab === AURA_TAB);
}
for (const item of root.querySelectorAll(`[data-group="${group}"][data-tab], .tabs [data-tab]`)) {
item.classList.toggle("active", item.dataset.tab === AURA_TAB);
}
}