mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2024-11-24 09:21:46 +00:00
More bar optimizations, compatibility improvement
This commit is contained in:
parent
51f9e2f1a7
commit
cc953e0b6b
3 changed files with 40 additions and 44 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue