diff --git a/CHANGELOG.md b/CHANGELOG.md index 12ae27c..87d7301 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/languages/en.json b/languages/en.json index a4352fc..1294377 100644 --- a/languages/en.json +++ b/languages/en.json @@ -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", diff --git a/module.json b/module.json index 151ca5b..743709d 100644 --- a/module.json +++ b/module.json @@ -12,7 +12,7 @@ "flags": {} } ], - "version": "1.7.3", + "version": "1.7.4", "compatibility": { "minimum": "10", "verified": "10" @@ -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" } diff --git a/scripts/dorako-ui.js b/scripts/dorako-ui.js index fb952ff..c66c87d 100644 --- a/scripts/dorako-ui.js +++ b/scripts/dorako-ui.js @@ -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() { @@ -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"); @@ -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); @@ -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); @@ -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"), diff --git a/styles/chat.css b/styles/chat.css index f9010ed..3114f4a 100644 --- a/styles/chat.css +++ b/styles/chat.css @@ -334,9 +334,6 @@ -#chat-log .message { - margin: 0px; -} .dice-roll .dice-formula { margin-bottom: 3px; @@ -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; } @@ -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; } \ No newline at end of file