1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-12-12 09:21:36 +00:00
The-Modding-Tree/js/technical/displays.js

198 lines
6.5 KiB
JavaScript
Raw Normal View History

2021-05-03 02:39:38 +00:00
function prestigeButtonText(layer) {
if (layers[layer].prestigeButtonText !== undefined)
return run(layers[layer].prestigeButtonText(), layers[layer])
if (tmp[layer].type == "normal")
return `${player[layer].points.lt(1e3) ? (tmp[layer].resetDescription !== undefined ? tmp[layer].resetDescription : "Reset for ") : ""}+<b>${formatWhole(tmp[layer].resetGain)}</b> ${tmp[layer].resource} ${tmp[layer].resetGain.lt(100) && player[layer].points.lt(1e3) ? `<br><br>Next at ${(tmp[layer].roundUpCost ? formatWhole(tmp[layer].nextAt) : format(tmp[layer].nextAt))} ${tmp[layer].baseResource}` : ""}`
if (tmp[layer].type == "static")
return `${tmp[layer].resetDescription !== undefined ? tmp[layer].resetDescription : "Reset for "}+<b>${formatWhole(tmp[layer].resetGain)}</b> ${tmp[layer].resource}<br><br>${player[layer].points.lt(30) ? (tmp[layer].baseAmount.gte(tmp[layer].nextAt) && (tmp[layer].canBuyMax !== undefined) && tmp[layer].canBuyMax ? "Next:" : "Req:") : ""} ${formatWhole(tmp[layer].baseAmount)} / ${(tmp[layer].roundUpCost ? formatWhole(tmp[layer].nextAtDisp) : format(tmp[layer].nextAtDisp))} ${tmp[layer].baseResource}
`
if (tmp[layer].type == "none")
return ""
return "You need prestige button text"
}
function constructNodeStyle(layer){
let style = []
if ((tmp[layer].isLayer && layerunlocked(layer)) || (!tmp[layer].isLayer && tmp[layer].canClick))
style.push({'background-color': tmp[layer].color})
if (tmp[layer].image !== undefined)
style.push({'background-image': 'url("' + tmp[layer].image + '")'})
2021-05-07 23:24:32 +00:00
if(tmp[layer].notify && player[layer].unlocked)
style.push({'box-shadow': 'var(--hqProperty2a), 0 0 20px ' + tmp[layer].trueGlowColor})
2021-05-03 02:39:38 +00:00
style.push(tmp[layer].nodeStyle)
return style
}
function challengeStyle(layer, id) {
if (player[layer].activeChallenge == id && canCompleteChallenge(layer, id)) return "canComplete"
2024-10-27 21:28:08 +00:00
else if (maxedChallenge(layer, id)) return "done"
2021-05-03 02:39:38 +00:00
return "locked"
}
function challengeButtonText(layer, id) {
2024-10-27 21:28:08 +00:00
return (player[layer].activeChallenge==(id)?(canCompleteChallenge(layer, id)?"Finish":"Exit Early"):(maxedChallenge(layer, id)?"Completed":"Start"))
2021-05-03 02:39:38 +00:00
}
function achievementStyle(layer, id){
ach = tmp[layer].achievements[id]
let style = []
if (ach.image){
style.push({'background-image': 'url("' + ach.image + '")'})
}
2024-10-27 21:14:49 +00:00
if (!hasAchievement(layer, id)) style.push({'visibility': 'hidden'})
2021-05-03 02:39:38 +00:00
style.push(ach.style)
return style
}
function updateWidth() {
2021-06-02 21:54:07 +00:00
let screenWidth = window.innerWidth
let splitScreen = screenWidth >= 1024
2021-06-03 05:04:56 +00:00
if (options.forceOneTab) splitScreen = false
2021-05-26 05:44:12 +00:00
if (player.navTab == "none") splitScreen = true
tmp.other.screenWidth = screenWidth
2021-05-18 01:51:36 +00:00
tmp.other.screenHeight = window.innerHeight
tmp.other.splitScreen = splitScreen
tmp.other.lastPoints = player.points
}
function updateOomps(diff)
{
tmp.other.oompsMag = 0
if (player.points.lte(new Decimal(1e100)) || diff == 0) return
var pp = new Decimal(player.points);
var lp = tmp.other.lastPoints || new Decimal(0);
if (pp.gt(lp)) {
if (pp.gte("10^^8")) {
pp = pp.slog(1e10)
lp = lp.slog(1e10)
tmp.other.oomps = pp.sub(lp).div(diff)
tmp.other.oompsMag = -1;
} else {
while (pp.div(lp).log(10).div(diff).gte("100") && tmp.other.oompsMag <= 5 && lp.gt(0)) {
pp = pp.log(10)
lp = lp.log(10)
tmp.other.oomps = pp.sub(lp).div(diff)
tmp.other.oompsMag++;
}
}
}
}
function constructBarStyle(layer, id) {
let bar = tmp[layer].bars[id]
let style = {}
2024-10-27 21:22:04 +00:00
let tempProgress
if (bar.progress instanceof Decimal)
2024-10-27 21:22:04 +00:00
tempProgress = (1 -Math.min(Math.max(bar.progress.toNumber(), 0), 1)) * 100
else
tempProgress = (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:
2024-10-27 21:22:04 +00:00
style.fillDims['clip-path'] = 'inset(' + tempProgress + '% 0% 0% 0%)'
style.fillDims.width = bar.width + 1 + 'px'
break;
case DOWN:
2024-10-27 21:22:04 +00:00
style.fillDims['clip-path'] = 'inset(0% 0% ' + tempProgress + '% 0%)'
style.fillDims.width = bar.width + 1 + 'px'
break;
case RIGHT:
2024-10-27 21:22:04 +00:00
style.fillDims['clip-path'] = 'inset(0% ' + tempProgress + '% 0% 0%)'
break;
case LEFT:
2024-10-27 21:22:04 +00:00
style.fillDims['clip-path'] = 'inset(0% 0% 0% ' + tempProgress + '%)'
break;
case DEFAULT:
style.fillDims['clip-path'] = 'inset(0% 50% 0% 0%)'
}
2021-06-07 23:25:19 +00:00
if (bar.instant) {
style.fillDims['transition-duration'] = '0s'
}
return style
2021-05-10 01:39:15 +00:00
}
function constructTabFormat(layer, id, family){
let tabTemp, tabLayer, tabFunc, location, key
if (id === undefined){
tabTemp = tmp[layer].tabFormat
tabLayer = layers[layer].tabFormat
tabFunc = funcs[layer].tabFormat
location = tmp[layer]
key = "tabFormat"
}
else if (family === undefined) {
tabTemp = tmp[layer].tabFormat[id].content
tabLayer = layers[layer].tabFormat[id].content
tabFunc = funcs[layer].tabFormat[id].content
location = tmp[layer].tabFormat[id]
key = "content"
}
else {
tabTemp = tmp[layer].microtabs[family][id].content
tabLayer = layers[layer].microtabs[family][id].content
tabFunc = funcs[layer].microtabs[family][id].content
location = tmp[layer].microtabs[family][id]
key = "tabFormat"
}
if (isFunction(tabLayer)) {
2021-06-01 18:56:33 +00:00
return tabLayer.bind(location)()
2021-05-10 01:39:15 +00:00
}
2021-06-01 18:56:33 +00:00
updateTempData(tabLayer, tabTemp, tabFunc, {layer, id, family})
2021-05-10 01:39:15 +00:00
return tabTemp
}
function updateTabFormats() {
updateTabFormat(player.tab)
updateTabFormat(player.navTab)
}
function updateTabFormat(layer) {
if (layers[layer]?.tabFormat === undefined) return
let tab = player.subtabs[layer]?.mainTabs
if (isFunction(layers[layer].tabFormat)) {
Vue.set(temp[layer], 'tabFormat', layers[layer].tabFormat())
}
else if (Array.isArray(layers[layer].tabFormat)) {
Vue.set(temp[layer], 'tabFormat', constructTabFormat(layer))
}
else if (isPlainObject(layers[layer].tabFormat)) {
if (layers[layer].tabFormat[tab].embedLayer === undefined)
Vue.set(temp[layer].tabFormat[tab], 'content', constructTabFormat(layer, tab))
}
// Check for embedded layer
if (isPlainObject(tmp[layer].tabFormat) && tmp[layer].tabFormat[tab].embedLayer !== undefined) {
2021-05-13 03:21:39 +00:00
updateTabFormat(tmp[layer].tabFormat[tab].embedLayer)
2021-05-10 01:39:15 +00:00
}
// Update microtabs
for (family in layers[layer].microtabs) {
tab = player.subtabs[layer][family]
if (tmp[layer].microtabs[family][tab]) {
if (tmp[layer].microtabs[family][tab].embedLayer)
2021-05-13 03:21:39 +00:00
updateTabFormat(tmp[layer].microtabs[family][tab].embedLayer)
2021-05-10 01:39:15 +00:00
else
2021-05-13 03:21:39 +00:00
Vue.set(temp[layer].microtabs[family][tab], 'content', constructTabFormat(layer, tab, family))
2021-05-10 01:39:15 +00:00
}
}
}