Skip to content

Commit

Permalink
1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorako committed Nov 5, 2022
1 parent 86360d7 commit 67bc3f4
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 336 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 1.8.0

Fixed visual styling of Narrator Tools and Alpha Suit modules in the Controls.

Fixed effect tooltip going off-screen when using modules that increase the tooltip size.

Fixed nat 1/20 color support of inline rolls.

Fixed display of action cost for spells with cast time in minutes.

Removed combine-attacks-and-damage-rolls feature, instead improved support for DF Chat Enhancement's chat merge functionality. I recommend setting the combine setting to 'any'.

Removed TAH theme (or rather, made it simply add a gap). Use the 'Dorako UI' style option in TAH.

# 1.7.4

Added feature to combine weapon attack rolls with damage rolls visually.
Expand Down
1 change: 1 addition & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"dorako-ui.settings.skin-combat-tracker.name": "Theme combat tracker?",
"dorako-ui.settings.skin-custom-hotbar.name": "Theme Custom Hotbar module?",
"dorako-ui.settings.skin-token-action-hud.name": "Theme Token Action HUD module?",
"dorako-ui.settings.skin-token-action-hud.hint": "Enable the 'Dorako UI' style in TAH.",
"dorako-ui.settings.skin-window-controls.name": "Theme Window Controls module?",
"dorako-ui.settings.skin-combat-carousel.name": "Theme Combat Carousel module?",
"dorako-ui.settings.skin-dice-tray.name": "Theme Dice Tray module?",
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.4",
"version": "1.8.0",
"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.4.zip",
"download": "https://github.com/Dorako/pf2e-dorako-ui/archive/refs/tags/v1.8.0.zip",
"manifest": "https://github.com/Dorako/pf2e-dorako-ui/releases/latest/download/module.json"
}
185 changes: 126 additions & 59 deletions scripts/dorako-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ function titleCase(string) {
return string[0].toUpperCase() + string.slice(1).toLowerCase();
}

// second return value is whether the first value can be styled as pf2e-icon
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 === "1 to 3") return ["1 / 2 / 3", true];
if (actionCost === "1 or 2") return ["1 / 2", true];
if (actionCost === "2 or 3") return ["2 / 3", true];
if (actionCost.type == "action") {
return actionCost.value;
} else if (actionCost.type == "reaction") return "R";
else if (actionCost.type == "free") return "F";
else return actionCost;
return [actionCost.value, true];
} else if (actionCost.type == "reaction") return ["R", true];
else if (actionCost.type == "free") return ["F", true];
else return [actionCost, false];
}

// function cleanHTML() {
Expand Down Expand Up @@ -222,7 +223,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 @@ -271,45 +272,109 @@ 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;
// // 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.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;
}
}
}
});
// const chatLength = game.messages?.contents.length ?? 0;
// if (chatLength <= 1) return;
// if (chatMessage?.isDamageRoll) {
// let recentIndex = -2;
// let mostRecent = game.messages?.contents.at(recentIndex);
// while (
// mostRecent?.flags?.["pf2-flat-check"] ||
// mostRecent?.flags?.["pf2e-flat-check"] ||
// mostRecent?.flags?.["pf2e-ranged-combat"]
// ) {
// recentIndex -= 1;
// mostRecent = game.messages?.contents.at(recentIndex);
// }
// 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];
// if (header) header.classList.add("dorako-display-none");
// let tags = html.find(".tags")[0];
// if (tags) tags.remove();

// // 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;
// 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["narrator-tools"]) {
// return;
// }

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

// 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;

// const chatLength = game.messages?.contents.length ?? 0;
// if (chatLength <= 2) return;
// let mostRecent2 = game.messages?.contents.at(-2); // -1 is newest, -2 should be 'one earlier', not sure why -3 is needed for it to work
// let mostRecent3 = game.messages?.contents.at(-3); // -1 is newest, -2 should be 'one earlier', not sure why -3 is needed for it to work
// // console.log({ mostRecent2 });
// // console.log({ mostRecent3 });
// const mostRecentIsAttack =
// mostRecent2?.flags?.pf2e?.context?.type === "attack-roll" ||
// mostRecent3?.flags?.pf2e?.context?.type === "attack-roll";
// // console.log({ mostRecentIsAttack });
// const isFlatCheck = chatMessage?.flags?.["pf2-flat-check"] || chatMessage?.flags?.["pf2e-flat-check"];
// // console.log({ isFlatCheck });

// if (isFlatCheck && mostRecentIsAttack) {
// html[0].classList.add("dorako-flat-check");
// let header = html.find(".message-header")[0];
// if (header) header.classList.add("dorako-display-none");
// }
// });

// 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;

// const chatLength = game.messages?.contents.length ?? 0;
// if (chatLength <= 4) return;
// let mostRecent2 = game.messages?.contents.at(-2); // -1 is newest, -2 should be 'one earlier', not sure why -3 is needed for it to work
// let mostRecent3 = game.messages?.contents.at(-3); // -1 is newest, -2 should be 'one earlier', not sure why -3 is needed for it to work
// let mostRecent4 = game.messages?.contents.at(-4); // -1 is newest, -2 should be 'one earlier', not sure why -3 is needed for it to work

// // console.log({ mostRecent2 });
// // console.log({ mostRecent3 });
// const mostRecentIsAttack =
// mostRecent2?.flags?.pf2e?.context?.type === "attack-roll" ||
// mostRecent3?.flags?.pf2e?.context?.type === "attack-roll" ||
// mostRecent4?.flags?.pf2e?.context?.type === "attack-roll";

// // console.log({ mostRecentIsAttack });
// const isRangedCombat = chatMessage?.flags?.["pf2e-ranged-combat"];
// // console.log({ isRangedCombat });

// if (isRangedCombat && mostRecentIsAttack) {
// html[0].classList.add("dorako-ranged-combat");
// let header = html.find(".message-header")[0];
// if (header) header.classList.add("dorako-display-none");
// }
// });

Hooks.on("preCreateChatMessage", (message) => {
addAvatarsToFlags(message);
Expand Down Expand Up @@ -370,13 +435,13 @@ function injectAvatar(html, avatar) {

function injectActionCost(html, actionCost) {
if (!actionCost) return;
const actionGlyph = getActionGlyph(actionCost);
const [actionGlyph, shouldBeStyled] = getActionGlyph(actionCost);
if (!actionGlyph) return;

// console.log("Injecting actionGlyph %s", actionGlyph);
let messageHeader = html.find(".card-header")[0];
let actionGlyphText = document.createElement("h3");
actionGlyphText.classList.add("pf2-icon");
if (shouldBeStyled) actionGlyphText.classList.add("pf2-icon");
actionGlyphText.textContent = actionGlyph;
messageHeader.append(actionGlyphText);
}
Expand Down Expand Up @@ -405,15 +470,16 @@ function injectSpellInfo(html, spell) {
let messageHeader = html.find(".card-content")[0];
let spellInfo = document.createElement("div");
spellInfo.classList.add("spell-info");
console.log(spell);
// 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 = getActionGlyph(spell?.system?.time?.value);
castTime.classList.add("pf2-icon");
const [cost, shouldBeGlyph] = getActionGlyph(spell?.system?.time?.value);
castTime.textContent = cost;
if (shouldBeGlyph) castTime.classList.add("pf2-icon");
let castComponents = document.createElement("span");
castComponents.textContent = spellComponentsToText(spell?.system?.components);
castInfo.append(castInfoLabel);
Expand Down Expand Up @@ -507,7 +573,7 @@ function injectSpellInfo(html, spell) {

// Footer
let footer = html.find(".card-footer")[0];
footer.remove();
if (footer) footer.classList.add("dorako-display-none");

messageHeader.prepend(hr);
messageHeader.prepend(spellInfo);
Expand Down Expand Up @@ -1127,17 +1193,17 @@ 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", "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"),
Expand Down Expand Up @@ -1316,6 +1382,7 @@ Hooks.once("init", async () => {

game.settings.register("pf2e-dorako-ui", "skin-token-action-hud", {
name: i18n("dorako-ui.settings.skin-token-action-hud.name"),
hint: i18n("dorako-ui.settings.skin-token-action-hud.hint"),
scope: "world",
type: Boolean,
default: true,
Expand Down
25 changes: 22 additions & 3 deletions styles/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ message-content .chat-damage-buttons button {
.message a.content-link,
.message a.inline-roll {
text-shadow: none;
color: black;
/* color: black; */
border-radius: 3px;
text-shadow: none;
width: fit-content;
Expand Down Expand Up @@ -1238,11 +1238,15 @@ table.pf2-table td, table.pf2-table th {
background-position: left 0px top -100px;
}

#chat-log .message.dfce-cm-middle .message-header,
#chat-log .message.dfce-cm-bottom .message-header {
#chat-log .message.dfce-cm-middle .message-header .portrait-and-name,
#chat-log .message.dfce-cm-bottom .message-header .portrait-and-name {
display: none;
}

.dfce-cm-middle .message-delete, .dfce-cm-bottom .message-delete {
top: 5px;
}

.chat-message .message-header .message-sender {
display: flex;
flex-wrap: wrap;
Expand Down Expand Up @@ -1738,7 +1742,22 @@ span[data-pf2-check].with-repost {
padding: 2px 5px 5px 5px;
}

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

.chat-message.dorako-flat-check .message-content {
padding-bottom: 8px;
}

.chat-message.dorako-ranged-combat,
.chat-message.dorako-flat-check,
.chat-message.dorako-damage-roll {
border-radius: 0px 0px 5px 5px;
margin-top: -13px;
}

.chat-message.dorako-ranged-combat p.action-content {
margin-top: 0px;
}
5 changes: 5 additions & 0 deletions styles/controls.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
background-image: none;
}

#controls ol.control-tools>li.toggle,
#controls ol li.control-tool.toggle,
#controls .app li,
#controls ol li,
Expand Down Expand Up @@ -111,12 +112,15 @@
/* backdrop-filter: var(--dorako-vibrancy-active); */
}

#controls ol.control-tools>li.toggle,
#controls ol li.control-tool.toggle,
#controls ol.sub-controls .control-tool.toggle {
background-color: var(--paizo-blue-dark);
/* backdrop-filter: var(--dorako-vibrancy); */
}

#controls ol.control-tools>li.toggle:hover,
#controls ol.control-tools>li.toggle.active:hover,
#controls ol li.control-tool.toggle:hover,
#controls ol li.control-tool.toggle.active:hover,
#controls ol.sub-controls .control-tool.toggle:hover,
Expand All @@ -125,6 +129,7 @@
/* backdrop-filter: var(--dorako-vibrancy-active) var(--dorako-vibrancy-active); */
}

#controls ol.control-tools>li.toggle.active,
#controls ol li.control-tool.toggle.active,
#controls ol.sub-controls .control-tool.toggle.active {
background-color: var(--paizo-blue-bright);
Expand Down
Loading

0 comments on commit 67bc3f4

Please sign in to comment.