Skip to content

Commit

Permalink
2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorako committed Jul 19, 2023
1 parent 3ffb6b7 commit 1a35c92
Show file tree
Hide file tree
Showing 18 changed files with 486 additions and 79 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.3.0

- (Module) Added support for PF2e Utility Buttons (formerly flatcheck-helper)
- (New) :pacman:'d the Sidebar Resizer module, with some improvements to functionality
- (Refinement) Updated the jump-to chatlog button to be more visible, and is now properly centered even on wider chatlogs

# 2.2.5

- (SWADE) Fix a regression causing non-journal application windows to not be tagged as "premium" and thus render with incorrect backgrounds
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,9 @@ Besides the theme, Dorako UI also has a bunch of UI-adjacent features, including
- Got a nitpicky feature request that isn't already a setting?

Dorako UI's custom settings menu allows you to configure the theme to your liking.

## Licenses & Attributions

This code is available under the MIT license, see LICENSE.

The sidebar resizing functionality has been adapted from [Sidebar Resizer](https://github.com/saif-ellafi/foundryvtt-sidebar-resizer) also available under the MIT license.
6 changes: 0 additions & 6 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@
"name": "UX Settings",
"label": "Configure UX Settings",
"hint": "Configure settings related to showing, hiding, making UI less obstructive or clearer, moving stuff to different locations",

"chat-input-height": {
"name": "Chatbox height",
"hint": "Foundry default is approx 100px",
"CGMPhint": "Foundry default is approx 100px; Note that with Cautious Gamemaster's Pack's \"Notify Typing\" setting enabled, the notification eats at most 60px of the height of the chatbox"
},
"restructure-card-info": {
"name": "Restructure chat card info?",
"hint": "Makes action-cost for features more apparent, and moves spell info out of the footer"
Expand Down
14 changes: 5 additions & 9 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@
],
"flags": {
"hotReload": {
"extensions": [
".css",
".json"
]
"extensions": [".css", ".json"]
}
},
"languages": [
Expand Down Expand Up @@ -100,9 +97,7 @@
"path": "languages/pl.json"
}
],
"styles": [
"styles/fonts.css"
],
"styles": ["styles/fonts.css"],
"esmodules": [
"modules/misc-hooks.js",
"modules/settings/settings.js",
Expand All @@ -111,11 +106,12 @@
"modules/message-hooks.js",
"modules/premium-module-hooks.js",
"modules/consts.js",
"modules/pixi.js"
"modules/pixi.js",
"modules/sidebar-resizer.js"
],
"changelog": "https://github.com/Dorako/pf2e-dorako-ui/blob/master/CHANGELOG.md",
"download": "https://github.com/Dorako/pf2e-dorako-ui/archive/refs/tags/v1.11.3.zip",
"manifest": "https://github.com/Dorako/pf2e-dorako-ui/releases/latest/download/module.json",
"readme": "https://github.com/Dorako/pf2e-dorako-ui",
"bugs": "https://github.com/Dorako/pf2e-dorako-ui/issues"
}
}
12 changes: 6 additions & 6 deletions modules/base-theme-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ Hooks.on("renderTokenActionHUD", (app, html, data) => {
// reconsider logic
if (game.modules.get("token-action-hud")?.active && game.settings.get("token-action-hud", "style") === "dorakoUI") {
let html0 = html[0];
console.debug(`${MODULE_NAME} | render${app.constructor.name} => add .dorako-ui`);
console.debug(`${MODULE_NAME} | render${app.constructor.name} => add .dorako-ui`);
html0.classList.add("dorako-ui");
return;
}
console.debug(`${MODULE_NAME} | render${app.constructor.name} but style !== "dorakoUI" => do not add .dorako-ui`);
console.debug(`${MODULE_NAME} | render${app.constructor.name} but style !== "dorakoUI" => do not add .dorako-ui`);
});

// Add .dorako-ui to all .dialog applications
Expand All @@ -82,10 +82,10 @@ Hooks.on("renderDialog", (app, html, data) => {
console.debug(`${MODULE_NAME} | render${app.constructor.name} | pushing .dorako-ui class option`);
// console.debug({ app });
app.options?.classes?.push("dorako-ui");
// let position = app.position;
// position.height += 6;
// position.width += 6;
// app.setPosition(position);
let position = app.position;
position.height += 6;
position.width += 6;
app.setPosition(position);
app.render();
});

Expand Down
24 changes: 0 additions & 24 deletions modules/settings/ux-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export class UXSettings extends SettingsMenuDorakoUI {
static namespace = "ux";

static SETTINGS = [
"chat-input-height",
"restructure-card-info",
"no-cards",
"no-chat-control-icon",
Expand Down Expand Up @@ -50,29 +49,6 @@ export class UXSettings extends SettingsMenuDorakoUI {
config: true,
requiresReload: true,
},
"chat-input-height": {
name: "pf2e-dorako-ui.settings.ux.chat-input-height.name",
hint: game.modules.get("CautiousGamemastersPack")?.active
? "pf2e-dorako-ui.settings.ux.chat-input-height.CGMPhint"
: "pf2e-dorako-ui.settings.ux.chat-input-height.hint",
scope: "client",
type: Number,
default: 90,
range: {
min: 20,
max: 300,
step: 5,
},
config: true,
requiresReload: false,
onChange: (value) => {
const root = document.querySelector(":root").style;
root.setProperty(
"--chat-input-height",
game.settings.get("pf2e-dorako-ui", "ux.chat-input-height").toString() + "px"
);
},
},
"restructure-card-info": {
name: "pf2e-dorako-ui.settings.ux.restructure-card-info.name",
hint: "pf2e-dorako-ui.settings.ux.restructure-card-info.hint",
Expand Down
224 changes: 224 additions & 0 deletions modules/sidebar-resizer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
const _poppedOutSizeDenominator = 1.5;

function _assignSidebarResizer(sidebar) {
let minSize = 300;
let mouseStart, startSize, newSize;

// Create a resizer handle
const resizer = document.createElement("div");
resizer.classList.add("dorako-resize");
sidebar.appendChild(resizer);

// Listen for mousedown on resizer
resizer.addEventListener("mousedown", startResize, false);

// React to user resizing
function startResize(e) {
if (ui.sidebar._collapsed) return;
mouseStart = e.clientX;
startSize = sidebar.offsetWidth;
window.addEventListener("mousemove", resize, false);
window.addEventListener("mouseup", stopResize, false);
}

// Perform the resize operation
function resize(e) {
newSize = Math.round(startSize + mouseStart - e.clientX);
if (newSize >= minSize) {
sidebar.style.setProperty("--sidebarWidth", `${newSize}px`);
} else {
sidebar.style.setProperty("--sidebarWidth", `${minSize}px`);
}
}

// On mouseup remove listeners & save final size
function stopResize(e) {
window.localStorage.setItem("pf2e-dorako-ui.sidebar-width", sidebar.offsetWidth);
window.removeEventListener("mousemove", resize, false);
window.removeEventListener("mouseup", stopResize, false);
}
}

function _assignChatformResizer(chatform, poppedOut) {
let minSize = 50;
let mouseStart, startSize, newSize;

// Create a resizer handle
const resizer = document.createElement("div");
resizer.classList.add("dorako-resize");
chatform.prepend(resizer);

// Listen for mousedown on resizer
resizer.addEventListener("mousedown", startResize, false);

// React to user resizing
function startResize(e) {
if (!poppedOut && ui.sidebar._collapsed) return;
mouseStart = e.clientY;
startSize = chatform.offsetHeight;
window.addEventListener("mousemove", resize, false);
window.addEventListener("mouseup", stopResize, false);
}

// Perform the resize operation
function resize(e) {
newSize = Math.round(startSize + mouseStart - e.clientY);
if (newSize >= minSize) {
chatform.style.setProperty("--chatformHeight", `${newSize}px`);
} else {
chatform.style.setProperty("--chatformHeight", `${minSize}px`);
}
}

// On mouseup remove listeners & save final size
function stopResize(e) {
const key = `pf2e-dorako-ui.${poppedOut ? "popped-out-" : ""}chatform-height`;
window.localStorage.setItem(key, chatform.offsetHeight);
window.removeEventListener("mousemove", resize, false);
window.removeEventListener("mouseup", stopResize, false);
}
}

Hooks.once("ready", function () {
// Setup vars
const sidebar = ui.sidebar.element[0];
const chatform = $(ui.chat.element[0]).find("#chat-form")[0];
_assignSidebarResizer(sidebar);
if (!chatform) return;

// Enable Chat popout Resize
if (game.modules.get("lib-wrapper")?.active) {
libWrapper.register(
"pf2e-dorako-ui",
"ChatLog.defaultOptions",
function (wrapped, ...args) {
let result = wrapped(...args);
result.resizable = true;
result.height = parseInt($("#board").css("height")) / _poppedOutSizeDenominator;
const storedSidebarWidth = window.localStorage.getItem("pf2e-dorako-ui.sidebar-width");
if (storedSidebarWidth && Number.isInteger(+storedSidebarWidth)) result.width = parseInt(storedSidebarWidth);
return result;
},
"WRAPPER"
);
libWrapper.register(
"pf2e-dorako-ui",
"CombatTracker.defaultOptions",
function (wrapped, ...args) {
let result = wrapped(...args);
result.resizable = true;
result.height = parseInt($("#board").css("height")) / _poppedOutSizeDenominator;
return result;
},
"WRAPPER"
);
libWrapper.register(
"pf2e-dorako-ui",
"SceneDirectory.defaultOptions",
function (wrapped, ...args) {
let result = wrapped(...args);
result.resizable = true;
result.height = parseInt($("#board").css("height")) / _poppedOutSizeDenominator;
return result;
},
"WRAPPER"
);
libWrapper.register(
"pf2e-dorako-ui",
"ActorDirectory.defaultOptions",
function (wrapped, ...args) {
let result = wrapped(...args);
result.resizable = true;
result.height = parseInt($("#board").css("height")) / _poppedOutSizeDenominator;
return result;
},
"WRAPPER"
);
libWrapper.register(
"pf2e-dorako-ui",
"ItemDirectory.defaultOptions",
function (wrapped, ...args) {
let result = wrapped(...args);
result.resizable = true;
result.height = parseInt($("#board").css("height")) / _poppedOutSizeDenominator;
return result;
},
"WRAPPER"
);
libWrapper.register(
"pf2e-dorako-ui",
"RollTableDirectory.defaultOptions",
function (wrapped, ...args) {
let result = wrapped(...args);
result.resizable = true;
result.height = parseInt($("#board").css("height")) / _poppedOutSizeDenominator;
return result;
},
"WRAPPER"
);
libWrapper.register(
"pf2e-dorako-ui",
"CardsDirectory.defaultOptions",
function (wrapped, ...args) {
let result = wrapped(...args);
result.resizable = true;
result.height = parseInt($("#board").css("height")) / _poppedOutSizeDenominator;
return result;
},
"WRAPPER"
);
libWrapper.register(
"pf2e-dorako-ui",
"PlaylistDirectory.defaultOptions",
function (wrapped, ...args) {
let result = wrapped(...args);
result.resizable = true;
result.height = parseInt($("#board").css("height")) / _poppedOutSizeDenominator;
return result;
},
"WRAPPER"
);
libWrapper.register(
"pf2e-dorako-ui",
"CompendiumDirectory.defaultOptions",
function (wrapped, ...args) {
let result = wrapped(...args);
result.resizable = true;
result.height = parseInt($("#board").css("height")) / _poppedOutSizeDenominator;
return result;
},
"WRAPPER"
);
} else {
console.warn(`${MODULE_NAME} | libwrapper not enabled, resizing of popped-out sidebars will be limited`);
}
});

// Sidebar width
Hooks.once("renderSidebarTab", function () {
const storedSidebarWidth = window.localStorage.getItem("pf2e-dorako-ui.sidebar-width");
if (!storedSidebarWidth) return;
if (Number.isInteger(+storedSidebarWidth)) {
const sidebar = document.querySelector("#sidebar");
sidebar.style.setProperty("--sidebarWidth", `${storedSidebarWidth}px`);
}
});

// Chat-form height
Hooks.on("renderChatLogPF2e", function (app, html, data) {
if (!app?.options?.classes?.includes("chat-sidebar") ?? true) return;
let poppedOut = undefined;
if (app?.options?.classes?.includes("sidebar-popout")) {
poppedOut = true;
}

const chatform = html.find("#chat-form");
if (!chatform) return;
_assignChatformResizer(chatform[0], poppedOut);
const key = `pf2e-dorako-ui.${poppedOut ? "popped-out-" : ""}chatform-height`;
const storedChatformHeight = window.localStorage.getItem(key);
if (!storedChatformHeight) return;
if (Number.isInteger(+storedChatformHeight)) {
chatform[0].style.setProperty("--chatformHeight", `${storedChatformHeight}px`);
}
});
2 changes: 1 addition & 1 deletion sass/foundry/_application-dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
@include sheet;
color: var(--color-text-light-heading);
}
.dorako-ui.light-theme.journal-entry-content {
.dorako-ui.light-theme:not(.premium) .journal-entry-content {
--color-text-dark-primary: #191813;
color: var(--color-text-dark-primary);
}
Expand Down
Loading

0 comments on commit 1a35c92

Please sign in to comment.