Skip to content

Commit

Permalink
Merge branch 'release/0.5.13' into main
Browse files Browse the repository at this point in the history
caewok committed Feb 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 167fc69 + 2f53195 commit 9451d01
Showing 14 changed files with 63 additions and 1,942 deletions.
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.5.13
Tweaks so elevation measurement works with Elevation Ruler.
Fix for manual elevation change failing when autoelevate tokens is enabled. Closes issue #105.
Fix for #104 (cannot see over walls). Fixes shadows incorrectly sized because point source elevations were getting set to 0 incorrectly.
Fix for Color Picker registration failing, causing setting elevation to fail. Closes issue #107.
Update geometry lib to 0.2.17.

## 0.5.12
Fix terrain wall shadow leakage when walls are in a "V." Closes issue #95, but unfortunately causes the terrain walls to lose their penumbra with sized light sources. See issue #103. This is preferable to shadow leakage because the penumbra is a subtle visual-only effect.

2 changes: 1 addition & 1 deletion scripts/ElevationLayer.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ ui,
"use strict";

import { MODULE_ID, FLAGS } from "./const.js";
import { PixelCache } from "./PixelCache.js";
import { PixelCache } from "./geometry/PixelCache.js";
import {
log,
readDataURLFromFile,
14 changes: 5 additions & 9 deletions scripts/ModuleSettingsAbstract.js
Original file line number Diff line number Diff line change
@@ -16,13 +16,12 @@ PATCHES.BASIC = {};
/**
* Wipe the settings cache on update
*/
function updateSetting(document, change, options, userId) { // eslint-disable-line no-unused-vars
const [module, ...arr] = document.key.split(".");
const key = arr.join("."); // If the key has periods, multiple will be returned by split.
if ( module === MODULE_ID && Settings.cache.has(key) ) Settings.cache.delete(key);
async function set(wrapper, namespace, key, value, options) {
if ( namespace === MODULE_ID ) ModuleSettingsAbstract.cache.delete(key);
return wrapper(namespace, key, value, options);
}

PATCHES.BASIC.HOOKS = { updateSetting };
PATCHES.BASIC.WRAPS = { set };

export class ModuleSettingsAbstract {
/** @type {Map<string, *>} */
@@ -64,10 +63,7 @@ export class ModuleSettingsAbstract {
* @param {*} value
* @returns {Promise<boolean>}
*/
static async set(key, value) {
this.cache.delete(key);
return game.settings.set(MODULE_ID, key, value);
}
static async set(key, value) { return game.settings.set(MODULE_ID, key, value); }

static async toggle(key) {
const curr = this.get(key);
38 changes: 31 additions & 7 deletions scripts/Patcher.js
Original file line number Diff line number Diff line change
@@ -131,6 +131,7 @@ export class Patcher {
isStatic: typeName.includes("STATIC") };
switch ( typeName ) {
case "HOOKS": patchCl = HookPatch; break;

case "STATIC_OVERRIDES": // eslint-disable-line no-fallthrough
case "OVERRIDES":
case "STATIC_MIXES":
@@ -142,10 +143,20 @@ export class Patcher {
? libWrapper.OVERRIDE : typeName.includes("MIXES")
? libWrapper.MIXED : libWrapper.WRAPPER;
break;
case "STATIC_GETTERS": // eslint-disable-line no-fallthrough

case "STATIC_GETTERS": // eslint-disable-line no-fallthrough
case "GETTERS":
cfg.isGetter = true;
default: // eslint-disable-line no-fallthrough
patchCl = MethodPatch;
break;

case "STATIC_SETTERS": // eslint-disable-line no-fallthrough
case "SETTERS":
cfg.isSetter = true;
patchCl = MethodPatch;
break;

default:
patchCl = MethodPatch;
}
const thePatch = patchCl.create(patchName, patch, cfg);
@@ -166,11 +177,20 @@ export class Patcher {
* @param {boolean} [opts.optional] True if the getter should not be set if it already exists.
* @returns {undefined|object<id{string}} Either undefined if the getter already exists or the cl.prototype.name.
*/
static addClassMethod(cl, name, fn, { getter = false, optional = false } = {}) {
static addClassMethod(cl, name, fn, { getter = false, setter = false, optional = false } = {}) {
if ( optional && Object.hasOwn(cl, name) ) return undefined;
const descriptor = { configurable: true };
if ( getter ) descriptor.get = fn;
else {

// For getters and setters, keep the getter when creating a setter and vice-versa
if ( getter ) {
descriptor.get = fn;
const currentSetter = Object.getOwnPropertyDescriptor(cl, name)?.set;
if ( currentSetter ) descriptor.set = currentSetter;
} else if ( setter ) {
descriptor.set = fn;
const currentGetter = Object.getOwnPropertyDescriptor(cl, name)?.get;
if ( currentGetter ) descriptor.get = currentGetter;
} else {
descriptor.writable = true;
descriptor.value = fn;
}
@@ -351,6 +371,9 @@ export class MethodPatch extends AbstractPatch {
}

cfg.isGetter = Boolean(config.isGetter);
cfg.isSetter = Boolean(config.isSetter);
if ( cfg.isGetter && cfg.isSetter ) console.warn("Patcher|Getter and Setter both true; you probably only want 1 at a time!");

cfg.isStatic = Boolean(config.isStatic);
this.cl = config.className;
}
@@ -374,9 +397,10 @@ export class MethodPatch extends AbstractPatch {

this.prevMethod = Object.getOwnPropertyDescriptor(this.#cl, this.target);
if ( this.config.isGetter ) this.prevMethod = this.prevMethod?.get;
else if ( this.config.isSetter ) this.prevMethod = this.prevMethod?.set;
else this.prevMethod = this.prevMethod?.value;

this.regId = Patcher.addClassMethod(this.#cl, this.target, this.patchFn, { getter: this.config.isGetter });
this.regId = Patcher.addClassMethod(this.#cl, this.target, this.patchFn, { getter: this.config.isGetter, setter: this.config.isSetter });
}

/**
@@ -388,7 +412,7 @@ export class MethodPatch extends AbstractPatch {

// Add back the original, if any.
if ( this.prevMethod ) {
Patcher.addClassMethod(this.#cl, this.target, this.prevMethod, { getter: this.config.isGetter });
Patcher.addClassMethod(this.#cl, this.target, this.prevMethod, { getter: this.config.isGetter, setter: this.config.isSetter });
this.prevMethod = undefined;
}
this.regId = undefined;
Loading

0 comments on commit 9451d01

Please sign in to comment.