Skip to content

Commit

Permalink
v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorako committed Jul 18, 2022
1 parent 2ba9e54 commit 685a327
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 49 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.4.0

Made the 'pop out' portrait scaling work for tokens of different scaling factors.
Added some padding for the 'X is typing' feature from Cautious Gamemaster's Pack, and unbroke the animation.

This patch features a regression as well - the zoom-chat-portraits-on-hover feature lives no more. Better alternatives exist for showing creature art.

# 1.3.29

Implemented feature that allows for 'pop out' tokens to have 'pop out' chat portraits. Can be disabled in settings.
Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"description": "Overhauls the Foundry UI and several modules.",
"url": "https://github.com/Dorako/pf2e-dorako-ui",
"author": "Dorako",
"version": "1.3.29",
"version": "1.4.0",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9",
"system": ["pf2e"],
"scripts": ["scripts/dorako-ui.js"],
"templates": ["templates/*"],
"download": "https://github.com/Dorako/pf2e-dorako-ui/archive/refs/tags/v1.3.29.zip",
"download": "https://github.com/Dorako/pf2e-dorako-ui/archive/refs/tags/v1.4.0.zip",
"manifest": "https://github.com/Dorako/pf2e-dorako-ui/raw/main/module.json"
}
97 changes: 57 additions & 40 deletions scripts/dorako-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,57 @@ Hooks.once("init", async function () {
}
});

Handlebars.registerHelper("getTokenScale", function (message) {
const border = game.settings.get("pf2e-dorako-ui", "chat-portrait-border");
const popoutTokenPortraits = game.settings.get(
"pf2e-dorako-ui",
"popout-token-portraits"
);
if (!border && popoutTokenPortraits) {
const tk = canvas.tokens?.get(message.speaker.token);
const scale = tk?.data.scale ?? 1;
return scale;
}
return 1;
});

Handlebars.registerHelper("isTokenPortrait", function (message) {
let combatantImg;
let actorImg;
let tokenImg;

const speaker = message.speaker;
if (speaker) {
if (speaker.token) {
tokenImg = game.scenes.get(speaker.scene)?.tokens?.get(speaker.token)
?.data.img;
}
if (speaker.actor) {
const actor = Actors.instance.get(speaker.actor);
combatantImg = combatImagesActive
? actor.getFlag("combat-tracker-images", "trackerImage")
: null;
actorImg = actor?.data.img;
}
}

let result = "";
const main = game.settings.get("pf2e-dorako-ui", "insertSpeakerImage");
if (main === "token") {
result =
(combatantImg ? "combatant" : "") ||
(tokenImg ? "token" : "") ||
(actorImg ? "actor" : "");
}
if (main === "actor") {
result =
(combatantImg ? "combatant" : "") ||
(actorImg ? "actor" : "") ||
(tokenImg ? "token" : "");
}
return result == "token";
});

Handlebars.registerHelper("determineImageKind", function (message) {
let combatantImg;
let actorImg;
Expand Down Expand Up @@ -218,26 +269,21 @@ Hooks.once("init", async function () {
if (!border && popoutTokenPortraits) {
const tk = canvas.tokens?.get(message.speaker.token);
const scale = tk?.data.scale;
if (scale >= game.settings.get("pf2e-dorako-ui", "popout-token-portraits-scale")) {
sizeClass = "scale-up ";
}
}

const main = game.settings.get("pf2e-dorako-ui", "insertSpeakerImage");
if (main === "token") {
return (
sizeClass +
((combatantImg ? "combatant" : "") ||
(tokenImg ? "token" : "") ||
(actorImg ? "actor" : ""))
(combatantImg ? "combatant" : "") ||
(tokenImg ? "token" : "") ||
(actorImg ? "actor" : "")
);
}
if (main === "actor") {
return (
sizeClass +
((combatantImg ? "combatant" : "") ||
(actorImg ? "actor" : "") ||
(tokenImg ? "token" : ""))
(combatantImg ? "combatant" : "") ||
(actorImg ? "actor" : "") ||
(tokenImg ? "token" : "")
);
}
return "no-img";
Expand Down Expand Up @@ -498,23 +544,6 @@ Hooks.once("init", async function () {
debouncedReload();
},
});

game.settings.register("pf2e-dorako-ui", "popout-token-portraits-scale", {
name: "Chat portrait token popout scale",
hint: "Set the minimum threshold for the token scale to be 'popped out' of the chat portraits.",
scope: "client",
type: Number,
default: 1.5,
range: {
min: 0.2,
max: 3,
step: 0.1,
},
config: true,
onChange: () => {
debouncedReload();
},
});

game.settings.register("pf2e-dorako-ui", "chat-portrait-border", {
name: "... and add a border?",
Expand All @@ -528,18 +557,6 @@ Hooks.once("init", async function () {
},
});

game.settings.register("pf2e-dorako-ui", "chat-portrait-hover", {
name: "... and make portraits larger on hover?",
hint: "Works best if you mouse-over from the left.",
scope: "client",
config: true,
default: false,
type: Boolean,
onChange: () => {
debouncedReload();
},
});

game.settings.register("pf2e-dorako-ui", "chat-input-height", {
name: "Chatbox height",
scope: "client",
Expand Down
6 changes: 0 additions & 6 deletions styles/chat-portrait-hover.css

This file was deleted.

8 changes: 8 additions & 0 deletions styles/sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ nav.damage-log-nav.tabs {
} */

/* CGP */
#cgmp-typing-notify {
padding: 3px;
}

#cgmp-typing-notify.hidden {
padding: 0px;
}

#cgmp-typing-notify.hidden>* {
display: none;
}
6 changes: 5 additions & 1 deletion templates/base-chat-message.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
{{#if (showSpeakerImage message)}}
<div class="portrait-and-name" style="display: flex; gap:5px">
<div class="portrait-wrapper">
<img class="portrait {{determineImageKind message}}" src="{{getSpeakerImage message}}" />
{{#if (isTokenPortrait message)}}
<img class="portrait {{determineImageKind message}}" src="{{getSpeakerImage message}}" style="transform: scale({{getTokenScale message}})"/>
{{else}}
<img class="portrait {{determineImageKind message}}" src="{{getSpeakerImage message}}"/>
{{/if}}
</div>
{{/if}}
<div class="sender-wrapper">
Expand Down

0 comments on commit 685a327

Please sign in to comment.