changed character/party sheet displays to display in cr values
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
Hooks.on("renderDialog", (dialog, html, data) => {
|
||||
// Check if this dialog contains currency inputs
|
||||
if (
|
||||
html.find('[name="pp"], [name="gp"], [name="sp"], [name="cp"]').length > 0
|
||||
) {
|
||||
console.log("Add Coins dialog detected, hiding currencies");
|
||||
hideCurrenciesInAddCoinsDialog(html);
|
||||
}
|
||||
});
|
||||
|
||||
// Also hook into the specific PF2e currency dialog
|
||||
Hooks.on("renderCurrencyExchange", (dialog, html, data) => {
|
||||
console.log("CurrencyExchange dialog detected");
|
||||
hideCurrenciesInAddCoinsDialog(html);
|
||||
});
|
||||
|
||||
// Fallback: use a MutationObserver to catch the dialog when it appears
|
||||
const dialogObserver = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.addedNodes.length) {
|
||||
mutation.addedNodes.forEach((node) => {
|
||||
if (node.nodeType === 1) {
|
||||
// Element node
|
||||
const $node = $(node);
|
||||
|
||||
// Check if this node or its children contain currency inputs
|
||||
if (
|
||||
$node.find('[name="pp"], [name="gp"], [name="sp"], [name="cp"]')
|
||||
.length > 0 ||
|
||||
$node.is('[name="pp"], [name="gp"], [name="sp"], [name="cp"]')
|
||||
) {
|
||||
console.log("Currency dialog detected via MutationObserver");
|
||||
hideCurrenciesInAddCoinsDialog($node);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
dialogObserver.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
|
||||
function hideCurrenciesInAddCoinsDialog(html) {
|
||||
console.log("Attempting to hide currencies");
|
||||
|
||||
// Find all form groups
|
||||
const formGroups = html.find(".form-group");
|
||||
console.log("Found form groups:", formGroups.length);
|
||||
|
||||
formGroups.each(function () {
|
||||
const $group = $(this);
|
||||
const input = $group.find("input");
|
||||
const inputName = input.attr("name");
|
||||
const label = $group.find("label").text();
|
||||
|
||||
console.log(
|
||||
"Processing form group with input name:",
|
||||
inputName,
|
||||
"label:",
|
||||
label,
|
||||
);
|
||||
|
||||
// Hide Platinum, Gold, and Copper form groups
|
||||
if (inputName === "pp" || inputName === "gp" || inputName === "cp") {
|
||||
console.log("Hiding:", inputName);
|
||||
$group.css("display", "none");
|
||||
}
|
||||
|
||||
// Rename Silver to Credits
|
||||
if (inputName === "sp") {
|
||||
console.log("Renaming Silver to Credits");
|
||||
$group.find("label").text("Credits");
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user