From cc953e0b6b7ae1615f402e613766fa4939c5f485 Mon Sep 17 00:00:00 2001 From: Harley White Date: Sun, 9 May 2021 18:39:12 -0400 Subject: [PATCH] More bar optimizations, compatibility improvement --- changelog.md | 4 ++++ js/technical/displays.js | 33 ++++++++++++++++++++++++++++ js/technical/temp.js | 47 +++------------------------------------- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/changelog.md b/changelog.md index f107419..45289ef 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,10 @@ # The Modding Tree changelog: +# v2.5.3 - 5/8/21 +- Improved performance of bars. - Respec confirmation settings are now kept on resets. +- Improved compatibility with older browsers. +- Fixed missing pixel on vertical bars. # v2.5.2.1 - 5/7/21 - Fixed microtabs making layers highlight incorrectly. diff --git a/js/technical/displays.js b/js/technical/displays.js index 81fc146..f37e23a 100644 --- a/js/technical/displays.js +++ b/js/technical/displays.js @@ -85,4 +85,37 @@ function updateOomps(diff) } } +} + +function constructBarStyle(layer, id) { + let bar = tmp[layer].bars[id] + let style = {} + if (bar.progress instanceof Decimal) + bar.progress = bar.progress.toNumber() + bar.progress = (1 -Math.min(Math.max(bar.progress, 0), 1)) * 100 + + style.dims = {'width': bar.width + "px", 'height': bar.height + "px"} + let dir = bar.direction + style.fillDims = {'width': (bar.width + 0.5) + "px", 'height': (bar.height + 0.5) + "px"} + + switch(bar.direction) { + case UP: + style.fillDims['clip-path'] = 'inset(' + bar.progress + '% 0% 0% 0%)' + style.fillDims.width = bar.width + 1 + 'px' + break; + case DOWN: + style.fillDims['clip-path'] = 'inset(0% 0% ' + bar.progress + '% 0%)' + style.fillDims.width = bar.width + 1 + 'px' + + break; + case RIGHT: + style.fillDims['clip-path'] = 'inset(0% ' + bar.progress + '% 0% 0%)' + break; + case LEFT: + style.fillDims['clip-path'] = 'inset(0% 0% 0% ' + bar.progress + '%)' + break; + case DEFAULT: + style.fillDims['clip-path'] = 'inset(0% 50% 0% 0%)' + } + return style } \ No newline at end of file diff --git a/js/technical/temp.js b/js/technical/temp.js index a65e4aa..530c698 100644 --- a/js/technical/temp.js +++ b/js/technical/temp.js @@ -9,6 +9,7 @@ var activeFunctions = [ "buy", "buyMax", "respec", "onComplete", "onPurchase", "onPress", "onClick", "onHold", "masterButtonPress", "sellOne", "sellAll", "pay", "actualCostFunction", "actualEffectFunction", "effectDescription", "display", "fullDisplay", "effectDisplay", "rewardDisplay", + "tabFormat", "content", ] var noCall = doNotCallTheseFunctionsEveryTick @@ -35,7 +36,6 @@ function setupTemp() { tmp[layer].notify = {} tmp[layer].prestigeNotify = {} tmp[layer].computedNodeStyle = [] - setupBarStyles(layer) setupBuyables(layer) tmp[layer].trueGlowColor = [] } @@ -156,59 +156,18 @@ function updateClickableTemp(layer) updateTempData(layers[layer].clickables, tmp[layer].clickables, funcs[layer].clickables) } - - -function constructBarStyle(layer, id) { - let bar = tmp[layer].bars[id] - let style = {} - if (bar.progress instanceof Decimal) - bar.progress = bar.progress.toNumber() - bar.progress = (1 -Math.min(Math.max(bar.progress, 0), 1)) * 100 - - style.dims = {'width': bar.width + "px", 'height': bar.height + "px"} - let dir = bar.direction - style.fillDims = {'width': (bar.width + 0.5) + "px", 'height': (bar.height + 0.5) + "px"} - if (dir !== undefined) - { - style.fillDims['clip-path'] = 'inset(0% 50% 0% 0%)' - if(dir == UP){ - style.fillDims['clip-path'] = 'inset(' + bar.progress + '% 0% 0% 0%)' - } - else if(dir == DOWN){ - style.fillDims['clip-path'] = 'inset(0% 0% ' + bar.progress + '% 0%)' - } - else if(dir == RIGHT){ - style.fillDims['clip-path'] = 'inset(0% ' + bar.progress + '% 0% 0%)' - } - else if(dir == LEFT){ - style.fillDims['clip-path'] = 'inset(0% 0% 0% ' + bar.progress + '%)' - } - } - return style -} - -function setupBarStyles(layer){ - if (layers[layer].bars === undefined) - return - for (id in layers[layer].bars){ - let bar = tmp[layer].bars[id] - bar.dims = {} - bar.fillDims = {} - } -} - function setupBuyables(layer) { for (id in layers[layer].buyables) { if (!isNaN(id)) { let b = layers[layer].buyables[id] b.actualCostFunction = b.cost b.cost = function(x) { - x = x ?? player[this.layer].buyables[this.id] + x = (x === undefined ? player[this.layer].buyables[this.id] : x) return layers[this.layer].buyables[this.id].actualCostFunction(x) } b.actualEffectFunction = b.effect b.effect = function(x) { - x = x ?? player[this.layer].buyables[this.id] + x = (x === undefined ? player[this.layer].buyables[this.id] : x) return layers[this.layer].buyables[this.id].actualEffectFunction(x) } }