From db86231a9d9222becebcf354e01376a64ee4f3ac Mon Sep 17 00:00:00 2001 From: Dorako Date: Sat, 16 Jul 2022 21:29:41 +0200 Subject: [PATCH] 1.3.29 --- module.json | 4 +- scripts/dorako-ui.js | 150 ++++++++++++++++++------------------------- styles/chat.css | 10 ++- styles/no-logo.css | 2 +- 4 files changed, 69 insertions(+), 97 deletions(-) diff --git a/module.json b/module.json index bc9ccc2..b7d5ef2 100644 --- a/module.json +++ b/module.json @@ -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.28", + "version": "1.3.29", "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.28.zip", + "download": "https://github.com/Dorako/pf2e-dorako-ui/archive/refs/tags/v1.3.29.zip", "manifest": "https://github.com/Dorako/pf2e-dorako-ui/raw/main/module.json" } diff --git a/scripts/dorako-ui.js b/scripts/dorako-ui.js index 6f798f8..a8cc194 100644 --- a/scripts/dorako-ui.js +++ b/scripts/dorako-ui.js @@ -209,19 +209,35 @@ Hooks.once("init", async function () { } } + let sizeClass = ""; + 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; + if (scale >= 1.5) { + sizeClass = "scale-up "; + } + } + const main = game.settings.get("pf2e-dorako-ui", "insertSpeakerImage"); if (main === "token") { return ( - (combatantImg ? "combatant" : "") || - (tokenImg ? "token" : "") || - (actorImg ? "actor" : "") + sizeClass + + ((combatantImg ? "combatant" : "") || + (tokenImg ? "token" : "") || + (actorImg ? "actor" : "")) ); } if (main === "actor") { return ( - (combatantImg ? "combatant" : "") || - (actorImg ? "actor" : "") || - (tokenImg ? "token" : "") + sizeClass + + ((combatantImg ? "combatant" : "") || + (actorImg ? "actor" : "") || + (tokenImg ? "token" : "")) ); } return "no-img"; @@ -238,8 +254,17 @@ Hooks.once("init", async function () { "hideGmIconWhenSecret" ); + const hidePortraitWhenHidden = game.settings.get( + "pf2e-dorako-ui", + "hidePortraitWhenHidden" + ); + if (chatPortraitSetting === "none") return false; + const tk = canvas.tokens?.get(message.speaker.token); + const isHidden = tk?.data.hidden; + if (hidePortraitWhenHidden && isHidden) return false; + const whisperTargets = message.whisper; const isBlind = message.blind || false; @@ -423,7 +448,7 @@ Hooks.once("init", async function () { game.settings.register("pf2e-dorako-ui", "hideGmIconWhenSecret", { name: "Hide chat portrait when secret?", - hint: "Hide the chat portrait whenever GM rolls secret/private rolls.", + hint: "Hides the chat portrait whenever GM rolls secret/private rolls.", scope: "world", config: true, default: true, @@ -433,9 +458,21 @@ Hooks.once("init", async function () { }, }); + game.settings.register("pf2e-dorako-ui", "hidePortraitWhenHidden", { + name: "Hide chat portrait when token hidden?", + hint: "Hides the chat portrait whenever the token of the speaker is hidden", + scope: "client", + type: Boolean, + default: true, + config: true, + onChange: () => { + debouncedReload(); + }, + }); + game.settings.register("pf2e-dorako-ui", "chat-portrait-size", { name: "Chat portrait size", - hint: "Suggested size of 36px.", + hint: "Suggested size of 40px.", scope: "client", type: Number, default: 40, @@ -450,6 +487,18 @@ Hooks.once("init", async function () { }, }); + game.settings.register("pf2e-dorako-ui", "popout-token-portraits", { + name: "Chat portrait token popout", + hint: "Scales the chat portraits of BB/AV-style tokens to allow for 'pop out'.", + scope: "client", + type: Boolean, + default: true, + config: true, + onChange: () => { + debouncedReload(); + }, + }); + game.settings.register("pf2e-dorako-ui", "chat-portrait-border", { name: "... and add a border?", hint: "Disable if your token art is fancy.", @@ -589,23 +638,6 @@ Hooks.once("init", async function () { }, }); - // game.settings.register("pf2e-dorako-ui", "primary-color", { - // name: "Primary color overwrite", - // hint: "Default is Red", - // scope: "client", - // config: true, - // type: String, - // default: "#FF0000", - // onChange: () => refresh() - // }); - - // const colorInput = window.document.createElement("input"); - // colorInput.setAttribute("type", "color"); - // colorInput.setAttribute("value", html.find(`input[name="primary-color"]`).val()); - // colorInput.setAttribute("data-edit", `${prefix}.monoVisionColor`); - - // html.find(`input[name="${prefix}.monoVisionColor"]`).after(colorInput); - game.settings.register("pf2e-dorako-ui", "disable-all-styles", { name: "Disable all styles?", hint: "Ignore all the toggles and removes any effect of the module, without having to disable it.", @@ -837,8 +869,6 @@ Hooks.once("init", async function () { "--edge-margin", game.settings.get("pf2e-dorako-ui", "edge-offset").toString() + "px" ); - // var sheet = document.styleSheets[0]; - // sheet.insertRule(":root{--chat-portrait-size: "+game.settings.get('pf2e-dorako-ui', 'chat-portrait-size').toString()+'px}'); root.setProperty( "--chat-portrait-size", @@ -876,11 +906,11 @@ Hooks.once("init", async function () { injectCSS("dice-tray"); let headerStyle = game.settings.get("pf2e-dorako-ui", "headerStyle"); if (headerStyle == "tint" || headerStyle == "red") { - enableRedHeader(); + injectCSS("header-red"); } else if (headerStyle == "blue") { - enableBlueHeader(); + injectCSS("header-blue"); } else if (headerStyle == "none") { - // padding-bottom: 0px; + // do nothing } if (game.settings.get("pf2e-dorako-ui", "skin-combat-carousel")) @@ -890,9 +920,9 @@ Hooks.once("init", async function () { if (theme == "light") { // do nothing } else if (theme == "dark") { - enableDarkTheme(); + injectCSS("chat-dark"); } else if (theme == "rainbow") { - enableRainbowTheme(); + injectCSS("chat-rainbow"); } setting = game.settings.get("pf2e-dorako-ui", "rolltype-indication"); if (setting == "both" || setting == "bg-color") @@ -910,7 +940,6 @@ Hooks.once("init", async function () { if (setting == "dark" || setting == "darkRedHeader") injectCSS("familiar-sheet-dark"); if (setting == "darkRedHeader") injectCSS("familiar-sheet-dark-red-header"); - // if (setting == "plain") injectCSS("sheet-plain"); } }); @@ -933,58 +962,3 @@ function injectCSS(filename) { mainCss.setAttribute("media", "all"); head.insertBefore(mainCss, head.lastChild); } - -function injectBaseCss() { - const head = document.getElementsByTagName("head")[0]; - const mainCss = document.createElement("link"); - mainCss.setAttribute("rel", "stylesheet"); - mainCss.setAttribute("type", "text/css"); - mainCss.setAttribute("href", "modules/pf2e-dorako-ui/styles/dorako-ui.css"); - mainCss.setAttribute("media", "all"); - head.insertBefore(mainCss, head.lastChild); -} - -// Chat cards -function enableRedHeader() { - const head = document.getElementsByTagName("head")[0]; - const newCss = document.createElement("link"); - newCss.setAttribute("rel", "stylesheet"); - newCss.setAttribute("type", "text/css"); - newCss.setAttribute("href", "modules/pf2e-dorako-ui/styles/header-red.css"); - newCss.setAttribute("media", "all"); - head.insertBefore(newCss, head.lastChild); -} - -function enableBlueHeader() { - const head = document.getElementsByTagName("head")[0]; - const newCss = document.createElement("link"); - newCss.setAttribute("rel", "stylesheet"); - newCss.setAttribute("type", "text/css"); - newCss.setAttribute("href", "modules/pf2e-dorako-ui/styles/header-blue.css"); - newCss.setAttribute("media", "all"); - head.insertBefore(newCss, head.lastChild); -} - -function enableDarkTheme() { - const head = document.getElementsByTagName("head")[0]; - const newCss = document.createElement("link"); - newCss.setAttribute("rel", "stylesheet"); - newCss.setAttribute("type", "text/css"); - newCss.setAttribute("href", "modules/pf2e-dorako-ui/styles/chat-dark.css"); - newCss.setAttribute("media", "all"); - head.insertBefore(newCss, head.lastChild); -} - -function enableRainbowTheme() { - const head = document.getElementsByTagName("head")[0]; - const newCss = document.createElement("link"); - newCss.setAttribute("rel", "stylesheet"); - newCss.setAttribute("type", "text/css"); - newCss.setAttribute("href", "modules/pf2e-dorako-ui/styles/chat-rainbow.css"); - newCss.setAttribute("media", "all"); - head.insertBefore(newCss, head.lastChild); -} - -//const actor = game.scenes.get(speaker.scene)?.tokens?.get(speaker.token); -// const tokens = actor.getActiveTokens(true, false); -// const token = tokens.first(); diff --git a/styles/chat.css b/styles/chat.css index 04cce58..5935b41 100644 --- a/styles/chat.css +++ b/styles/chat.css @@ -407,13 +407,7 @@ button { } .message .message-header .message-sender { - /* font-size: small; - font-weight: 400; */ - grid-: sender; - /* align-items: center; */ display: flex; - - /* border-radius: 5px 0px 0px 0px; */ } @@ -668,6 +662,10 @@ message-content .chat-damage-buttons button { border-radius: 3px; } +.portrait.token.scale-up { + transform: scale(1.5); +} + /* Adds border around flavor text */ /* .flavor-text { diff --git a/styles/no-logo.css b/styles/no-logo.css index 6e1e7d2..e216ca6 100644 --- a/styles/no-logo.css +++ b/styles/no-logo.css @@ -1,3 +1,3 @@ #logo { - display: none; + display: none !important; } \ No newline at end of file