Skip to content

Fix/jumpgate load#189

Draft
Zalatos wants to merge 13 commits into
TheGiddyLimit:developmentfrom
Zalatos:fix/jumpgate-load
Draft

Fix/jumpgate load#189
Zalatos wants to merge 13 commits into
TheGiddyLimit:developmentfrom
Zalatos:fix/jumpgate-load

Conversation

@Zalatos
Copy link
Copy Markdown

@Zalatos Zalatos commented Apr 1, 2025

prevents some errors and enables some features.

  • attempted workaround to get canvas context
  • jukebox playlist error handled
  • fix: character sheet not found when on jumpgate

Copy link
Copy Markdown
Owner

@TheGiddyLimit TheGiddyLimit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in addition to the other feedback, please avoid pushing the dist/ ... changes

you can either rebase/amend your commits to remove those changes, make a new set of commits without committing the dist/ files, or I can just copy out the rest of the patch if/when the PR is otherwise ready

Comment thread js/5etools-main.js
{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`},
Copy link
Copy Markdown
Owner

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?

Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

it's definitely alive and well for me, can you double-check it in your browser?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works in browser .

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://5e.tools/data/adventures.json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown
Owner

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

Comment thread js/5etools-main.js Outdated
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) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sheets.length < 1 -> !sheets.length

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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)
can make it cleaner though. as long as it handles both jumpgate and non jumpgate games.

i'm not too attached to format

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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 undefined < 1 === false..?

if d20.journal.customSheets and d20.journal.characterSheetsManager.getAllSheets() are two fundamentally different data types, then there should just be two different branches, one to handle each. I.e., I'd prefer duplicated code to confusing checks at every usage point

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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

Comment thread js/5etools-main.js
Comment thread js/5etools-main.js Outdated
Comment on lines +934 to +935
if (firstSheet.layouthtml.indexOf("shaped_d20") > 0) d20plus.sheet = "shaped";
if (firstSheet.layouthtml.indexOf("DnD5e_Character_Sheet") > 0) d20plus.sheet = "community";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you're here,

firstSheet.layouthtml.indexOf("shaped_d20") > 0 -> firstSheet.layouthtml.includes("shaped_d20")

firstSheet.layouthtml.indexOf("DnD5e_Character_Sheet") > 0 -> firstSheet.layouthtml.includes("DnD5e_Character_Sheet")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet i like it

Comment thread js/5etools-template.js
$iptUrl.data("id", "lmop");
const $sel = $("#button-adventures-select");
adventureMetadata.adventure.forEach(a => {
if (adventureMetadata.adventure){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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

Comment thread js/base-engine.js Outdated
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){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing between ){

Comment thread js/base-engine.js
cacheRenderLoop();
};

if (!d20.engine.canvas.on) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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 $.on/$.off doing? Are these ever defined?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so $.off and on are query event listener hooks.
the repeat is because i was not certain with 100% certainty where the first call to the d20.enginge.canvas was.
so wit this i created the functions to apply the event listeners.

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.
there are still things i want to fix later

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the jQuery bodge I'm ultimately fine with; it's a hack, but it's a fairly elegant (and easy to un-hack later) one, so that's all good

$.on/$.off don't exist in my test game, hence the Q:

image

Copy link
Copy Markdown
Author

@Zalatos Zalatos Apr 7, 2025

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revised. found the location for them.$.fn.on/off

Comment thread js/base-menu.js Outdated
d20plus.engine.forwardOneLayer(n);
return false;
});
if (typeof(Mousetrap) !== "undefined"){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit typeof(Mousetrap) -> typeof Mousetrap

Comment thread js/base-remote-libre.js Outdated
.then(response => response.json())
.then(data => {
// check if blocked
if (data.block)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: move non-block-statement if statement onto same line as condition (or wrap in { })

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so u prefer single like non-block if statements?
like this?
if(conditionIsMet) doTheThing();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a space, but yes

if (conditionIsMet) doTheThing();

Comment thread js/base.js Outdated
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);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not document.getElementById(...) and skip the jQuery cruft?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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.
if u want getElementById can change for better portability. not attached

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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 .get(0) or [0]), then prefer using the browser built-in

character count is less important than flipping between two mental contexts for the sake of half a line

@TheGiddyLimit
Copy link
Copy Markdown
Owner

TheGiddyLimit commented Apr 6, 2025

appreciate the submission generally, but, hard to judge a set of changes without information on the intent/effect of those changes

screenshots of things working (or even better, "before" screenshot of things not working, and "after" screenshots of the working version with fixes applied) would be greatly appreciated

@Zalatos
Copy link
Copy Markdown
Author

Zalatos commented Apr 7, 2025

in addition to the other feedback, please avoid pushing the dist/ ... changes

you can either rebase/amend your commits to remove those changes, make a new set of commits without committing the dist/ files, or I can just copy out the rest of the patch if/when the PR is otherwise ready

sorry about that. i think the editorconfig overwrote the dist folder rollback on my amends. saving the file added the spaces etc.
was getting annoyed trying to fix it and left it for another time

@Zalatos
Copy link
Copy Markdown
Author

Zalatos commented Apr 7, 2025

in addition to the other feedback, please avoid pushing the dist/ ... changes
you can either rebase/amend your commits to remove those changes, make a new set of commits without committing the dist/ files, or I can just copy out the rest of the patch if/when the PR is otherwise ready

sorry about that. i think the editorconfig overwrote the dist folder rollback on my amends. saving the file added the spaces etc. was getting annoyed trying to fix it and left it for another time

no worries. since the live version is completely broken i thought i'd share my progress on fixing some of the functionality.
apparently VTTES is also broken so my next journey is that before i come back here

@Zalatos
Copy link
Copy Markdown
Author

Zalatos commented Apr 7, 2025

next update:

  • will try reverse the dist file content by saving without an editorconfig.
  • will 1 liner the non-block if statement
  • add getElementById instead of jquery version
  • change typeof() to typeof shorthand
  • change array.indeoxOf to array.includes

@Zalatos Zalatos marked this pull request as draft April 7, 2025 17:31
@Zalatos Zalatos requested a review from TheGiddyLimit April 7, 2025 20:10
@Zalatos
Copy link
Copy Markdown
Author

Zalatos commented Apr 8, 2025

should dist folder be added to gitignore?

@TheGiddyLimit
Copy link
Copy Markdown
Owner

should dist folder be added to gitignore?

not currently, as the compiled scripts are committed when a new release is put out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants