diff --git a/src/gui/userButton.js b/src/gui/sideBar.js similarity index 66% rename from src/gui/userButton.js rename to src/gui/sideBar.js index 0c8cf11d416de2f83b950d4cc7650cd3bb5bcfad..9c1e8e3508a06265f8f80745c8a64a4805fae3cf 100644 --- a/src/gui/userButton.js +++ b/src/gui/sideBar.js @@ -1,3 +1,26 @@ +/** Notify the game that the sidebar needs to be refreshed as soon as possible, but do not do it immediately. + * This allows us to call this function repeatedly without impacting performance (for example, from repX() and cashX()). + * The game will redraw the sidebar exactly once, as soon as all the scripts have finished executing. + */ +App.Utils.scheduleSidebarRefresh = (function() { + let refresh = false; + + function updateSidebar() { + refresh = false; + UIBar.update(); + App.UI.updateSidebarTooltips(); + } + + function schedule() { + if (!refresh) { + refresh = true; + setTimeout(updateSidebar, 0); + } + } + + return schedule; +})(); + App.Utils.userButton = function(nextButton = V.nextButton, nextLink = V.nextLink) { const el = document.createElement("span"); el.id = "next-button-wrapper"; // We must always have a named element so we have something to refresh even if the button is hidden for a scene diff --git a/src/js/utilsFC.js b/src/js/utilsFC.js index e0476b3f1b43c1745fbb9ffd34d66012b9109b51..2e21bd32214e1f6ec37813b5e1f7fdccfcd9c64a 100644 --- a/src/js/utilsFC.js +++ b/src/js/utilsFC.js @@ -94,29 +94,6 @@ globalThis.arrayToSentence = function(array) { return array.reduce((res, ch, i, arr) => res + (i === arr.length - 1 ? ' and ' : ', ') + ch); }; -/** Notify the game that the sidebar needs to be refreshed as soon as possible, but do not do it immediately. - * This allows us to call this function repeatedly without impacting performance (for example, from repX() and cashX()). - * The game will redraw the sidebar exactly once, as soon as all the scripts have finished executing. - */ -App.Utils.scheduleSidebarRefresh = (function() { - let refresh = false; - - function updateSidebar() { - refresh = false; - UIBar.update(); - App.UI.updateSidebarTooltips(); - } - - function schedule() { - if (!refresh) { - refresh = true; - setTimeout(updateSidebar, 0); - } - } - - return schedule; -})(); - App.Utils.alphabetizeIterable = function(iterable) { const compare = function(a, b) { let aTitle = a.toLowerCase();