diff --git a/.editorconfig b/.editorconfig index c23795f7..ab02da65 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,3 +5,7 @@ trim_trailing_whitespace=true insert_final_newline=true indent_style=tab indent_size=4 +# add space before curly brace in if statements +space_before_open_brace=all +# add space after if keyword +space_after_if=all diff --git a/dist/betteR20-5etools.user.js b/dist/betteR20-5etools.user.js index 9634c7d2..abcdf14c 100644 --- a/dist/betteR20-5etools.user.js +++ b/dist/betteR20-5etools.user.js @@ -1300,7 +1300,7 @@ function baseUtil () {

- betteR20 + betteR20 by 5etools

VTTES ${vttv} detected
${b20v} loaded

@@ -5183,7 +5183,7 @@ function baseToolUnlock () {

- +

@@ -8797,7 +8797,7 @@ function baseToolTable () {
- +
`, @@ -8845,7 +8845,7 @@ function baseToolTable () { "!import-table --Table-Name --show !import-table-item --Table-Name --Item One --1 -- !import-table-item --Table-Name --Item Two --1 -- -!import-table-item --Table-Name --Item Three (weighted more heavily) --5 --" +!import-table-item --Table-Name --Item Three (weighted more heavily) --5 --" class="table-import-textarea">`).appendTo($wrpClip); const $btnCheck = $(``).on("click", () => { const error = validatePaste($iptClip.val()); @@ -14179,7 +14179,7 @@ function baseMenu () { var d = t.height() , h = t.width() , p = {}; - + // BEGIN MOD // This block is pasted from newer version of roll20 Menu code, with appropriate changes to vars etc const r20ping = (u,i)=>{ @@ -18031,7 +18031,7 @@ function d20plusMod () { d20plus.mod.setAlpha = function (layer) { const l = ["map", "walls", "weather", "background", "objects", "foreground", "gmlayer"]; const o = ["background", "objects", "foreground"]; - return !window.is_gm + return !window.is_gm || (o.includes(layer) && o.includes(window.currentEditingLayer)) || (l.indexOf(window.currentEditingLayer) >= l.indexOf(layer) && !(o.includes(layer) && window.currentEditingLayer === "gmlayer")) @@ -77919,11 +77919,11 @@ EXT_LIB_API_SCRIPTS.push((function lib_script_23 () { /** * This is a small library for (mostly 2D) vector mathematics. * Internally, the vectors used by this library are simple arrays of numbers. - * The functions provided by this library do not alter the input vectors, + * The functions provided by this library do not alter the input vectors, * treating each vector as an immutable object. */ var VecMath = (function() { - + /** * Adds two vectors. * @param {vec} a @@ -77937,8 +77937,8 @@ var VecMath = (function() { } return result; }; - - + + /** * Creates a cloned copy of a vector. * @param {vec} v @@ -77951,10 +77951,10 @@ var VecMath = (function() { } return result; }; - - - /** - * Returns an array representing the cross product of two 3D vectors. + + + /** + * Returns an array representing the cross product of two 3D vectors. * @param {vec3} a * @param {vec3} b * @return {vec3} @@ -77965,9 +77965,9 @@ var VecMath = (function() { var z = a[0]*b[1] - a[1]*b[0]; return [x, y, z]; }; - - - /** + + + /** * Returns the degree of a vector - the number of dimensions it has. * @param {vec} vector * @return {int} @@ -77975,8 +77975,8 @@ var VecMath = (function() { var degree = function(vector) { return vector.length; }; - - + + /** * Computes the distance between two points. * @param {vec} pt1 @@ -77987,10 +77987,10 @@ var VecMath = (function() { var v = vec(pt1, pt2); return length(v); }; - - - /** - * Returns the dot product of two vectors. + + + /** + * Returns the dot product of two vectors. * @param {vec} a * @param {vec} b * @return {number} @@ -78002,21 +78002,21 @@ var VecMath = (function() { } return result; }; - - + + /** * Tests if two vectors are equal. * @param {vec} a * @param {vec} b - * @param {float} [tolerance] A tolerance threshold for comparing vector - * components. - * @return {boolean} true iff the each of the vectors' corresponding + * @param {float} [tolerance] A tolerance threshold for comparing vector + * components. + * @return {boolean} true iff the each of the vectors' corresponding * components are equal. */ var equal = function(a, b, tolerance) { if(a.length != b.length) return false; - + for(var i=0; i tolerance) { @@ -78028,11 +78028,11 @@ var VecMath = (function() { } return true; }; - - - - /** - * Returns the length of a vector. + + + + /** + * Returns the length of a vector. * @param {vec} vector * @return {number} */ @@ -78043,9 +78043,9 @@ var VecMath = (function() { } return Math.sqrt(length); }; - - - + + + /** * Computes the normalization of a vector - its unit vector. * @param {vec} v @@ -78053,16 +78053,16 @@ var VecMath = (function() { */ var normalize = function(v) { var vHat = []; - + var vLength = length(v); for(var i=0; i < v.length; i++) { vHat[i] = v[i]/vLength; } - + return vHat; }; - - + + /** * Computes the projection of vector b onto vector a. * @param {vec} a @@ -78072,13 +78072,13 @@ var VecMath = (function() { var projection = function(a, b) { var scalar = scalarProjection(a, b); var aHat = normalize(a); - + return scale(aHat, scalar); }; - - - /** - * Computes the distance from a point to an infinitely stretching line. + + + /** + * Computes the distance from a point to an infinitely stretching line. * Works for either 2D or 3D points. * @param {vec2 || vec3} pt * @param {vec2 || vec3} linePt1 A point on the line. @@ -78088,21 +78088,21 @@ var VecMath = (function() { var ptLineDist = function(pt, linePt1, linePt2) { var a = vec(linePt1, linePt2); var b = vec(linePt1, pt); - + // Make 2D vectors 3D to compute the cross product. if(!a[2]) a[2] = 0; if(!b[2]) b[2] = 0; - + var aHat = normalize(a); var aHatCrossB = cross(aHat, b); return length(aHatCrossB); }; - - - /** - * Computes the distance from a point to a line segment. + + + /** + * Computes the distance from a point to a line segment. * Works for either 2D or 3D points. * @param {vec2 || vec3} pt * @param {vec2 || vec3} linePt1 The start point of the segment. @@ -78113,24 +78113,24 @@ var VecMath = (function() { var a = vec(linePt1, linePt2); var b = vec(linePt1, pt); var aDotb = dot(a,b); - + // Is pt behind linePt1? if(aDotb < 0) { return length(vec(pt, linePt1)); } - + // Is pt after linePt2? else if(aDotb > dot(a,a)) { return length(vec(pt, linePt2)); } - + // Pt must be between linePt1 and linePt2. else { return ptLineDist(pt, linePt1, linePt2); } }; - - + + /** * Computes the scalar projection of b onto a. * @param {vec2} a @@ -78140,12 +78140,12 @@ var VecMath = (function() { var scalarProjection = function(a, b) { var aDotB = dot(a, b); var aLength = length(a); - + return aDotB/aLength; }; - - - + + + /** * Computes a scaled vector. * @param {vec2} v @@ -78154,15 +78154,15 @@ var VecMath = (function() { */ var scale = function(v, scalar) { var result = []; - + for(var i=0; i

- betteR20 + betteR20 by 5etools

VTTES ${vttv} detected
${b20v} loaded

@@ -4087,7 +4087,7 @@ function baseToolUnlock () {

- +

@@ -12696,7 +12696,7 @@ function baseMenu () { var d = t.height() , h = t.width() , p = {}; - + // BEGIN MOD // This block is pasted from newer version of roll20 Menu code, with appropriate changes to vars etc const r20ping = (u,i)=>{ @@ -16548,7 +16548,7 @@ function d20plusMod () { d20plus.mod.setAlpha = function (layer) { const l = ["map", "walls", "weather", "background", "objects", "foreground", "gmlayer"]; const o = ["background", "objects", "foreground"]; - return !window.is_gm + return !window.is_gm || (o.includes(layer) && o.includes(window.currentEditingLayer)) || (l.indexOf(window.currentEditingLayer) >= l.indexOf(layer) && !(o.includes(layer) && window.currentEditingLayer === "gmlayer")) @@ -40384,11 +40384,11 @@ EXT_LIB_API_SCRIPTS.push((function lib_script_7 () { /** * This is a small library for (mostly 2D) vector mathematics. * Internally, the vectors used by this library are simple arrays of numbers. - * The functions provided by this library do not alter the input vectors, + * The functions provided by this library do not alter the input vectors, * treating each vector as an immutable object. */ var VecMath = (function() { - + /** * Adds two vectors. * @param {vec} a @@ -40402,8 +40402,8 @@ var VecMath = (function() { } return result; }; - - + + /** * Creates a cloned copy of a vector. * @param {vec} v @@ -40416,10 +40416,10 @@ var VecMath = (function() { } return result; }; - - - /** - * Returns an array representing the cross product of two 3D vectors. + + + /** + * Returns an array representing the cross product of two 3D vectors. * @param {vec3} a * @param {vec3} b * @return {vec3} @@ -40430,9 +40430,9 @@ var VecMath = (function() { var z = a[0]*b[1] - a[1]*b[0]; return [x, y, z]; }; - - - /** + + + /** * Returns the degree of a vector - the number of dimensions it has. * @param {vec} vector * @return {int} @@ -40440,8 +40440,8 @@ var VecMath = (function() { var degree = function(vector) { return vector.length; }; - - + + /** * Computes the distance between two points. * @param {vec} pt1 @@ -40452,10 +40452,10 @@ var VecMath = (function() { var v = vec(pt1, pt2); return length(v); }; - - - /** - * Returns the dot product of two vectors. + + + /** + * Returns the dot product of two vectors. * @param {vec} a * @param {vec} b * @return {number} @@ -40467,21 +40467,21 @@ var VecMath = (function() { } return result; }; - - + + /** * Tests if two vectors are equal. * @param {vec} a * @param {vec} b - * @param {float} [tolerance] A tolerance threshold for comparing vector - * components. - * @return {boolean} true iff the each of the vectors' corresponding + * @param {float} [tolerance] A tolerance threshold for comparing vector + * components. + * @return {boolean} true iff the each of the vectors' corresponding * components are equal. */ var equal = function(a, b, tolerance) { if(a.length != b.length) return false; - + for(var i=0; i tolerance) { @@ -40493,11 +40493,11 @@ var VecMath = (function() { } return true; }; - - - - /** - * Returns the length of a vector. + + + + /** + * Returns the length of a vector. * @param {vec} vector * @return {number} */ @@ -40508,9 +40508,9 @@ var VecMath = (function() { } return Math.sqrt(length); }; - - - + + + /** * Computes the normalization of a vector - its unit vector. * @param {vec} v @@ -40518,16 +40518,16 @@ var VecMath = (function() { */ var normalize = function(v) { var vHat = []; - + var vLength = length(v); for(var i=0; i < v.length; i++) { vHat[i] = v[i]/vLength; } - + return vHat; }; - - + + /** * Computes the projection of vector b onto vector a. * @param {vec} a @@ -40537,13 +40537,13 @@ var VecMath = (function() { var projection = function(a, b) { var scalar = scalarProjection(a, b); var aHat = normalize(a); - + return scale(aHat, scalar); }; - - - /** - * Computes the distance from a point to an infinitely stretching line. + + + /** + * Computes the distance from a point to an infinitely stretching line. * Works for either 2D or 3D points. * @param {vec2 || vec3} pt * @param {vec2 || vec3} linePt1 A point on the line. @@ -40553,21 +40553,21 @@ var VecMath = (function() { var ptLineDist = function(pt, linePt1, linePt2) { var a = vec(linePt1, linePt2); var b = vec(linePt1, pt); - + // Make 2D vectors 3D to compute the cross product. if(!a[2]) a[2] = 0; if(!b[2]) b[2] = 0; - + var aHat = normalize(a); var aHatCrossB = cross(aHat, b); return length(aHatCrossB); }; - - - /** - * Computes the distance from a point to a line segment. + + + /** + * Computes the distance from a point to a line segment. * Works for either 2D or 3D points. * @param {vec2 || vec3} pt * @param {vec2 || vec3} linePt1 The start point of the segment. @@ -40578,24 +40578,24 @@ var VecMath = (function() { var a = vec(linePt1, linePt2); var b = vec(linePt1, pt); var aDotb = dot(a,b); - + // Is pt behind linePt1? if(aDotb < 0) { return length(vec(pt, linePt1)); } - + // Is pt after linePt2? else if(aDotb > dot(a,a)) { return length(vec(pt, linePt2)); } - + // Pt must be between linePt1 and linePt2. else { return ptLineDist(pt, linePt1, linePt2); } }; - - + + /** * Computes the scalar projection of b onto a. * @param {vec2} a @@ -40605,12 +40605,12 @@ var VecMath = (function() { var scalarProjection = function(a, b) { var aDotB = dot(a, b); var aLength = length(a); - + return aDotB/aLength; }; - - - + + + /** * Computes a scaled vector. * @param {vec2} v @@ -40619,15 +40619,15 @@ var VecMath = (function() { */ var scale = function(v, scalar) { var result = []; - + for(var i=0; iX`) @@ -929,8 +931,9 @@ const betteR205etoolsMain = function () { })); throw new Error("No character sheet selected!"); } - if (d20.journal.customSheets.layouthtml.indexOf("shaped_d20") > 0) d20plus.sheet = "shaped"; - if (d20.journal.customSheets.layouthtml.indexOf("DnD5e_Character_Sheet") > 0) d20plus.sheet = "community"; + const firstSheet = d20.journal.customSheets ?? sheets.first(); + if (firstSheet.layouthtml.includes("shaped_d20")) d20plus.sheet = "shaped"; + if (firstSheet.layouthtml.includes("DnD5e_Character_Sheet")) d20plus.sheet = "community"; d20plus.ut.log(`Switched Character Sheet Template to ${d20plus.sheet}`); }; diff --git a/js/5etools-template.js b/js/5etools-template.js index f24146dd..e07a3903 100644 --- a/js/5etools-template.js +++ b/js/5etools-template.js @@ -93,27 +93,29 @@ const d20plusTemplate = function () { } d20plus.template5e._populateAdventuresDropdown = function () { - const defaultAdvUrl = d20plus.formSrcUrl(ADVENTURE_DATA_DIR, "adventure-lmop.json"); - const $iptUrl = $("#import-adventures-url"); - $iptUrl.val(defaultAdvUrl); - $iptUrl.data("id", "lmop"); - const $sel = $("#button-adventures-select"); - adventureMetadata.adventure.forEach(a => { + if (adventureMetadata.adventure){ + const defaultAdvUrl = d20plus.formSrcUrl(ADVENTURE_DATA_DIR, "adventure-lmop.json"); + const $iptUrl = $("#import-adventures-url"); + $iptUrl.val(defaultAdvUrl); + $iptUrl.data("id", "lmop"); + const $sel = $("#button-adventures-select"); + adventureMetadata.adventure.forEach(a => { + $sel.append($("