changed character/party sheet displays to display in cr values
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
Hooks.on("renderActorSheet", (app, html, data) => {
|
||||
replaceSilverWithCredits(html);
|
||||
});
|
||||
|
||||
Hooks.on("updateActor", (actor, data) => {
|
||||
const sheets = actor.apps;
|
||||
sheets.forEach((sheet) => {
|
||||
if (sheet.element) {
|
||||
replaceSilverWithCredits(sheet.element);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function replaceSilverWithCredits(html) {
|
||||
// Update tooltip for silver currency
|
||||
const silverContainers = html.find('[data-unit="sp"]');
|
||||
silverContainers.each(function () {
|
||||
$(this).attr("data-tooltip", "Credits");
|
||||
$(this).find(".currency-image").attr("data-tooltip", "Credits");
|
||||
});
|
||||
|
||||
updateTooltips();
|
||||
}
|
||||
|
||||
function updateTooltips() {
|
||||
const tooltipObserver = new MutationObserver(() => {
|
||||
const allTooltips = document.querySelectorAll(".tooltip, [role='tooltip']");
|
||||
allTooltips.forEach((tooltip) => {
|
||||
if (tooltip.textContent.trim() === "Silver") {
|
||||
tooltip.textContent = "Credits";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
tooltipObserver.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
}
|
||||
|
||||
// Inject CSS rules with high specificity to override the PF2e system CSS
|
||||
const styleSheet = document.createElement("style");
|
||||
styleSheet.id = "sf2e-silver-to-credits-override";
|
||||
styleSheet.textContent = `
|
||||
/* Override silver currency background image globally */
|
||||
[data-unit="sp"] .currency-image {
|
||||
background-image: url('modules/sf2e-silver-to-credits/icons/equipment/treasure/currency/credits.webp') !important;
|
||||
}
|
||||
|
||||
/* Catch it in any context */
|
||||
.currency-image[data-tooltip*="Silver"],
|
||||
[style*="silver-pieces.webp"] {
|
||||
background-image: url('modules/sf2e-silver-to-credits/icons/equipment/treasure/currency/credits.webp') !important;
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(styleSheet);
|
||||
Reference in New Issue
Block a user