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.

87 lines
2.5 KiB

1 year ago
  1. class LevelsToolTip extends BasePlaceableHUD {
  2. static get defaultOptions() {
  3. const options = super.defaultOptions;
  4. options.classes = options.classes.concat(["levels-tooltip"]);
  5. options.template = "modules/levels/templates/tooltip.html";
  6. options.id = "levels-tooltip";
  7. return options;
  8. }
  9. getData() {
  10. const data = super.getData();
  11. return data;
  12. }
  13. setPosition() {
  14. if (!this.object) return;
  15. let posleft = this.object.center.x - this.object.width / 2;
  16. let postop = this.object.center.y - this.object.height / 2;
  17. if(this.object instanceof Note){
  18. postop -= this.object.height / 2;
  19. }
  20. const position = {
  21. width: canvas.grid.size * 1.2,
  22. height: canvas.grid.size * 0.8,
  23. left: posleft,
  24. top: postop,
  25. "font-size": canvas.grid.size / 3.5 + "px",
  26. display: "grid",
  27. };
  28. this.element.css(position);
  29. }
  30. }
  31. Hooks.once("init", () => {
  32. Hooks.on("renderHeadsUpDisplay", async (app, html, data) => {
  33. html.append('<template id="levels-tooltip"></template>');
  34. canvas.hud.levels = new LevelsToolTip();
  35. });
  36. });
  37. Hooks.on("renderSceneControls", () => {
  38. if (canvas.hud?.levels) canvas.hud.levels.clear();
  39. });
  40. Hooks.on("hoverTile", (object, hovered) => {
  41. if (
  42. hovered &&
  43. object.document.overhead &&
  44. CONFIG.Levels.settings.get("enableTooltips") && !game.Levels3DPreview?._active
  45. ) {
  46. canvas.hud.levels.bind(object);
  47. } else {
  48. canvas.hud.levels.clear();
  49. }
  50. });
  51. Hooks.on("hoverDrawing", (object, hovered) => {
  52. if (hovered && CONFIG.Levels.settings.get("enableTooltips") && !game.Levels3DPreview?._active) {
  53. canvas.hud.levels.bind(object);
  54. } else {
  55. canvas.hud.levels.clear();
  56. }
  57. });
  58. Hooks.on("hoverAmbientLight", (object, hovered) => {
  59. if (hovered && CONFIG.Levels.settings.get("enableTooltips") && !game.Levels3DPreview?._active) {
  60. canvas.hud.levels.bind(object);
  61. } else {
  62. canvas.hud.levels.clear();
  63. }
  64. });
  65. Hooks.on("hoverNote", (object, hovered) => {
  66. if (game.user.isGM && hovered && CONFIG.Levels.settings.get("enableTooltips") && !game.Levels3DPreview?._active) {
  67. canvas.hud.levels.bind(object);
  68. } else {
  69. canvas.hud.levels.clear();
  70. }
  71. });
  72. Hooks.on("hoverAmbientSound", (object, hovered) => {
  73. if (hovered && CONFIG.Levels.settings.get("enableTooltips") && !game.Levels3DPreview?._active) {
  74. canvas.hud.levels.bind(object);
  75. } else {
  76. canvas.hud.levels.clear();
  77. }
  78. });