Skip to content

Commit

Permalink
1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorako committed Feb 8, 2022
1 parent 38a2300 commit 394bf0d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 12 deletions.
77 changes: 67 additions & 10 deletions scripts/dorako-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ function injectWhisperParticipants(html, messageData) {
Hooks.once('init', async function () {
CONFIG.ChatMessage.template = "modules/pf2e-dorako-ui/templates/base-chat-message.html";

game.settings.register("pf2e-dorako-ui", "displaySetting", {
name: "Display setting",
hint: "Configure which cards should receive custom styling, and which ones should be left as default. Changing this may require you to refresh your window.",
scope: "client",
config: true,
default: "allCards",
type: String,
choices: {
"allCards": "Affect every message.",
"selfAndGM": "Affect own messages and GM messages.",
"self": "Only affect own messages.",
"gm": "Only affect GM messages.",
"player": "Only affect player messages.",
"none": "Don't affect any messages."
}
});

game.settings.register("pf2e-dorako-ui", "theme", {
name: "Theme",
hint: "Select between light and dark theme",
Expand Down Expand Up @@ -106,10 +123,18 @@ Hooks.once('init', async function () {
}
});

game.settings.register("pf2e-dorako-ui", "borderOverride", {
name: "Override border",
hint: "Enables border colour override. This will colour the border of the chat card with the player's colour.",
scope: "client",
config: true,
default: true,
type: Boolean
});

game.settings.register("pf2e-dorako-ui", "enable-chat-portrait", {
name: "Enable chat portrait",
hint: "Adds a visual representation of the speaker to the top-left corner of each message",
game.settings.register("pf2e-dorako-ui", "insertSpeakerImage", {
name: "Insert Speaker Image",
hint: "Adds the image of the speaker to the chat card.",
scope: "client",
config: true,
default: true,
Expand All @@ -120,7 +145,24 @@ Hooks.once('init', async function () {

Hooks.on('init', () => {
function shouldOverrideMessage(message) {
return true;
const setting = game.settings.get("pf2e-dorako-ui", "displaySetting");
if (setting !== "none") {
const user = game.users.get(message.user);
if (user) {
const isSelf = user.data._id === game.user.data._id;
const isGM = user.isGM;

if ((setting === "allCards")
|| (setting === "self" && isSelf)
|| (setting === "selfAndGM" && (isSelf || isGM))
|| (setting === "gm" && isGM)
|| (setting === "player" && !isGM)
) {
return true;
}
}
}
return false;
}


Expand All @@ -147,7 +189,7 @@ Hooks.once("setup", function () {
});

Handlebars.registerHelper("showSpeakerImage", function (message) {
const insertSpeakerImage = game.settings.get("pf2e-dorako-ui", "enable-chat-portrait");
const insertSpeakerImage = game.settings.get("pf2e-dorako-ui", "insertSpeakerImage");
if (!insertSpeakerImage) {
return false;
}
Expand Down Expand Up @@ -206,7 +248,7 @@ Hooks.once("setup", function () {
});

Handlebars.registerHelper("getBorderStyle", function (message, foundryBorder) {
const borderOverride = true;
const borderOverride = game.settings.get("pf2e-dorako-ui", "borderOverride");
if (borderOverride && shouldOverrideMessage(message)) {
const user = game.users.get(message.user);
return `border-color: ${user.data.color}`;
Expand Down Expand Up @@ -259,7 +301,7 @@ Hooks.once("setup", function () {
return "";
});

Handlebars.registerHelper("getHeaderStyle", function () {
Handlebars.registerHelper("getheaderStyle", function () {
const headerStyle = game.settings.get("pf2e-dorako-ui", "headerStyle");
return headerStyle;
});
Expand Down Expand Up @@ -539,9 +581,8 @@ Hooks.once("setup", function () {
if (theme == "light") {
// do nothing
} else if (theme == "dark") {
enableDarkTheme();
enableDarkTheme()
} else if (theme == "rainbow") {
enableDarkTheme();
enableRainbowTheme();
}

Expand All @@ -552,7 +593,23 @@ Hooks.once("setup", function () {

function shouldOverrideMessage(message) {
const setting = game.settings.get("pf2e-dorako-ui", "displaySetting");
return true;
if (setting !== "none") {
const user = game.users.get(message.user);
if (user) {
const isSelf = user.data._id === game.user.data._id;
const isGM = user.isGM;

if ((setting === "allCards")
|| (setting === "self" && isSelf)
|| (setting === "selfAndGM" && (isSelf || isGM))
|| (setting === "gm" && isGM)
|| (setting === "player" && !isGM)
) {
return true;
}
}
}
return false;
}


Expand Down
6 changes: 4 additions & 2 deletions styles/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,7 @@ button {
/* DARK MODE */

:root {
--pf2e-header-text-color: --pf2e-body-primary;
--bg-current: var(--bg-light);


--pf2e-body-primary: hsl(0, 0%, 10%);
--pf2e-body-secondary: hsl(0, 0%, 25%);
Expand All @@ -544,6 +543,9 @@ button {
--pf2e-translucent-very: var(--pf2e-translucent-very-for-light);
--filter-img: var(--filter-light);

--pf2e-header-text-color: var(--pf2e-body-primary);
--bg-current: var(--bg-light);

/* --bg-current: var(--bg-dark);
--pf2e-body-primary: hsl(0, 0%, 100%);
--pf2e-body-secondary: hsl(0, 0%, 60%);
Expand Down

0 comments on commit 394bf0d

Please sign in to comment.