Skip to content

Commit

Permalink
2.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorako committed Oct 22, 2023
1 parent 5aad776 commit 330b0c7
Show file tree
Hide file tree
Showing 140 changed files with 13,540 additions and 12,935 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 2.11.0

- (Refactor) Massive internal refactor.
- (Refinement) Added Foundry 2 styling for Token Action HUD.
- (Refinement) Allowed certain header input fields to inherit height in Foundry 2 theme.
- (Fix) Fixed a regression where PF2e See Simple Scale Statistics labels would be colored in the default Dorako theme.

# 2.10.11

- (Refinement) Ensured that Jewel of Indigo Isles and World of Indigo Isles journals are excluded from styling.
Expand Down
4 changes: 0 additions & 4 deletions modules/consts.js → esmodules/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const baseThemeCoreFoundryApplications = ["ImagePopout","SceneControls",
// prettier-ignore
export const baseThemePf2eApplications = ["VehicleSheetPF2e","HotbarPF2e", "EffectsPanel", "SceneDarknessAdjuster"]; // "JournalSheetPF2e",
// prettier-ignore
// export const baseThemePf2eSheets = ["ItemSheet","ActorSheet","LootSheetPF2e"]; //"FamiliarSheetPF2e","HazardSheetPF2e"
export const baseThemePf2eSheets = ["KingdomSheetPF2e","CreatureSheetPF2e","PartySheetPF2e","SpellPreparationSheet","ItemSheet","NPCSheetPF2e","VehicleSheetPf2e","FamiliarSheetPF2e","HazardSheetPF2e", "CharacterSheetPF2e","LootSheetPF2e"]; //|| "ItemSheet","ActorSheet"

// prettier-ignore
Expand All @@ -37,9 +36,6 @@ export const premiumModuleSelector = ".pf2e-ii, .pf2e-woii, .seasonofghosts, .se
// SWPFSheet
// SWPFJournalSheet

// prettier-ignore
// export const premiumModuleIds = ["pf2e-beginner-box", "pf2e-abomination-vaults","pf2e-ap178-180-outlaws-of-alkenstar","pf2e-ap181-186-blood-lords", "pf2e-ap187-189-gatewalkers"];

// CLASSES
export class Avatar {
constructor(name, image) {
Expand Down
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions modules/chat-merge.js → esmodules/dorako-ux/chat-merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export default class ChatMerge {

static ready() {
const style = document.querySelector(":root").style;
style.setProperty("--dfce-cm-separation", this._separateWithBorder ? "" : "0");
this._showHover
? style.removeProperty("--dfce-cm-hover-shadow")
: style.setProperty("--dfce-cm-hover-shadow", "0px");
style.setProperty("--dfce-cm-header", this._showHeader ? "" : "none");
if (game.user.isGM) {
style.setProperty("--dfce-cm-header-delete", this._showHeader ? "" : "0");
style.setProperty("--dfce-cm-header-delete-pad", this._showHeader ? "" : "16px");
}
// style.setProperty("--dfce-cm-separation", this._separateWithBorder ? "" : "0");
// this._showHover
// ? style.removeProperty("--dfce-cm-hover-shadow")
// : style.setProperty("--dfce-cm-hover-shadow", "0px");
// style.setProperty("--dfce-cm-header", this._showHeader ? "" : "none");
// if (game.user.isGM) {
// style.setProperty("--dfce-cm-header-delete", this._showHeader ? "" : "0");
// style.setProperty("--dfce-cm-header-delete-pad", this._showHeader ? "" : "16px");
// }
this._processAllMessage(ui.chat.element);
Hooks.on("renderChatLog", (_, html) => this._processAllMessage(html));
}
Expand Down Expand Up @@ -115,7 +115,7 @@ export default class ChatMerge {
const messages = element.find("li.chat-message");
// Return if there are no messages rendered
if (messages.length === 0) return;
// Make sure to set the hover colour for the first message since we skip it in the processor bellow.
// Make sure to set the hover colour for the first message since we skip it in the processor below.
if (messages[0].hasAttribute("style")) {
messages[0].style.setProperty("--dfce-mc-border-color", messages[0].style.borderColor);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MODULE_NAME } from "./consts.js";
import { MODULE_NAME } from "../consts.js";

const ICONS_FOR_KNOWN_ROLL_TYPES = {
publicroll: "fas fa-dice-d20",
Expand Down Expand Up @@ -91,7 +91,7 @@ export default class ChatRollPrivacy {
html.find("select[name=rollMode]").after(buttonHtml);
html.find("select[name=rollMode]").remove();

const nonrolltype = $(`<div id="dorako-nonrt-buttons" class="buttons control-buttons"></div>`);
const nonrolltype = $(`<div id="dorako-nonrt-buttons" class="buttons flexrow control-buttons"></div>`);

html.find("#chat-controls div.control-buttons a").each(function () {
const html = $(this).html();
Expand Down
191 changes: 99 additions & 92 deletions modules/settings/settings.js → esmodules/dorako-ux/customization.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import * as util from "../util.js";
import { ThemeSettings } from "./theme-settings.js";
import { UXSettings } from "./ux-settings.js";
import { AvatarSettings } from "./avatar-settings.js";
import { MiscSettings } from "./misc-settings.js";
import { CustomizationSettings } from "./customization-settings.js";
import { ExternalModuleSettings } from "./external-module-settings.js";
import ChatMerge from "../chat-merge.js";
import ChatRollPrivacy from "../chat-rolltype-buttons.js";
import { MODULE_NAME } from "../consts.js";
import ChatMerge from "../dorako-ux/chat-merge.js";
import ChatRollPrivacy from "../dorako-ux/chat-rolltype-buttons.js";

function injectCSS(filename) {
const head = document.getElementsByTagName("head")[0];
Expand All @@ -18,95 +13,11 @@ function injectCSS(filename) {
head.insertBefore(mainCss, head.lastChild);
}

export function refreshChat() {
if (game.messages.size > 100) {
return ui.notifications.warn(game.i18n.localize("pf2e-dorako-ui.text.large-chatlog-warning"));
}
const messages = game.messages.filter((m) => m instanceof ChatMessage);
for (const message of messages) {
ui.chat.updateMessage(message);
}
}

Hooks.once("init", async () => {
util.debug("init");

game.settings.register("pf2e-dorako-ui", "mld-nag", {
scope: "world",
config: false,
default: true,
type: Boolean,
});

game.settings.register("pf2e-dorako-ui", "tah-nag", {
scope: "client",
config: false,
default: true,
type: Boolean,
});

game.settings.register("pf2e-dorako-ui", "migration-version", {
scope: "world",
config: false,
default: "0.0.0",
type: String,
});

ThemeSettings.registerSettings();
AvatarSettings.registerSettings();
UXSettings.registerSettings();
MiscSettings.registerSettings();
CustomizationSettings.registerSettings();
ExternalModuleSettings.registerSettings();

if (game.settings.get("pf2e-dorako-ui", "ux.chat-merge")) {
ChatMerge.init();
}

if (game.settings.get("pf2e-dorako-ui", "ux.adjust-chat-controls")) {
ChatRollPrivacy.setup();
ChatRollPrivacy.init();
}

const theme = game.settings.get("pf2e-dorako-ui", "theme.application-theme");
if (theme === "foundry2-theme") {
document.querySelector("#tooltip").classList.add("foundry2");
$("#tooltip").attr("data-theme", "foundry2");
$("#fps").attr("data-theme", "foundry2");
game.settings.set("pf2e-dorako-ui", "theme.chat-theme", "foundry2");
} else if (theme !== "no-theme") {
$("#tooltip").attr("data-theme", "dorako-ui");
$("#fps").attr("data-theme", "dorako-ui");
}

util.debug("registered settings");

injectCSS("dorako-ui");
injectCSS("module-support");
injectCSS("fonts");

const root = document.querySelector(":root").style;

root.setProperty("--avatar-size", game.settings.get("pf2e-dorako-ui", "avatar.size").toString() + "px");
root.setProperty("--border-radius", game.settings.get("pf2e-dorako-ui", "ux.border-radius").toString() + "px");
root.setProperty("--control-size", game.settings.get("pf2e-dorako-ui", "ux.control-size").toString() + "px");
root.setProperty("--controls-alignment", game.settings.get("pf2e-dorako-ui", "ux.controls-alignment").toString());

util.debug("initialized properties");
});

Hooks.once("ready", () => {
let dorakoCustomCss = document.createElement("style");
dorakoCustomCss.id = "dorako-custom-css";
dorakoCustomCss.innerHTML = game.settings.get("pf2e-dorako-ui", "customization.custom-css");
document.querySelector("head").appendChild(dorakoCustomCss);
// const userColor = Color.fromString(game.user.color);
// const whiteColor = Color.fromString("#ffffff");
// const blackColor = Color.fromString("#000000");

// document.querySelector(":root").style.setProperty("--secondary", userColor.css);
// document.querySelector(":root").style.setProperty("--secondary-light", userColor.mix(whiteColor, 0.2));
// document.querySelector(":root").style.setProperty("--secondary-dark", userColor.mix(blackColor, 0.2));
});

Hooks.once("ready", () => {
Expand Down Expand Up @@ -170,3 +81,99 @@ Hooks.once("renderSidebar", () => {
if (!noCards) return;
$(".item[data-tab=cards]").addClass("dorako-display-none");
});

Hooks.once("init", async () => {
util.debug(`${MODULE_NAME} | INIT`);
util.debug(`${MODULE_NAME} | REGISTERING SETTINGS`);
util.debug(`${MODULE_NAME} | INITIALIZING APPLICATIONS`);

if (game.settings.get("pf2e-dorako-ui", "ux.chat-merge")) {
ChatMerge.init();
}

if (game.settings.get("pf2e-dorako-ui", "ux.adjust-chat-controls")) {
ChatRollPrivacy.setup();
ChatRollPrivacy.init();
}

util.debug(`${MODULE_NAME} | INJECTING CSS`);

injectCSS("dorako-ux/dorako-ux");
injectCSS("fonts");

util.debug(`${MODULE_NAME} | INJECTING CSS VARIABLES`);

const root = document.querySelector(":root").style;

root.setProperty("--avatar-size", game.settings.get("pf2e-dorako-ui", "avatar.size").toString() + "px");
root.setProperty("--border-radius", game.settings.get("pf2e-dorako-ui", "ux.border-radius").toString() + "px");
root.setProperty("--control-size", game.settings.get("pf2e-dorako-ui", "ux.control-size").toString() + "px");
root.setProperty("--controls-alignment", game.settings.get("pf2e-dorako-ui", "ux.controls-alignment").toString());

util.debug(`${MODULE_NAME} | INIT COMPLETE`);
});

Hooks.once("ready", (app, html, data) => {
if (!game.settings.get(`${MODULE_NAME}`, "ux.start-sidebar-collapsed")) return;
ui.sidebar.collapse();
});

Hooks.once("ready", (app, html, data) => {
if (!game.settings.get(`${MODULE_NAME}`, "ux.start-navigation-collapsed")) return;
ui.nav.collapse();
});

Hooks.on("closeCombatDock", (app, html, data) => {
if (!game.settings.get(`${MODULE_NAME}`, "ux.compact-ui")) return;
ui.nav.expand();
});

Hooks.on("getItemSheetPF2eHeaderButtons", (sheet, buttons) => {
if (!game.settings.get(`${MODULE_NAME}`, "misc.send-to-chat")) {
return;
}

buttons.unshift({
label: i18n(`${MODULE_NAME}.text.send-to-chat`),
class: "send",
icon: "fas fa-comment-alt",
onclick: async () => {
if (sheet.document.actor) {
await sheet.document.toChat(); // Can post directly
} else {
const json = sheet.document.toJSON();
const actor =
canvas.tokens.controlled[0]?.actor ?? // Selected token's corresponding actor
game.user?.character ?? // Assigned actor
new Actor({ name: game.user.name, type: "character" }); // Dummy actor fallback

await new sheet.document.constructor(json, { parent: actor }).toChat();
}
},
});
});

Hooks.on("renderCombatTracker", addScalingToCombatTrackerAvatars);

function addScalingToCombatTrackerAvatars(app, html, data) {
const combatImagesActive = game.modules.get("combat-tracker-images")?.active;
$(".combatant", html).each(function () {
let id = this.dataset.combatantId;
let combatant = game.combat.combatants.get(id);
let scale = combatant.token.texture.scaleX;
let tokenImageElem = this.getElementsByClassName("token-image")[0];
if (scale < 1 || (combatImagesActive && combatant.actor.getFlag("combat-tracker-images", "trackerImage"))) {
scale = 1;
}
tokenImageElem.setAttribute("style", "transform: scale(" + Math.abs(scale) + ")");
});
}

for (const appName of ["JournalSheet", "JournalPageSheet"]) {
Hooks.on("render" + appName, (app, html, data) => {
const isDalvyn = game.settings.get("pf2e-dorako-ui", "misc.skin-crb-journal");
if (!isDalvyn) return;
if (app.id.includes("Compendium-pf2e-criticaldeck")) return;
html.closest(".app").find(".journal-entry-content").addClass("dorako-ui dalvyn-journal");
});
}
20 changes: 9 additions & 11 deletions modules/pixi.js → esmodules/dorako-ux/radial-condition-hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ function sizeToIconScale(size) {

function drawBG(effectIcon, background, gridScale) {
const r = effectIcon.width / 2;
const theme = game.settings.get("pf2e-dorako-ui", "theme.application-theme");
if (theme === "foundry2-theme") {
background.lineStyle((1 * gridScale) / 2, 0x302831, 1, 0);
background.drawCircle(effectIcon.position.x, effectIcon.position.y, r + 1 * gridScale);
background.beginFill(0x0b0a13);
background.drawCircle(effectIcon.position.x, effectIcon.position.y, r + 1 * gridScale);
background.endFill();
return;
}
background.lineStyle((1 * gridScale) / 2, 0x956d58, 1, 1);
background.drawCircle(effectIcon.position.x, effectIcon.position.y, r + 1 * gridScale);
background.lineStyle((1 * gridScale) / 2, 0xe9d7a1, 1, 0);
Expand All @@ -100,7 +109,6 @@ function drawBG(effectIcon, background, gridScale) {
function updateEffectScales(token) {
// if (token?.actor?.size == "sm") return;
const numEffects = countEffects(token);
// debugger;
if (numEffects > 0 && token.effects.children.length > 0) {
const background = token.effects.children[0];
if (!(background instanceof PIXI.Graphics)) return;
Expand All @@ -115,7 +123,6 @@ function updateEffectScales(token) {
// Reposition and scale them
effectIcons.forEach((effectIcon, i, effectIcons) => {
if (!(effectIcon instanceof PIXI.Sprite)) return;
// debugger;

effectIcon.anchor.set(0.5);

Expand All @@ -125,15 +132,6 @@ function updateEffectScales(token) {
updateIconSize(effectIcon, scaledSize);
updateIconPosition(effectIcon, i, effectIcons, token);
drawBG(effectIcon, background, gridScale);
// const myMask = new PIXI.Graphics()
// .beginFill(0xffffff, 0.001)
// .drawCircle(0, 0, Math.min(effectIcon.width, effectIcon.height) / 2)
// .endFill();
// myMask.x = effectIcon.x;
// myMask.y = effectIcon.y;
// effectIcon.mask = myMask;
// effectIcon.parent.addChild(myMask);
// debugger;
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MODULE_NAME } from "./consts.js";
import { MODULE_NAME } from "../consts.js";

const _poppedOutSizeDenominator = 1.5;

Expand Down Expand Up @@ -67,9 +67,9 @@ function _assignChatformResizer(chatform, poppedOut) {
function resize(e) {
newSize = Math.round(startSize + mouseStart - e.clientY);
if (newSize >= minSize) {
chatform.style.setProperty("--chatformHeight", `${newSize}px`);
chatform.style.setProperty("--chatform-height", `${newSize}px`);
} else {
chatform.style.setProperty("--chatformHeight", `${minSize}px`);
chatform.style.setProperty("--chatform-height", `${minSize}px`);
}
}

Expand Down Expand Up @@ -244,6 +244,6 @@ Hooks.on("renderChatLogPF2e", function (app, html, data) {
const storedChatformHeight = window.localStorage.getItem(key);
if (!storedChatformHeight) return;
if (Number.isInteger(+storedChatformHeight)) {
chatform[0].style.setProperty("--chatformHeight", `${storedChatformHeight}px`);
chatform[0].style.setProperty("--chatform-height", `${storedChatformHeight}px`);
}
});
Loading

0 comments on commit 330b0c7

Please sign in to comment.