Skip to content

Commit

Permalink
1.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorako committed Oct 27, 2022
1 parent 9f62a55 commit 86360d7
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.7.4

Added feature to combine weapon attack rolls with damage rolls visually.

# 1.7.3

Added feature that makes action cost more prominent, and restructures spells to be more easily readable.
Expand Down
3 changes: 3 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
"dorako-ui.settings.restructure-card-info.name": "Restructure chat card info?",
"dorako-ui.settings.restructure-card-info.hint": "Makes action-cost for features more apparent, and moves spell info out of the footer",

"dorako-ui.settings.combine-attack-and-damage-roll-messages.name": "Combine attack and damage roll messages?",
"dorako-ui.settings.combine-attack-and-damage-roll-messages.hint": "Makes damage roll messages take up less space by visually combining them with the attack",

"dorako-ui.settings.compact-ui.name": "Enable Compact UI?",
"dorako-ui.settings.compact-ui.hint": "Resizes controls, and hides inactive controls and navigation elements unless hovered",

Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"flags": {}
}
],
"version": "1.7.3",
"version": "1.7.4",
"compatibility": {
"minimum": "10",
"verified": "10"
Expand Down Expand Up @@ -59,6 +59,6 @@
],
"styles": ["styles/fonts.css"],
"scripts": ["scripts/dorako-ui.js"],
"download": "https://github.com/Dorako/pf2e-dorako-ui/archive/refs/tags/v1.7.3.zip",
"download": "https://github.com/Dorako/pf2e-dorako-ui/archive/refs/tags/v1.7.4.zip",
"manifest": "https://github.com/Dorako/pf2e-dorako-ui/releases/latest/download/module.json"
}
67 changes: 60 additions & 7 deletions scripts/dorako-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ function titleCase(string) {
}

function getActionGlyph(actionCost) {
if (actionCost === "1 to 3") return "1 / 2 / 3";
if (actionCost === "1 or 2") return "1 / 2";
if (actionCost === "2 or 3") return "2 / 3";
if (actionCost.type == "action") {
return actionCost.value;
} else if (actionCost.type == "reaction") return "R";
else if (actionCost.type == "free") return "F";
else return "";
else return actionCost;
}

// function cleanHTML() {
Expand Down Expand Up @@ -219,7 +222,7 @@ Hooks.on("renderChatMessage", (chatMessage, html, messageData) => {

// console.log("renderChatMessage Hook");
// console.log("chatMessage");
// console.log(chatMessage);
console.log(chatMessage);
// console.log("html");
// console.log(html);
// console.log("messageData");
Expand Down Expand Up @@ -268,6 +271,46 @@ Hooks.on("renderChatMessage", (chatMessage, html, messageData) => {
themeHeader(html, chatMessage);
});

// Combine attack and damage rolls from same source
Hooks.on("renderChatMessage", (chatMessage, html, messageData) => {
if (!game.settings.get("pf2e-dorako-ui", "combine-attack-and-damage-roll-messages")) return;

if (chatMessage.flags["narrator-tools"]) {
return;
}

if (chatMessage?.isDamageRoll) {
const chatLength = game.messages?.contents.length ?? 0;
const mostRecent = game.messages?.contents[chatLength - 2];
const isDamageAfterAttack = mostRecent?.flags?.pf2e?.context?.type === "attack-roll";
if (isDamageAfterAttack) {
const mostRecentSource = mostRecent?.flags?.pf2e?.origin?.uuid ?? "a";
const currentSource = chatMessage?.flags?.pf2e?.origin?.uuid ?? "b";
const isSameSource = mostRecentSource === currentSource;
if (isSameSource) {
html[0].classList.add("dorako-damage-roll");
let header = html.find(".message-header")[0];
header.remove();
let tags = html.find(".tags")[1];
let flavorText = html.find(".flavor-text")[0];
flavorText.innerHTML = tags.outerHTML;
}
}
}
});

Hooks.on("renderChatMessage", (chatMessage, html, messageData) => {
if (!game.settings.get("pf2e-dorako-ui", "combine-attack-and-damage-roll-messages")) return;

if (chatMessage.flags["narrator-tools"]) {
return;
}

if (chatMessage?.flags?.pf2e?.context?.type === "attack-roll") {
html[0].classList.add("dorako-attack-roll");
}
});

Hooks.on("preCreateChatMessage", (message) => {
addAvatarsToFlags(message);

Expand Down Expand Up @@ -359,20 +402,18 @@ function spellComponentsToText(components) {

function injectSpellInfo(html, spell) {
if (!spell) return;
// console.log(spell);
let messageHeader = html.find(".card-content")[0];
let spellInfo = document.createElement("div");
spellInfo.classList.add("spell-info");
console.log(spell);

// Cast info
let castInfo = document.createElement("p");
let castInfoLabel = document.createElement("strong");
castInfoLabel.textContent = i18n("PF2E.SpellCostLabel") + " ";
let castTime = document.createElement("span");
castTime.textContent = spell?.system?.time?.value;
if (spell?.system?.time?.value.length == 1) {
castTime.classList.add("pf2-icon");
}
castTime.textContent = getActionGlyph(spell?.system?.time?.value);
castTime.classList.add("pf2-icon");
let castComponents = document.createElement("span");
castComponents.textContent = spellComponentsToText(spell?.system?.components);
castInfo.append(castInfoLabel);
Expand Down Expand Up @@ -1086,6 +1127,18 @@ Hooks.once("init", async () => {
},
});

game.settings.register("pf2e-dorako-ui", "combine-attack-and-damage-roll-messages", {
name: i18n("dorako-ui.settings.combine-attack-and-damage-roll-messages.name"),
hint: i18n("dorako-ui.settings.combine-attack-and-damage-roll-messages.hint"),
scope: "world",
type: Boolean,
default: true,
config: true,
onChange: () => {
debouncedReload();
},
});

game.settings.register("pf2e-dorako-ui", "compact-ui", {
name: i18n("dorako-ui.settings.compact-ui.name"),
hint: i18n("dorako-ui.settings.compact-ui.hint"),
Expand Down
20 changes: 12 additions & 8 deletions styles/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,6 @@



#chat-log .message {
margin: 0px;
}

.dice-roll .dice-formula {
margin-bottom: 3px;
Expand Down Expand Up @@ -375,18 +372,15 @@ button {
}
*/

#chat-log>.chat-message {
margin-top: 0px;
}

/* #chat-log>.chat-message:not(.dfce-cm-middle, .dfce-cm-bottom) {
margin-top: 10px;
} */

#chat-log>.message {
border: 5px solid red;
.message {
box-shadow: var(--gold-and-glow);
border: none;
margin-top: 0px;
margin-left: 3px;
margin-right: 3px;
}
Expand Down Expand Up @@ -1737,4 +1731,14 @@ span[data-pf2-check].with-repost {

.pf2e.chat-card .card-header h4 span.heightened {
color: green;
}


.chat-message.dorako-damage-roll .message-content {
padding: 2px 5px 5px 5px;
}

.chat-message.dorako-damage-roll {
border-radius: 0px 0px 5px 5px;
margin-top: -13px;
}

0 comments on commit 86360d7

Please sign in to comment.