All user data for FoundryVTT. Includes worlds, systems, modules, and any asset in the "foundryuserdata" directory. Does NOT include the FoundryVTT installation itself.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.6 KiB

  1. Hooks.on("renderNPCSheetPF2e", (app, html, data) => {
  2. const acDetails = app.object.attributes.ac.details;
  3. const collapseAc = acDetails === "";
  4. const hpDetails = app.object.attributes.hp.details;
  5. const hpTemp = app.object.attributes.hp.temp;
  6. const collapseHp = hpDetails === "" && hpTemp === 0;
  7. const collapseInitiative = app.object.attributes.initiative.ability === "perception";
  8. const collapseToggles = app.object.system.toggles?.length === 0;
  9. const collapseSaves = app.object.system.attributes.allSaves.value === "";
  10. const immunities = app.object.system.attributes.immunities;
  11. const collapseImmunities = immunities.length === 0 && (immunities.custom === undefined || immunities.custom === "");
  12. const weaknesses = app.object.system.attributes.weaknesses;
  13. const collapseWeaknesses = weaknesses.length === 0;
  14. const resistances = app.object.system.attributes.resistances;
  15. const collapseResistances = resistances.length === 0;
  16. html.find("select").addClass("dorako-ui-skip");
  17. html.find("input").addClass("dorako-ui-skip");
  18. if (collapseAc) {
  19. let section = html.find(".armor-section")[0];
  20. section.classList.add("collapsed");
  21. }
  22. if (collapseHp) {
  23. let section = html.find(".health-section")[0];
  24. section.classList.add("collapsed");
  25. }
  26. if (collapseInitiative) {
  27. let section = html.find(".initiative")[0];
  28. section.classList.add("collapsed");
  29. }
  30. if (collapseToggles) {
  31. let section = html.find(".toggles")[0];
  32. section.classList.add("dorako-display-none");
  33. }
  34. if (collapseImmunities) {
  35. let section = html.find(".immunities")[0];
  36. section.classList.add("collapsed", "empty");
  37. }
  38. if (collapseWeaknesses) {
  39. let section = html.find(".weaknesses")[0];
  40. section.classList.add("collapsed", "empty");
  41. }
  42. if (collapseResistances) {
  43. let section = html.find(".resistances")[0];
  44. section.classList.add("collapsed", "empty");
  45. }
  46. let saves = html.find(".saves")[0];
  47. let saveDetails = html.find(".save-details")[0];
  48. saveDetails.classList.remove("side-bar-section");
  49. let initiative = html.find(".initiative")[0];
  50. let newSaves = document.createElement("div");
  51. newSaves.classList.add("saves-section", "side-bar-section");
  52. newSaves.appendChild(saves);
  53. newSaves.appendChild(saveDetails);
  54. initiative.parentNode.insertBefore(newSaves, initiative.nextSibling);
  55. if (collapseSaves) {
  56. let section = html.find(".saves-section")[0];
  57. section.classList.add("collapsed");
  58. }
  59. });
  60. Hooks.on("renderNPCSheetPF2e", (app, html, data) => {
  61. if (html[0].tagName === "FORM") return;
  62. html[0].classList.add("dorako-ux");
  63. });