Skip to content

Commit

Permalink
Merge branch 'development' of github.com:TheGiddyLimit/5etoolsR20 int…
Browse files Browse the repository at this point in the history
…o development
  • Loading branch information
TheGiddyLimit committed Nov 26, 2023
2 parents 0a4b111 + c3bcbfe commit 462107e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
35 changes: 21 additions & 14 deletions js/base-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ function d20plusEngine () {
};

d20plus.engine.swapTemplates = () => {
const oldToolbar = document.getElementById("floatingtoolbar");
d20plus.isOptedInNewUI = !oldToolbar;

d20plus.ut.log("Swapping templates...");
$("#tmpl_charactereditor").html($(d20plus.html.characterEditor).html());
$("#tmpl_handouteditor").html($(d20plus.html.handoutEditor).html());
Expand Down Expand Up @@ -196,21 +199,25 @@ function d20plusEngine () {
}).addTouch();
}

overwriteDraggables();
$(`#page-toolbar`).css("top", "calc(-90vh + 40px)");

const originalFn = d20.pagetoolbar.refreshPageListing;
// original function is debounced at 100ms, so debounce this at 110ms and hope for the best
const debouncedOverwrite = _.debounce(() => {
if (!d20plus.isOptedInNewUI) {
overwriteDraggables();
// fire an event for other parts of the script to listen for
const pageChangeEvt = new Event(`VePageChange`);
d20plus.ut.log("Firing page-change event");
document.dispatchEvent(pageChangeEvt);
}, 110);
d20.pagetoolbar.refreshPageListing = () => {
originalFn();
debouncedOverwrite();
$(`#page-toolbar`).css("top", "calc(-90vh + 40px)");

const originalFn = d20.pagetoolbar.refreshPageListing;
// original function is debounced at 100ms, so debounce this at 110ms and hope for the best
const debouncedOverwrite = _.debounce(() => {
overwriteDraggables();
// fire an event for other parts of the script to listen for
const pageChangeEvt = new Event(`VePageChange`);
d20plus.ut.log("Firing page-change event");
document.dispatchEvent(pageChangeEvt);
}, 110);
d20.pagetoolbar.refreshPageListing = () => {
originalFn();
debouncedOverwrite();
}
} else {
$(`#page-toolbar`).hide();
}

$(`body`).on("mouseup", "li.dl", (evt) => {
Expand Down
4 changes: 4 additions & 0 deletions js/base-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ function baseUtil () {
} else {
d20plus.ut.showHardDickMessage(scriptName);
}
d20plus.isOptedInNewUI && !isStreamer && d20plus.ut.sendHackerChat(`
betteR20 does not support the new UI preview at this moment!
Using it will make some betteR20 functionality unavailable.
`);
$boringProgress
.before(`<span><span>&gt;</span>all systems operational</span>`)
.html("");
Expand Down

0 comments on commit 462107e

Please sign in to comment.