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.

241 lines
9.1 KiB

  1. import { MODULE_NAME, systemSheets } from "./consts.js";
  2. import { i18n, debug, warn } from "./util.js";
  3. Hooks.once("ready", () => {
  4. if (!game.modules.get("pf2e-dorako-ux")) return;
  5. if (game.modules.get("pf2e-dorako-ux")?.active) return;
  6. if (!game.user.isGM) return;
  7. new Dialog({
  8. title: "Dorako UX is not active!",
  9. content: `
  10. <p>Dorako UI is dependant on the module Dorako UX.</p>
  11. <p>It's probably already installed, but not enabled.</p>
  12. <p>Go to Manage Modules and enable it, hit Save Module Settings, and reload.</p>`,
  13. buttons: {
  14. OK: {
  15. label: "OK",
  16. callback: () => {},
  17. },
  18. },
  19. default: "OK",
  20. }).render(true);
  21. });
  22. Hooks.once("ready", () => {
  23. if (!game.modules.get("monks-little-details")?.active) return;
  24. if (!game.settings.get("monks-little-details", "window-css-changes")) return;
  25. if (!game.settings.get("pf2e-dorako-ui", "mld-nag")) return;
  26. if (!game.user.isGM) return;
  27. new Dialog({
  28. title: "Dorako UI - Monk's Little Details conflict",
  29. content: `
  30. <p>Monk's Little Details has a default-on setting that influences the look of application windows.</p>
  31. <p>Dorako UI already affects application windows, so it is recommended to disable the setting.</p>
  32. <p>If you want to make application windows opaque, Dorako UI has a setting for changing all glassy backgrounds.</p>
  33. <p>Dorako UI can change your settings for you using the following buttons:</p>`,
  34. buttons: {
  35. disable: {
  36. label: "Disable MLD setting",
  37. callback: () => {
  38. game.settings.set("monks-little-details", "window-css-changes", false);
  39. },
  40. },
  41. opaque: {
  42. label: "Disable MLD setting + use Dorako UI opaque app theme",
  43. callback: () => {
  44. game.settings.set("monks-little-details", "window-css-changes", false);
  45. game.settings.set("pf2e-dorako-ui", "theme.app-theme", "opaque");
  46. },
  47. },
  48. "dont-ask": {
  49. label: "Do nothing, don't ask again",
  50. callback: () => {
  51. game.settings.set("pf2e-dorako-ui", "mld-nag", false);
  52. },
  53. },
  54. },
  55. default: "disable",
  56. }).render(true);
  57. });
  58. // Hooks.once("ready", () => {
  59. // if (!game.modules.get("token-action-hud")?.active) return;
  60. // if (game.settings.get("token-action-hud", "style") === "dorakoUI") return;
  61. // if (!game.settings.get("pf2e-dorako-ui", "tah-nag")) return; // if nag has been disabled
  62. // new Dialog({
  63. // title: "Dorako UI - Token Action HUD style",
  64. // content: `
  65. // <p>Token Action HUD ships with a setting that matches the style of Dorako UI.</p>
  66. // <p>Dorako UI can turn the setting on for you (recommended).</p>`,
  67. // buttons: {
  68. // enable: {
  69. // label: "Enable Dorako UI style",
  70. // callback: () => {
  71. // game.settings.set("token-action-hud", "style", "dorakoUI");
  72. // },
  73. // },
  74. // "dont-ask": {
  75. // label: "Do nothing, don't ask again",
  76. // callback: () => {
  77. // game.settings.set("pf2e-dorako-ui", "tah-nag", false);
  78. // },
  79. // },
  80. // },
  81. // default: "enable",
  82. // }).render(true);
  83. // });
  84. // Hooks.on("tokenActionHudCoreReady", () => {
  85. // if (game.settings.get("token-action-hud-core", "style") === "dorakoUI") return;
  86. // if (!game.settings.get("pf2e-dorako-ui", "tah-nag")) return; // if nag has been disabled
  87. // new Dialog({
  88. // title: "Dorako UI - Token Action HUD Core style",
  89. // content: `
  90. // <p>Token Action HUD Core ships with a setting that matches the style of Dorako UI.</p>
  91. // <p>Dorako UI can turn the setting on for you (recommended).</p>`,
  92. // buttons: {
  93. // enable: {
  94. // label: "Enable Dorako UI style",
  95. // callback: () => {
  96. // game.settings.set("token-action-hud-core", "style", "dorakoUI");
  97. // },
  98. // },
  99. // "dont-ask": {
  100. // label: "Do nothing, don't ask again",
  101. // callback: () => {
  102. // game.settings.set("pf2e-dorako-ui", "tah-nag", false);
  103. // },
  104. // },
  105. // },
  106. // default: "enable",
  107. // }).render(true);
  108. // });
  109. for (const application of ["Application", ...systemSheets]) {
  110. Hooks.on("render" + application, (app, html, data) => {
  111. if (!game.settings.get(`${MODULE_NAME}`, "misc.enable-debug-mode")) {
  112. return;
  113. }
  114. let colorSchemeButton = $(
  115. `<a class="header-button dark-theme-toggle" alt="Toggle dark theme" data-tooltip="Dark theme" data-tooltip-direction="UP"">
  116. <i class="fas fa-fw fa-moon"></i>
  117. </a>`
  118. );
  119. colorSchemeButton.click((ev) => {
  120. let colorScheme = html[0].dataset.colorScheme;
  121. if (colorScheme === "light") {
  122. html[0].dataset.colorScheme = "dark";
  123. } else {
  124. html[0].dataset.colorScheme = "light";
  125. }
  126. });
  127. let foundry2Button = $(
  128. `<a class="header-button foundry2-toggle" alt="Toggle Foundry2" data-tooltip="Toggle Foundry2" data-tooltip-direction="UP">
  129. <i class="fa-fw fas fa-f"></i>
  130. </a>`
  131. );
  132. foundry2Button.click((ev) => {
  133. html[0].dataset.theme = "foundry2";
  134. });
  135. let crbButton = $(
  136. `<a class="header-button crb-toggle" alt="Toggle CRB" data-tooltip="Toggle CRB" data-tooltip-direction="UP">
  137. <i class="fa-fw fas fa-c"></i>
  138. </a>`
  139. );
  140. crbButton.click((ev) => {
  141. html[0].dataset.theme = "crb";
  142. });
  143. let bg3Button = $(
  144. `<a class="header-button bg3-toggle" alt="Toggle BG3" data-tooltip="Toggle BG3" data-tooltip-direction="UP">
  145. <i class="fa-fw fas fa-b"></i>
  146. </a>`
  147. );
  148. bg3Button.click((ev) => {
  149. html[0].dataset.theme = "bg3";
  150. });
  151. let discordButton = $(
  152. `<a class="header-button discord-toggle" alt="Toggle Discord" data-tooltip="Toggle Discord" data-tooltip-direction="UP">
  153. <i class="fa-fw fas fa-d"></i>
  154. </a>`
  155. );
  156. discordButton.click((ev) => {
  157. html[0].dataset.theme = "discord";
  158. });
  159. let noThemeButton = $(
  160. `<a class="header-button no-theme-toggle" alt="No theme" data-tooltip="No theme" data-tooltip-direction="UP">
  161. <i class="fa-fw fas fa-eraser"></i>
  162. </a>`
  163. );
  164. noThemeButton.click((ev) => {
  165. delete html[0].dataset.theme;
  166. delete html[0].dataset.colorScheme;
  167. });
  168. html.closest(".app").find(".dark-theme-toggle").remove();
  169. html.closest(".app").find(".crb-toggle").remove();
  170. html.closest(".app").find(".foundry2-toggle").remove();
  171. html.closest(".app").find(".bg3-toggle").remove();
  172. html.closest(".app").find(".discord-toggle").remove();
  173. html.closest(".app").find(".no-theme-toggle").remove();
  174. let titleElement = html.closest(".app").find(".window-title");
  175. colorSchemeButton.insertAfter(titleElement);
  176. crbButton.insertAfter(titleElement);
  177. foundry2Button.insertAfter(titleElement);
  178. bg3Button.insertAfter(titleElement);
  179. discordButton.insertAfter(titleElement);
  180. noThemeButton.insertAfter(titleElement);
  181. });
  182. }
  183. Hooks.on("renderSettingsConfig", (app, html, data) => {
  184. $("<div>")
  185. .addClass("form-group dorako settings-header")
  186. .html(
  187. i18n("pf2e-dorako-ui.settings.theme.name") + `<p class="notes">${i18n("pf2e-dorako-ui.settings.theme.hint")}</p>`
  188. )
  189. .insertBefore($('[name="pf2e-dorako-ui.theme.app-theme"]').parents("div.form-group:first"));
  190. $("<div>")
  191. .addClass("form-group dorako settings-header")
  192. .html(
  193. i18n("pf2e-dorako-ui.settings.avatar.name") +
  194. `<p class="notes">${i18n("pf2e-dorako-ui.settings.avatar.hint")}</p>`
  195. )
  196. .insertBefore($('[name="pf2e-dorako-ui.avatar.source"]').parents("div.form-group:first"));
  197. $("<div>")
  198. .addClass("form-group dorako settings-header")
  199. .html(i18n("pf2e-dorako-ui.settings.ux.name") + `<p class="notes">${i18n("pf2e-dorako-ui.settings.ux.hint")}</p>`)
  200. .insertBefore($('[name="pf2e-dorako-ui.ux.restructure-card-info"]').parents("div.form-group:first"));
  201. $("<div>")
  202. .addClass("form-group dorako settings-header")
  203. .html(
  204. i18n("pf2e-dorako-ui.settings.misc.name") + `<p class="notes">${i18n("pf2e-dorako-ui.settings.misc.hint")}</p>`
  205. )
  206. .insertBefore($('[name="pf2e-dorako-ui.misc.enable-debug-mode"]').parents("div.form-group:first"));
  207. $("<div>")
  208. .addClass("form-group dorako settings-header")
  209. .html(
  210. i18n("pf2e-dorako-ui.settings.customization.name") +
  211. `<p class="notes">${i18n("pf2e-dorako-ui.settings.customization.hint")}</p>`
  212. )
  213. .insertBefore($('[name="pf2e-dorako-ui.customization.excluded-applications"]').parents("div.form-group:first"));
  214. const isIdleHudEnabled = game.modules.get("pf2e-token-hud")?.active;
  215. if (isIdleHudEnabled) {
  216. $("<div>")
  217. .addClass("form-group dorako settings-header")
  218. .html(
  219. i18n("pf2e-dorako-ui.settings.external-module.name") +
  220. `<p class="notes">${i18n("pf2e-dorako-ui.settings.external-module.hint")}</p>`
  221. )
  222. .insertBefore($('[name="pf2e-dorako-ui.external-module.colorize-idle-hud"]').parents("div.form-group:first"));
  223. } else {
  224. $("div[data-setting-id*=external-module]").addClass("dorako-display-none");
  225. }
  226. });
  227. Hooks.on("renderHUD", (app, html, data) => {
  228. const isColorized = game.settings.get("pf2e-dorako-ui", "external-module.colorize-idle-hud");
  229. if (!isColorized) return;
  230. let html0 = html[0];
  231. html0.classList.add("colorized");
  232. });