-
Notifications
You must be signed in to change notification settings - Fork 48
Fix/jumpgate load #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Fix/jumpgate load #189
Changes from 3 commits
7d63140
32ca746
c4b2558
0e301be
e1c00df
9981b08
56c9541
de4cf08
df2f559
98b48d4
43d29b5
0f6c2fc
6f489cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -313,7 +313,7 @@ const betteR205etoolsMain = function () { | |
| {name: "bestiary index", url: `${MONSTER_DATA_DIR}index.json`}, | ||
| {name: "bestiary fluff index", url: `${MONSTER_DATA_DIR}fluff-index.json`}, | ||
| {name: "bestiary metadata", url: `${MONSTER_DATA_DIR}legendarygroups.json`}, | ||
| {name: "adventures index", url: `${DATA_URL}adventures.json`}, | ||
| // {name: "adventures index", url: `${DATA_URL}adventures.json`}, // error retrieving from 5e.tools | ||
| {name: "base items", url: `${DATA_URL}items-base.json`}, | ||
| {name: "item modifiers", url: `${DATA_URL}roll20-items.json`}, | ||
| ]; | ||
|
|
@@ -906,7 +906,8 @@ const betteR205etoolsMain = function () { | |
| d20plus.setSheet = function () { | ||
| d20plus.ut.log("Switched Character Sheet Template"); | ||
| d20plus.sheet = "ogl"; | ||
| if (window.is_gm && (!d20.journal.customSheets || !d20.journal.customSheets)) { | ||
| const sheets = d20.journal.customSheets ?? d20.journal.characterSheetsManager.getAllSheets(); | ||
| if (window.is_gm && sheets.length < 1) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nah, wanted to avoid the concept where length property did not exist. this clearly denotes its expecting an array since the jumpgate now stores sheets in an array (roll20 supports more than 1 sheet type for campaign now) i'm not too attached to format
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. certainly isn't clear enough for me to understand what's going on, so, would appreciate a revision to make it more explicit; you're saying you're relying on if
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i see. yes, they are 2 fundamentally different ways to provide sheets. 1 is an array 1 is 1 item in a non existent array |
||
| const $body = $(`body`); | ||
| $body.addClass("ve-nosheet__body"); | ||
| const $btnClose = $(`<button class="btn btn-danger ve-nosheet__btn-close">X</button>`) | ||
|
|
@@ -929,8 +930,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(); | ||
|
TheGiddyLimit marked this conversation as resolved.
|
||
| if (firstSheet.layouthtml.indexOf("shaped_d20") > 0) d20plus.sheet = "shaped"; | ||
| if (firstSheet.layouthtml.indexOf("DnD5e_Character_Sheet") > 0) d20plus.sheet = "community"; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while you're here,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sweet i like it |
||
| d20plus.ut.log(`Switched Character Sheet Template to ${d20plus.sheet}`); | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this smells like a hack due to disabling the adventure index load..? Or is there some other purpose
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if u want to call it a hack. if there is no result from the adventures list it will still cause the rest of the load to break when other features are still functional which sounds unnecessary |
||
| 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($("<option>", { | ||
| value: d20plus.formSrcUrl(ADVENTURE_DATA_DIR, `adventure-${a.id.toLowerCase()}.json|${a.id}`), | ||
| text: a.name, | ||
| })); | ||
| }); | ||
| $sel.append($("<option>", { | ||
| value: d20plus.formSrcUrl(ADVENTURE_DATA_DIR, `adventure-${a.id.toLowerCase()}.json|${a.id}`), | ||
| text: a.name, | ||
| value: "", | ||
| text: "Custom", | ||
| })); | ||
| }); | ||
| $sel.append($("<option>", { | ||
| value: "", | ||
| text: "Custom", | ||
| })); | ||
| $sel.val(defaultAdvUrl); | ||
| $sel.change(() => { | ||
| const [url, id] = $sel.val().split("|"); | ||
| $($iptUrl).val(url); | ||
| $iptUrl.data("id", id); | ||
| }); | ||
| $sel.val(defaultAdvUrl); | ||
| $sel.change(() => { | ||
| const [url, id] = $sel.val().split("|"); | ||
| $($iptUrl).val(url); | ||
| $iptUrl.data("id", id); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| d20plus.template5e.addCustomHTML = function () { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,10 @@ function d20plusEngine () { | |
| $(`head`).append(`<style id="5etools-status-css"/>`); | ||
|
|
||
| d20plus.mod.overwriteStatusEffects(); | ||
| if (!d20.engine.canvas.on) { | ||
| d20.engine.canvas.prototype.on = $.on ?? $("babylonCanvas").on; | ||
| d20.engine.canvas.prototype.off = $.off ?? $("babylonCanvas").off; | ||
| } | ||
|
|
||
| d20.engine.canvas.off("object:added"); | ||
| d20.engine.canvas.on("object:added", d20plus.mod.overwriteStatusEffects); | ||
|
|
@@ -528,33 +532,35 @@ function d20plusEngine () { | |
|
|
||
| // needs to be called after `enhanceMeasureTool()` | ||
| d20plus.engine.enhanceMouseMove = () => { | ||
| // add missing vars | ||
| var i = d20.engine.canvas; | ||
|
|
||
| // Roll20 bug (present as of 2019-5-25) workaround | ||
| // when box-selecting + moving tokens, the "object:moving" event throws an exception | ||
| // try-catch-ignore this, because it's extremely annoying | ||
| const cachedFire = i.fire.bind(i); | ||
| i.fire = function (namespace, opts) { | ||
| if (namespace === "object:moving") { | ||
| try { | ||
| if (d20.engine.canvas){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer inverting and avoiding the extra indent, i.e. |
||
| // add missing vars | ||
| var i = d20.engine.canvas; | ||
|
|
||
| // Roll20 bug (present as of 2019-5-25) workaround | ||
| // when box-selecting + moving tokens, the "object:moving" event throws an exception | ||
| // try-catch-ignore this, because it's extremely annoying | ||
| const cachedFire = i.fire.bind(i); | ||
| i.fire = function (namespace, opts) { | ||
| if (namespace === "object:moving") { | ||
| try { | ||
| cachedFire(namespace, opts); | ||
| } catch (e) {} | ||
| } else { | ||
| cachedFire(namespace, opts); | ||
| } catch (e) {} | ||
| } else { | ||
| cachedFire(namespace, opts); | ||
| } | ||
| }; | ||
| } | ||
| }; | ||
|
|
||
| const I = d20plus.overwrites.canvasHandlerMove | ||
| const I = d20plus.overwrites.canvasHandlerMove | ||
|
|
||
| if (FINAL_CANVAS_MOUSEMOVE_LIST.length) { | ||
| FINAL_CANVAS_MOUSEMOVE = (FINAL_CANVAS_MOUSEMOVE_LIST.find(it => it.on === d20.engine.final_canvas) || {}).listener; | ||
| } | ||
| if (FINAL_CANVAS_MOUSEMOVE_LIST.length) { | ||
| FINAL_CANVAS_MOUSEMOVE = (FINAL_CANVAS_MOUSEMOVE_LIST.find(it => it.on === d20.engine.final_canvas) || {}).listener; | ||
| } | ||
|
|
||
| if (FINAL_CANVAS_MOUSEMOVE) { | ||
| d20plus.ut.log("Enhancing mouse move"); | ||
| d20.engine.final_canvas.removeEventListener("mousemove", FINAL_CANVAS_MOUSEMOVE); | ||
| d20.engine.final_canvas.addEventListener("mousemove", I); | ||
| if (FINAL_CANVAS_MOUSEMOVE) { | ||
| d20plus.ut.log("Enhancing mouse move"); | ||
| d20.engine.final_canvas.removeEventListener("mousemove", FINAL_CANVAS_MOUSEMOVE); | ||
| d20.engine.final_canvas.addEventListener("mousemove", I); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -589,6 +595,11 @@ function d20plusEngine () { | |
| cacheRenderLoop(); | ||
| }; | ||
|
|
||
| if (!d20.engine.canvas.on) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. repeated from above? Is this something that could be factored out, and given e.g. a useful function name explaining what it's doing? additionally, what is
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so $.off and on are query event listener hooks. was too lazy to rely on element.addEventListener with the custom events that were expected to exist here so relied on jquery. i'm not even sure if his is a full fix.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think i had a backup in there . like pulling the ref to the relevant canvas and stuff. i think i tried to prototype it too. but havent been able to get it working
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revised. found the location for them.$.fn.on/off |
||
| d20.engine.canvas.prototype.on = $.on ?? $("babylonCanvas").on; | ||
| d20.engine.canvas.prototype.off = $.off ?? $("babylonCanvas").off; | ||
| } | ||
|
|
||
| // store data for the rendering function to access | ||
| d20.engine.canvas.on("mouse:move", (data, ...others) => { | ||
| // enable hover from GM layer -> token layer | ||
|
|
@@ -748,11 +759,12 @@ function d20plusEngine () { | |
| `); | ||
| } | ||
| } | ||
|
|
||
| d20.engine.canvas._renderAll = _.bind(d20plus.mod.renderAll, d20.engine.canvas); | ||
| d20.engine.canvas.sortTokens = _.bind(d20plus.mod.sortTokens, d20.engine.canvas); | ||
| d20.engine.canvas.drawAnyLayer = _.bind(d20plus.mod.drawAnyLayer, d20.engine.canvas); | ||
| d20.engine.canvas.drawTokensWithoutAuras = _.bind(d20plus.mod.drawTokensWithoutAuras, d20.engine.canvas); | ||
| if (d20.engine.canvas){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: missing |
||
| d20.engine.canvas._renderAll = _.bind(d20plus.mod.renderAll, d20.engine.canvas); | ||
| d20.engine.canvas.sortTokens = _.bind(d20plus.mod.sortTokens, d20.engine.canvas); | ||
| d20.engine.canvas.drawAnyLayer = _.bind(d20plus.mod.drawAnyLayer, d20.engine.canvas); | ||
| d20.engine.canvas.drawTokensWithoutAuras = _.bind(d20plus.mod.drawTokensWithoutAuras, d20.engine.canvas); | ||
| } | ||
| }; | ||
|
|
||
| d20plus.engine.removeLinkConfirmation = function () { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,17 +7,19 @@ function baseMenu () { | |
|
|
||
| const getTokenWhisperPart = () => d20plus.cfg.getOrDefault("token", "massRollWhisperName") ? "/w gm Rolling for @{selected|token_name}...\n" : ""; | ||
|
|
||
| Mousetrap.bind("b b", function () { // back on layer | ||
| const n = d20plus.engine.getSelectedToMove(); | ||
| d20plus.engine.backwardOneLayer(n); | ||
| return false; | ||
| }); | ||
|
|
||
| Mousetrap.bind("b f", function () { // forward one layer | ||
| const n = d20plus.engine.getSelectedToMove(); | ||
| d20plus.engine.forwardOneLayer(n); | ||
| return false; | ||
| }); | ||
| if (typeof(Mousetrap) !== "undefined"){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit |
||
| Mousetrap.bind("b b", function () { // back on layer | ||
| const n = d20plus.engine.getSelectedToMove(); | ||
| d20plus.engine.backwardOneLayer(n); | ||
| return false; | ||
| }); | ||
|
|
||
| Mousetrap.bind("b f", function () { // forward one layer | ||
| const n = d20plus.engine.getSelectedToMove(); | ||
| d20plus.engine.forwardOneLayer(n); | ||
| return false; | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * @param token A token. | ||
|
|
@@ -82,7 +84,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)=>{ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,9 @@ function remoteLibre () { | |
| return fetch("https://api.github.com/repos/DMsGuild201/Roll20_resources/contents/playlist") | ||
| .then(response => response.json()) | ||
| .then(data => { | ||
| // check if blocked | ||
| if (data.block) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: move non-block-statement
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok so u prefer single like non-block if statements?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing a space, but yes |
||
| return Promise.reject(`Blocked: ${data.block.reason ?? "Unknown reason"}`); | ||
| const promises = data.filter(file => file.download_url.toLowerCase().endsWith(".json")) | ||
| .map(file => d20plus.remoteLibre.downloadPlaylist(file.download_url)); | ||
| return Promise.all(promises).then(res => d20plus.remoteLibre.processRemotePlaylists(res)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ const D20plus = function (version) { | |
| if ((typeof window.d20 !== "undefined" || window.currentPlayer?.d20) && !$("#loading-overlay").is(":visible") && !hasRunInit) { | ||
| hasRunInit = true; | ||
| if (!window.d20) window.d20 = window.currentPlayer.d20; | ||
| d20.engine.canvas ??= $("#babylonCanvas").get(0); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no reason. if jquery had to be loaded before this was loaded thought i'd use it. less characters.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the case where it's jQuery selector -> immediately de-reference it to underlying DOM element (with character count is less important than flipping between two mental contexts for the sake of half a line |
||
| d20plus.Init(); | ||
| } else { | ||
| setTimeout(waitForD20, 50); | ||
|
|
@@ -48,14 +49,12 @@ const D20plus = function (version) { | |
|
|
||
| window.d20plus = d20plus; | ||
| d20plus.ut.log("Injection successful..."); | ||
| } else if (timeWaitedForEnhancementSuiteMs > 4 * 5000) { | ||
| alert("betteR20 may require the VTTES (R20ES) extension to be installed!\nPlease install it from https://ssstormy.github.io/roll20-enhancement-suite/\nClicking ok will take you there."); | ||
| window.open("https://ssstormy.github.io/roll20-enhancement-suite/", "_blank"); | ||
| } else { | ||
| if (timeWaitedForEnhancementSuiteMs > 4 * 5000) { | ||
| alert("betteR20 may require the VTTES (R20ES) extension to be installed!\nPlease install it from https://ssstormy.github.io/roll20-enhancement-suite/\nClicking ok will take you there."); | ||
| window.open("https://ssstormy.github.io/roll20-enhancement-suite/", "_blank"); | ||
| } else { | ||
| timeWaitedForEnhancementSuiteMs += 100; | ||
| setTimeout(waitForEnhancementSuite, 100); | ||
| } | ||
| timeWaitedForEnhancementSuiteMs += 100; | ||
| setTimeout(waitForEnhancementSuite, 100); | ||
| } | ||
| })(); | ||
| } | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file definitely should exist (see https://5e.tools/data/adventures.json); what errors are you seeing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that endpoint responded with 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's definitely alive and well for me, can you double-check it in your browser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works in browser .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can run this in the console while in a roll20 game
var x = await fetch("https://5e.tools/data/adventures.json")
will give same result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 have asked the server host to take a look at it, because it really should be available, but it's behind some CloudFlare thing