Skip to content

Commit

Permalink
3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorako committed Dec 3, 2023
1 parent 25ff8de commit aae6e3a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 103 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.2.1

- (Fix) Fixed an issue where CRB (Dark) sheet theme would be broken.

# 3.2.0

- (New) Excluded PFS premium module journals from styling.
Expand Down
2 changes: 1 addition & 1 deletion esmodules/message-hooks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getChatTheme, getDefaultColorScheme, lookupThemeAndSchemeForKey } from "./ui-theme.js";
import { lookupThemeAndSchemeForKey } from "./ui-theme.js";

Hooks.on("renderChatMessage", (chatMessage, html, messageData) => {
if (html[0].hasAttribute("style")) {
Expand Down
4 changes: 2 additions & 2 deletions esmodules/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ThemeSettings } from "./theme-settings.js";
import { MiscSettings } from "./misc-settings.js";
import { CustomizationSettings } from "./customization-settings.js";
import { ExternalModuleSettings } from "./external-module-settings.js";
import { getAppThemeAndScheme, getUiTheme } from "../ui-theme.js";
import { lookupThemeAndSchemeForKey } from "../ui-theme.js";
import { MODULE_NAME } from "../consts.js";

export function refreshChat() {
Expand Down Expand Up @@ -50,7 +50,7 @@ Hooks.once("init", async () => {

const applicationTheme = game.settings.get("pf2e-dorako-ui", "theme.app-theme");
if (applicationTheme !== "no-theme") {
const uiTheme = getAppThemeAndScheme();
const uiTheme = lookupThemeAndSchemeForKey(applicationTheme);
const { dorakoUiTheme, colorScheme } = uiTheme;

if (uiTheme) {
Expand Down
105 changes: 5 additions & 100 deletions esmodules/ui-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,101 +8,6 @@ import {
} from "./consts.js";
import { isPremiumApplication } from "./premium-module-hooks.js";

export function getDefaultColorScheme(theme) {
switch (theme) {
case "crb-light":
return "light";
case "foundry2":
return "dark";
case "bg3-brown":
return "dark";
case "bg3-blue":
return "dark";
case "bg3":
return "dark";
case "discord":
return "dark";
case "discord-light":
return "light";
case "discord-dark":
return "dark";
default:
return null;
}
}

export function getUiTheme() {
const windowAppTheme = game.settings.get("pf2e-dorako-ui", "theme.window-app-theme");
// const colorSchemePref = game.settings.get("pf2e-dorako-ui", "theme.window-app-color-scheme");
// const colorScheme = (function () {
// switch (colorSchemePref) {
// case "default":
// return getDefaultColorScheme(windowAppTheme);
// case "prefer-light":
// return "light";
// case "prefer-dark":
// return "dark";
// }
// })();
// return { dorakoUiTheme: windowAppTheme, colorScheme: colorScheme };
return { dorakoUiTheme: windowAppTheme, colorScheme: getDefaultColorScheme(windowAppTheme) };
}

export function getAppThemeAndScheme() {
const setting = game.settings.get("pf2e-dorako-ui", "theme.app-theme");
switch (setting) {
case "crb":
return { dorakoUiTheme: "crb", colorScheme: null };
case "crb-light":
return { dorakoUiTheme: "crb-light", colorScheme: "light" };
case "crb-dark":
return { dorakoUiTheme: "crb-dark", colorScheme: "dark" };
case "foundry2":
return { dorakoUiTheme: "foundry2", colorScheme: "dark" };
case "bg3":
return { dorakoUiTheme: "bg3", colorScheme: "dark" };
case "discord":
return { dorakoUiTheme: "discord", colorScheme: "dark" };
case "discord-light":
return { dorakoUiTheme: "discord-light", colorScheme: "light" };
case "discord-dark":
return { dorakoUiTheme: "discord-dark", colorScheme: "dark" };
case "opaque": {
return { dorakoUiTheme: "opaque", colorScheme: "dark" };
}
default:
return "", "";
}
}

export function getChatTheme() {
const setting = game.settings.get("pf2e-dorako-ui", "theme.chat-message-theme");
switch (setting) {
case "crb":
return { dorakoUiTheme: "crb", colorScheme: null };
case "crb-light":
return { dorakoUiTheme: "crb", colorScheme: "light" };
case "crb-dark":
return { dorakoUiTheme: "crb", colorScheme: "dark" };
case "foundry2":
return { dorakoUiTheme: "foundry2", colorScheme: "dark" };
case "bg3":
return { dorakoUiTheme: "bg3", colorScheme: "dark" };
case "bg3-brown":
return { dorakoUiTheme: "bg3", colorScheme: "dark" };
case "bg3-blue":
return { dorakoUiTheme: "bg3", colorScheme: "dark" };
case "discord":
return { dorakoUiTheme: "discord", colorScheme: "dark" };
case "discord-light":
return { dorakoUiTheme: "discord-light", colorScheme: "light" };
case "discord-dark":
return { dorakoUiTheme: "discord-dark", colorScheme: "dark" };
default:
return "", "";
}
}

export function lookupThemeAndSchemeForKey(key) {
switch (key) {
case "crb":
Expand Down Expand Up @@ -133,7 +38,7 @@ export function lookupThemeAndSchemeForKey(key) {
Hooks.on("renderSvelteApplication", (app, html, data) => {
const theme = game.settings.get("pf2e-dorako-ui", "theme.window-app-theme");
if (theme === "no-theme") return;
const uiTheme = getUiTheme();
const uiTheme = lookupThemeAndSchemeForKey(theme);
if (uiTheme === null) return;
const excludeString = game.settings.get("pf2e-dorako-ui", "customization.excluded-applications");
const excludeList = excludeString.split(/[\s,]+/);
Expand All @@ -151,7 +56,7 @@ for (const appName of [...themedApps]) {
Hooks.on("render" + appName, (app, html, data) => {
const theme = game.settings.get("pf2e-dorako-ui", "theme.app-theme");
if (theme === "no-theme") return;
const uiTheme = getAppThemeAndScheme();
const uiTheme = lookupThemeAndSchemeForKey(theme);
if (uiTheme === null) return;
const { dorakoUiTheme, colorScheme } = uiTheme;
const excludeString = game.settings.get("pf2e-dorako-ui", "customization.excluded-applications");
Expand All @@ -172,7 +77,7 @@ for (const appName of [...systemSheets, ...moduleWindowApps]) {
Hooks.on("render" + appName, (app, html, data) => {
const theme = game.settings.get("pf2e-dorako-ui", "theme.window-app-theme");
if (theme === "no-theme") return;
const uiTheme = getUiTheme();
const uiTheme = lookupThemeAndSchemeForKey(theme);
if (uiTheme === null) return;
const { dorakoUiTheme, colorScheme } = uiTheme;
const excludeString = game.settings.get("pf2e-dorako-ui", "customization.excluded-applications");
Expand Down Expand Up @@ -205,7 +110,7 @@ Hooks.on("renderApplication", (app, html, data) => {
if (isPremiumApplication(app, html, data, app.constructor.name)) return;
const theme = game.settings.get("pf2e-dorako-ui", "theme.window-app-theme");
if (theme === "no-theme") return;
const uiTheme = getUiTheme();
const uiTheme = lookupThemeAndSchemeForKey(theme);
if (uiTheme === null) return;
const { dorakoUiTheme, colorScheme } = uiTheme;
const excludeString =
Expand Down Expand Up @@ -258,7 +163,7 @@ for (const appName of [...limitedScopeApplications]) {
Hooks.on("render" + appName, (app, html, data) => {
const theme = game.settings.get("pf2e-dorako-ui", "theme.window-app-theme");
if (theme === "no-theme") return;
const uiTheme = getUiTheme();
const uiTheme = lookupThemeAndSchemeForKey(theme);
if (uiTheme === null) return;
const excludeString = game.settings.get("pf2e-dorako-ui", "customization.excluded-applications");
const excludeList = excludeString.split(/[\s,]+/);
Expand Down

0 comments on commit aae6e3a

Please sign in to comment.