Skip to content

Commit

Permalink
3.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorako committed Oct 24, 2024
1 parent 0fad2eb commit e6a9aa3
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 98 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 3.7.5

- (Refinement) Adjusted the way the chat message header color is computed - it will now prefer the color of the user associated with the actor, rather than the user who is the author of the message.
- (Refinement) Updated whisper styling to be compatible with Dorako UX 1.5.7.
- (Refinement) Exclude whisper tags from 'damage-taken' style messages.

# 3.7.4

- (Refinement) Tweaked the color generation for the new 'Player Sheet Theme Color' feature again.
Expand Down
7 changes: 2 additions & 5 deletions esmodules/message-hooks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { lookupThemeAndSchemeForKey } from "./ui-theme.js";
import { getPlayerOwners } from "./util.js";

Hooks.on("renderChatMessage", (chatMessage, html, messageData) => {
if (html[0].hasAttribute("style")) {
Expand Down Expand Up @@ -69,15 +70,11 @@ const headerStyleColors = {
function getHeaderColor(html, message) {
const headerStyle = game.settings.get("pf2e-dorako-ui", "theme.chat-message-header-style");
if (headerStyle === "tint") {
return message?.author?.color ?? headerStyleColors.fallback;
return getPlayerOwners(message.actor)[0].color.css ?? message?.author?.color ?? headerStyleColors.fallback;
}
return headerStyleColors[headerStyle] ?? headerStyleColors.fallback;
}

function invertColor(color) {
return color === "dark" ? "light" : "dark";
}

function calcHeaderTextColor(headerColor) {
if (headerColor === headerStyleColors.none) {
return "dark";
Expand Down
38 changes: 1 addition & 37 deletions esmodules/ui-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
appV2Apps,
} from "./consts.js";
import { isPremiumApplication } from "./premium-module-hooks.js";
import { getPlayerOwners } from "./util.js";

export function lookupThemeAndSchemeForKey(key) {
switch (key) {
Expand Down Expand Up @@ -341,43 +342,6 @@ for (const appName of ["CharacterSheetPF2e", "VehicleSheetPF2e"]) {
});
}

export function nonNullable(value) {
return value !== null && value !== undefined;
}

export function getPlayerOwners(actor) {
const assigned = game.users.contents.find((user) => user.character?.id === actor.id);
if (assigned) return [assigned];

// If everyone owns it, nobody does.
if (actor.ownership.default === 3) {
return game.users.contents;
}

// Check the ownership IDs, check if there is a player owner, yes, ignore GMs, no, count only GMs.
const owners = Object.keys(actor.ownership)
.filter((x) => x !== "default")
.filter((x) =>
actor.hasPlayerOwner ? !game.users.get(x)?.hasRole("GAMEMASTER") : game.users.get(x)?.hasRole("GAMEMASTER")
)
.map((x) => game.users.get(x))
.filter(nonNullable);

if (owners.length) {
return owners;
} else {
// If "nobody" owns it, whoever is the primaryUpdater (read: GM) does.
// This should handle weirdos like { ownership: { default: 0 } }
if (actor.primaryUpdater) {
log("Could not determine owner, defaulting to primaryUpdater.");
return [actor.primaryUpdater];
} else {
log("Could not determine owner nor found the primaryUpdater, defaulting to all GMs.");
return game.users.filter((x) => x.isGM);
}
}
}

Hooks.on("render" + "ItemSheetPF2e", (app, html, data) => {
const rarity = app?.object?.rarity;
if (rarity) app.element[0].dataset.rarity = rarity;
Expand Down
39 changes: 39 additions & 0 deletions esmodules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,42 @@ export function i18nFormat(key, data) {
export function titleCase(string) {
return string[0].toUpperCase() + string.slice(1).toLowerCase();
}

export function nonNullable(value) {
return value !== null && value !== undefined;
}

// Stolen from MrVauxs
export function getPlayerOwners(actor) {
if (actor == null) return game.users.filter((x) => x.isGM);
const assigned = game.users.contents.find((user) => user.character?.id === actor.id);
if (assigned) return [assigned];

// If everyone owns it, nobody does.
if (actor.ownership.default === 3) {
return game.users.contents;
}

// Check the ownership IDs, check if there is a player owner, yes, ignore GMs, no, count only GMs.
const owners = Object.keys(actor.ownership)
.filter((x) => x !== "default")
.filter((x) =>
actor.hasPlayerOwner ? !game.users.get(x)?.hasRole("GAMEMASTER") : game.users.get(x)?.hasRole("GAMEMASTER")
)
.map((x) => game.users.get(x))
.filter(nonNullable);

if (owners.length) {
return owners;
} else {
// If "nobody" owns it, whoever is the primaryUpdater (read: GM) does.
// This should handle weirdos like { ownership: { default: 0 } }
if (actor.primaryUpdater) {
log("Could not determine owner, defaulting to primaryUpdater.");
return [actor.primaryUpdater];
} else {
log("Could not determine owner nor found the primaryUpdater, defaulting to all GMs.");
return game.users.filter((x) => x.isGM);
}
}
}
9 changes: 6 additions & 3 deletions sass/module-support/_pf2e-hud.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
--color: var(--text-color-1);
}

#pf2e-hud-token-main:not(.exploded) .joined,
&[id^="pf2e-hud-persistent"].app,
&[id^="pf2e-hud-persistent"] .app {
@include dui-app;
}

#pf2e-hud-token-main:not(.exploded) .joined {
@include dui-app;
backdrop-filter: blur(5px);
}

Expand All @@ -26,11 +29,11 @@
}

&#pf2e-hud-sidebar .item-list {
backdrop-filter: blur(4px);
backdrop-filter: blur(5px);
}

&#pf2e-hud-persistent-effects .effect-item:hover .effect-info {
backdrop-filter: blur(4px);
backdrop-filter: blur(5px);
}

&[data-theme^="bg3"]#pf2e-hud-persistent-effects .effect-item .effect-info {
Expand Down
4 changes: 2 additions & 2 deletions sass/ui-theme/themes/_bg3.scss
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,11 @@
color: var(--bg3-text-1);
text-shadow: 0px 1px 1px black;

&.rolltype.whisper {
&.whisper {
background-color: color-mix(in srgb, var(--bg3-alliance-companion-blue) 50%, transparent);
border-color: color-mix(in srgb, var(--bg3-alliance-companion-blue) 100%, rgba(255, 255, 255, 0.5));
}
&.rolltype.blind {
&.blind {
background-color: color-mix(in srgb, var(--bg3-alliance-opposition-red) 50%, transparent);
border-color: color-mix(in srgb, var(--bg3-alliance-opposition-red) 100%, rgba(255, 255, 255, 0.5));
}
Expand Down
18 changes: 9 additions & 9 deletions sass/ui-theme/themes/_crb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@
}
}
}
.message-header .header-meta.rolltype {
&.blind {
background-color: var(--dnd5e-color-sc-2);
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5));
color: white;
}
.message-header .header-meta {
&.whisper {
background-color: var(--dnd5e-color-blue);
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5));
color: white;
background-color: var(--dnd5e-color-blue) !important;
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5)) !important;
color: white !important;
}
&.blind {
background-color: var(--dnd5e-color-sc-2) !important;
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5)) !important;
color: white !important;
}
}
.card-content {
Expand Down
8 changes: 4 additions & 4 deletions sass/ui-theme/themes/_discord.scss
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,13 @@
}
}

.message-header .header-meta.rolltype {
&.blind {
color: var(--blind-bg);
}
.message-header .header-meta {
&.whisper {
color: var(--whisper-bg);
}
&.blind {
color: var(--blind-bg);
}
}

.message-header,
Expand Down
10 changes: 5 additions & 5 deletions sass/ui-theme/themes/_dnd5e2.scss
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,14 @@
z-index: 1;
}

.message-header .header-meta.rolltype {
&.blind {
background-color: var(--dnd5e-color-sc-2);
.message-header .header-meta {
&.whisper {
background-color: var(--dnd5e-color-blue);
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5));
color: white;
}
&.whisper {
background-color: var(--dnd5e-color-blue);
&.blind {
background-color: var(--dnd5e-color-sc-2);
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5));
color: white;
}
Expand Down
8 changes: 4 additions & 4 deletions sass/ui-theme/themes/_foundry2.scss
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@
border: 1px solid color-mix(in srgb, var(--player-color) 50%, rgba(255, 255, 255, 0.5));
color: var(--text-color-1);
text-shadow: 0px 1px 1px black;
&.blind {
background-color: color-mix(in srgb, var(--blind-bg) 50%, transparent);
border: 1px solid color-mix(in srgb, var(--blind-bg) 66%, rgba(255, 255, 255, 0.5));
}
&.whisper {
background-color: color-mix(in srgb, rgb(42, 113, 255) 33%, transparent);
border: 1px solid color-mix(in srgb, rgb(42, 113, 255) 50%, rgba(255, 255, 255, 0.5));
}
&.blind {
background-color: color-mix(in srgb, var(--blind-bg) 50%, transparent);
border: 1px solid color-mix(in srgb, var(--blind-bg) 66%, rgba(255, 255, 255, 0.5));
}
}
}

Expand Down
64 changes: 36 additions & 28 deletions styles/dorako-ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,15 @@ body.compact-ui #navigation[data-theme] .monks-scene-navigation #nav-toggle {
[data-theme][id^=pf2e-hud] {
--color: var(--text-color-1);
}
[data-theme] #pf2e-hud-token-main:not(.exploded) .joined, [data-theme][id^=pf2e-hud-persistent].app, [data-theme][id^=pf2e-hud-persistent] .app {
[data-theme][id^=pf2e-hud-persistent].app, [data-theme][id^=pf2e-hud-persistent] .app {
background: var(--app-background);
border: var(--app-border-width) solid var(--app-border-color);
text-shadow: var(--app-text-shadow);
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
color: var(--text-color-3);
}
[data-theme] #pf2e-hud-token-main:not(.exploded) .joined {
background: var(--app-background);
border: var(--app-border-width) solid var(--app-border-color);
text-shadow: var(--app-text-shadow);
Expand All @@ -2030,10 +2038,10 @@ body.compact-ui #navigation[data-theme] .monks-scene-navigation #nav-toggle {
place-items: center;
}
[data-theme]#pf2e-hud-sidebar .item-list {
backdrop-filter: blur(4px);
backdrop-filter: blur(5px);
}
[data-theme]#pf2e-hud-persistent-effects .effect-item:hover .effect-info {
backdrop-filter: blur(4px);
backdrop-filter: blur(5px);
}
[data-theme][data-theme^=bg3]#pf2e-hud-persistent-effects .effect-item .effect-info {
background: var(--bg3-tooltip-window-background) padding-box, linear-gradient(to right, var(--bg3-border-outer) 0%, var(--bg3-border-inner) 50%, var(--bg3-border-outer) 100%) border-box;
Expand Down Expand Up @@ -11459,12 +11467,12 @@ nav#controls[data-theme] ol.control-tools > li.toggle:disabled {
[data-theme^=discord].chat-message.whisper.blind .message-header {
color: var(--blind-bg) !important;
}
[data-theme^=discord].chat-message .message-header .header-meta.rolltype.blind {
color: var(--blind-bg);
}
[data-theme^=discord].chat-message .message-header .header-meta.rolltype.whisper {
[data-theme^=discord].chat-message .message-header .header-meta.whisper {
color: var(--whisper-bg);
}
[data-theme^=discord].chat-message .message-header .header-meta.blind {
color: var(--blind-bg);
}
[data-theme^=discord].chat-message .message-header,
[data-theme^=discord].chat-message .message-header h4 {
color: color-mix(in srgb, var(--player-color) 80%, white 20%) !important;
Expand Down Expand Up @@ -11921,13 +11929,13 @@ nav#controls[data-theme] ol.control-tools > li.toggle:disabled {
text-shadow: unset;
z-index: 1;
}
[data-theme^=dnd5e2].chat-message .message-header .header-meta.rolltype.blind {
background-color: var(--dnd5e-color-sc-2);
[data-theme^=dnd5e2].chat-message .message-header .header-meta.whisper {
background-color: var(--dnd5e-color-blue);
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5));
color: white;
}
[data-theme^=dnd5e2].chat-message .message-header .header-meta.rolltype.whisper {
background-color: var(--dnd5e-color-blue);
[data-theme^=dnd5e2].chat-message .message-header .header-meta.blind {
background-color: var(--dnd5e-color-sc-2);
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5));
color: white;
}
Expand Down Expand Up @@ -12941,13 +12949,13 @@ nav#controls[data-theme] ol.control-tools > li.toggle:disabled {
color: var(--bg3-text-1);
text-shadow: 0px 1px 1px black;
}
[data-theme^=bg3].message.chat-message .message-timestamp.rolltype.whisper,
[data-theme^=bg3].message.chat-message .header-meta.rolltype.whisper {
[data-theme^=bg3].message.chat-message .message-timestamp.whisper,
[data-theme^=bg3].message.chat-message .header-meta.whisper {
background-color: color-mix(in srgb, var(--bg3-alliance-companion-blue) 50%, transparent);
border-color: color-mix(in srgb, var(--bg3-alliance-companion-blue) 100%, rgba(255, 255, 255, 0.5));
}
[data-theme^=bg3].message.chat-message .message-timestamp.rolltype.blind,
[data-theme^=bg3].message.chat-message .header-meta.rolltype.blind {
[data-theme^=bg3].message.chat-message .message-timestamp.blind,
[data-theme^=bg3].message.chat-message .header-meta.blind {
background-color: color-mix(in srgb, var(--bg3-alliance-opposition-red) 50%, transparent);
border-color: color-mix(in srgb, var(--bg3-alliance-opposition-red) 100%, rgba(255, 255, 255, 0.5));
}
Expand Down Expand Up @@ -13463,15 +13471,15 @@ nav#controls[data-theme] ol.control-tools > li.toggle:disabled {
background: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.5);
}
[data-theme^=crb].chat-message .message-header .header-meta.rolltype.blind {
background-color: var(--dnd5e-color-sc-2);
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5));
color: white;
[data-theme^=crb].chat-message .message-header .header-meta.whisper {
background-color: var(--dnd5e-color-blue) !important;
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5)) !important;
color: white !important;
}
[data-theme^=crb].chat-message .message-header .header-meta.rolltype.whisper {
background-color: var(--dnd5e-color-blue);
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5));
color: white;
[data-theme^=crb].chat-message .message-header .header-meta.blind {
background-color: var(--dnd5e-color-sc-2) !important;
border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5)) !important;
color: white !important;
}
[data-theme^=crb].chat-message .card-content {
--app-border-color: var(--tertiary);
Expand Down Expand Up @@ -13780,16 +13788,16 @@ nav#controls[data-theme] ol.control-tools > li.toggle:disabled {
color: var(--text-color-1);
text-shadow: 0px 1px 1px black;
}
[data-theme=foundry2].message.chat-message .message-timestamp.blind,
[data-theme=foundry2].message.chat-message .header-meta.blind {
background-color: color-mix(in srgb, var(--blind-bg) 50%, transparent);
border: 1px solid color-mix(in srgb, var(--blind-bg) 66%, rgba(255, 255, 255, 0.5));
}
[data-theme=foundry2].message.chat-message .message-timestamp.whisper,
[data-theme=foundry2].message.chat-message .header-meta.whisper {
background-color: color-mix(in srgb, rgb(42, 113, 255) 33%, transparent);
border: 1px solid color-mix(in srgb, rgb(42, 113, 255) 50%, rgba(255, 255, 255, 0.5));
}
[data-theme=foundry2].message.chat-message .message-timestamp.blind,
[data-theme=foundry2].message.chat-message .header-meta.blind {
background-color: color-mix(in srgb, var(--blind-bg) 50%, transparent);
border: 1px solid color-mix(in srgb, var(--blind-bg) 66%, rgba(255, 255, 255, 0.5));
}
[data-theme=foundry2].window-app, [data-theme=foundry2].application {
backdrop-filter: blur(4px);
}
Expand Down
2 changes: 1 addition & 1 deletion styles/dorako-ui.css.map

Large diffs are not rendered by default.

0 comments on commit e6a9aa3

Please sign in to comment.