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.

74 lines
2.5 KiB

  1. import * as util from "../util.js";
  2. import { ThemeSettings } from "./theme-settings.js";
  3. import { MiscSettings } from "./misc-settings.js";
  4. import { CustomizationSettings } from "./customization-settings.js";
  5. import { ExternalModuleSettings } from "./external-module-settings.js";
  6. import { lookupThemeAndSchemeForKey } from "../ui-theme.js";
  7. import { MODULE_NAME } from "../consts.js";
  8. export function refreshChat() {
  9. if (game.messages.size > 100) {
  10. return ui.notifications.warn(game.i18n.localize("pf2e-dorako-ui.text.large-chatlog-warning"));
  11. }
  12. const messages = game.messages.filter((m) => m instanceof ChatMessage);
  13. for (const message of messages) {
  14. ui.chat.updateMessage(message);
  15. }
  16. }
  17. Hooks.once("init", async () => {
  18. util.debug("Init...");
  19. game.settings.register("pf2e-dorako-ui", "mld-nag", {
  20. scope: "world",
  21. config: false,
  22. default: true,
  23. type: Boolean,
  24. });
  25. ThemeSettings.registerSettings();
  26. MiscSettings.registerSettings();
  27. CustomizationSettings.registerSettings();
  28. ExternalModuleSettings.registerSettings();
  29. util.debug("Registered settings...");
  30. const applicationTheme = game.settings.get("pf2e-dorako-ui", "theme.app-theme");
  31. if (applicationTheme !== "no-theme") {
  32. const uiTheme = lookupThemeAndSchemeForKey(applicationTheme);
  33. const { dorakoUiTheme, colorScheme } = uiTheme;
  34. if (uiTheme) {
  35. $("#tooltip").attr("data-theme", dorakoUiTheme);
  36. $("#fps").attr("data-theme", dorakoUiTheme);
  37. }
  38. }
  39. const root = document.querySelector(":root").style;
  40. root.setProperty("--border-radius", game.settings.get("pf2e-dorako-ui", "theme.border-radius").toString() + "px");
  41. util.debug("initialized properties...");
  42. util.debug("Migrating invalid settings to default...");
  43. const allSettings = [...game.settings.settings].filter(([k, _]) => k.startsWith(MODULE_NAME));
  44. for (const [_, setting] of allSettings) {
  45. const key = setting.key;
  46. const currentValue = game.settings.get(MODULE_NAME, key);
  47. const choices = setting.choices;
  48. if (choices) {
  49. if (!(currentValue in choices)) {
  50. const defaultValue = setting.default;
  51. await game.settings.set(MODULE_NAME, key, defaultValue);
  52. console.warn(`Set ${key} to '${defaultValue}' since '${currentValue}' is invalid`);
  53. }
  54. }
  55. }
  56. });
  57. Hooks.once("ready", () => {
  58. let dorakoCustomCss = document.createElement("style");
  59. dorakoCustomCss.id = "dorako-custom-css";
  60. dorakoCustomCss.innerHTML = game.settings.get("pf2e-dorako-ui", "customization.custom-css");
  61. document.querySelector("head").appendChild(dorakoCustomCss);
  62. });