1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-25 09:51:54 +00:00
The-Modding-Tree/js/components.js

666 lines
30 KiB
JavaScript
Raw Normal View History

2020-08-19 02:50:24 +00:00
var app;
function loadVue() {
2020-10-07 20:41:45 +00:00
// data = a function returning the content (actually HTML)
Vue.component('display-text', {
props: ['layer', 'data'],
template: `
2020-10-12 22:28:12 +00:00
<span class="instant" v-html="data"></span>
`
})
2020-10-12 22:28:12 +00:00
// data = a function returning the content (actually HTML)
Vue.component('raw-html', {
props: ['layer', 'data'],
template: `
<span class="instant" v-html="data"></span>
`
})
2020-10-04 21:14:13 +00:00
// Blank space, data = optional height in px or pair with width and height in px
Vue.component('blank', {
props: ['layer', 'data'],
template: `
2020-10-12 22:28:12 +00:00
<div class = "instant">
<div class = "instant" v-if="!data" v-bind:style="{'width': '8px', 'height': '17px'}"></div>
<div class = "instant" v-else-if="Array.isArray(data)" v-bind:style="{'width': data[0], 'height': data[1]}"></div>
2020-10-23 19:07:27 +00:00
<div class = "instant" v-else v-bind:style="{'width': '8px', 'height': data}"><br></div>
</div>
`
})
// Displays an image, data is the URL
Vue.component('display-image', {
props: ['layer', 'data'],
template: `
2020-10-12 22:28:12 +00:00
<img class="instant" v-bind:src= "data" v-bind:alt= "data">
`
})
2020-10-04 21:14:13 +00:00
// data = an array of Components to be displayed in a row
Vue.component('row', {
props: ['layer', 'data'],
computed: {
key() {return this.$vnode.key}
},
template: `
<div class="upgTable instant">
<div class="upgRow">
<div v-for="(item, index) in data">
<div v-if="!Array.isArray(item)" v-bind:is="item" :layer= "layer" v-bind:style="tmp[layer].componentStyles[item]" :key="key + '-' + index"></div>
<div v-else-if="item.length==3" v-bind:style="[tmp[layer].componentStyles[item[0]], (item[2] ? item[2] : {})]" v-bind:is="item[0]" :layer= "layer" :data= "item[1]" :key="key + '-' + index"></div>
<div v-else-if="item.length==2" v-bind:is="item[0]" :layer= "layer" :data= "item[1]" v-bind:style="tmp[layer].componentStyles[item[0]]" :key="key + '-' + index"></div>
</div>
</div>
</div>
`
})
// data = an array of Components to be displayed in a column
Vue.component('column', {
props: ['layer', 'data'],
computed: {
key() {return this.$vnode.key}
},
template: `
2020-10-26 02:11:57 +00:00
<div class="upgTable instant">
<div class="upgCol">
<div v-for="(item, index) in data">
<div v-if="!Array.isArray(item)" v-bind:is="item" :layer= "layer" v-bind:style="tmp[layer].componentStyles[item]" :key="key + '-' + index"></div>
<div v-else-if="item.length==3" v-bind:style="[tmp[layer].componentStyles[item[0]], (item[2] ? item[2] : {})]" v-bind:is="item[0]" :layer= "layer" :data= "item[1]" :key="key + '-' + index"></div>
<div v-else-if="item.length==2" v-bind:is="item[0]" :layer= "layer" :data= "item[1]" v-bind:style="tmp[layer].componentStyles[item[0]]" :key="key + '-' + index"></div>
</div>
</div>
</div>
`
})
// data [other layer, tabformat for within proxy]
Vue.component('layer-proxy', {
props: ['layer', 'data'],
computed: {
key() {return this.$vnode.key}
},
template: `
<div>
<column :layer="data[0]" :data="data[1]" :key="key + 'col'"></column>
</div>
`
})
2020-10-25 22:21:02 +00:00
Vue.component('infobox', {
2020-10-24 16:40:56 +00:00
props: ['layer', 'data'],
template: `
2020-10-26 06:06:02 +00:00
<div class="story instant" v-if="tmp[layer].infoboxes && tmp[layer].infoboxes[data]!== undefined && tmp[layer].infoboxes[data].unlocked" v-bind:style="[{'border-color': tmp[layer].color, 'border-radius': player.infoboxes[layer][data] ? 0 : '8px'}, tmp[layer].infoboxes[data].style]">
2020-10-26 02:11:57 +00:00
<button class="story-title" v-bind:style="[{'background-color': tmp[layer].color}, tmp[layer].infoboxes[data].titleStyle]"
2020-10-25 22:21:02 +00:00
v-on:click="player.infoboxes[layer][data] = !player.infoboxes[layer][data]">
<span class="story-toggle">{{player.infoboxes[layer][data] ? "+" : "-"}}</span>
<span v-html="tmp[layer].infoboxes[data].title ? tmp[layer].infoboxes[data].title : (tmp[layer].name)"></span>
</button>
2020-10-26 02:11:57 +00:00
<div v-if="!player.infoboxes[layer][data]" class="story-text" v-bind:style="tmp[layer].infoboxes[data].bodyStyle">
<span v-html="tmp[layer].infoboxes[data].body ? tmp[layer].infoboxes[data].body : 'Blah'"></span>
</div>
2020-10-24 16:40:56 +00:00
</div>
`
})
// Data = width in px, by default fills the full area
Vue.component('h-line', {
props: ['layer', 'data'],
template:`
2020-10-12 22:28:12 +00:00
<hr class="instant" v-bind:style="data ? {'width': data} : {}" class="hl">
`
})
// Data = height in px, by default is bad
Vue.component('v-line', {
props: ['layer', 'data'],
template: `
2020-10-12 22:28:12 +00:00
<div class="instant" v-bind:style="data ? {'height': data} : {}" class="vl2"></div>
`
})
Vue.component('challenges', {
2021-06-03 17:26:21 +00:00
props: ['layer', 'data'],
template: `
2020-10-25 01:03:18 +00:00
<div v-if="tmp[layer].challenges" class="upgTable">
2021-06-03 17:26:21 +00:00
<div v-for="row in (data === undefined ? tmp[layer].challenges.rows : data)" class="upgRow">
<div v-for="col in tmp[layer].challenges.cols">
2020-10-25 01:03:18 +00:00
<challenge v-if="tmp[layer].challenges[row*10+col]!== undefined && tmp[layer].challenges[row*10+col].unlocked" :layer = "layer" :data = "row*10+col" v-bind:style="tmp[layer].componentStyles.challenge"></challenge>
</div>
</div>
</div>
`
})
// data = id
Vue.component('challenge', {
props: ['layer', 'data'],
template: `
2021-06-03 05:04:56 +00:00
<div v-if="tmp[layer].challenges && tmp[layer].challenges[data]!== undefined && tmp[layer].challenges[data].unlocked && !(options.hideChallenges && maxedChallenge(layer, [data]) && !inChallenge(layer, [data]))"
v-bind:class="['challenge', challengeStyle(layer, data), player[layer].activeChallenge === data ? 'resetNotify' : '']" v-bind:style="tmp[layer].challenges[data].style">
<br><h3 v-html="tmp[layer].challenges[data].name"></h3><br><br>
2021-05-03 02:39:38 +00:00
<button v-bind:class="{ longUpg: true, can: true, [layer]: true }" v-bind:style="{'background-color': tmp[layer].color}" v-on:click="startChallenge(layer, data)">{{challengeButtonText(layer, data)}}</button><br><br>
<span v-if="layers[layer].challenges[data].fullDisplay" v-html="run(layers[layer].challenges[data].fullDisplay, layers[layer].challenges[data])"></span>
2020-11-29 05:40:01 +00:00
<span v-else>
<span v-html="tmp[layer].challenges[data].challengeDescription"></span><br>
2021-06-02 20:59:37 +00:00
Goal: <span v-if="tmp[layer].challenges[data].goalDescription" v-html="tmp[layer].challenges[data].goalDescription"></span><span v-else>{{format(tmp[layer].challenges[data].goal)}} {{tmp[layer].challenges[data].currencyDisplayName ? tmp[layer].challenges[data].currencyDisplayName : modInfo.pointsName}}</span><br>
2020-11-29 05:40:01 +00:00
Reward: <span v-html="tmp[layer].challenges[data].rewardDescription"></span><br>
2021-05-03 02:39:38 +00:00
<span v-if="layers[layer].challenges[data].rewardDisplay!==undefined">Currently: <span v-html="(tmp[layer].challenges[data].rewardDisplay) ? (run(layers[layer].challenges[data].rewardDisplay, layers[layer].challenges[data])) : format(tmp[layer].challenges[data].rewardEffect)"></span></span>
2020-11-29 05:40:01 +00:00
</span>
2021-06-03 04:01:31 +00:00
<node-mark :layer='layer' :data='tmp[layer].challenges[data].marked' :offset="20" :scale="1.5"></node-mark></span>
2021-05-14 19:32:20 +00:00
</div>
`
})
Vue.component('upgrades', {
2020-12-05 19:52:29 +00:00
props: ['layer', 'data'],
template: `
2020-10-25 01:03:18 +00:00
<div v-if="tmp[layer].upgrades" class="upgTable">
2020-12-05 19:52:29 +00:00
<div v-for="row in (data === undefined ? tmp[layer].upgrades.rows : data)" class="upgRow">
2020-10-25 01:03:18 +00:00
<div v-for="col in tmp[layer].upgrades.cols"><div v-if="tmp[layer].upgrades[row*10+col]!== undefined && tmp[layer].upgrades[row*10+col].unlocked" class="upgAlign">
<upgrade :layer = "layer" :data = "row*10+col" v-bind:style="tmp[layer].componentStyles.upgrade"></upgrade>
</div></div>
</div>
<br>
</div>
`
})
// data = id
Vue.component('upgrade', {
props: ['layer', 'data'],
template: `
2021-06-10 04:54:36 +00:00
<button v-if="tmp[layer].upgrades && tmp[layer].upgrades[data]!== undefined && tmp[layer].upgrades[data].unlocked" :id='"upgrade-" + layer + "-" + data' v-on:click="buyUpg(layer, data)" v-bind:class="{ [layer]: true, tooltipBox: true, upg: true, bought: hasUpgrade(layer, data), locked: (!(canAffordUpgrade(layer, data))&&!hasUpgrade(layer, data)), can: (canAffordUpgrade(layer, data)&&!hasUpgrade(layer, data))}"
v-bind:style="[((!hasUpgrade(layer, data) && canAffordUpgrade(layer, data)) ? {'background-color': tmp[layer].color} : {}), tmp[layer].upgrades[data].style]">
2021-05-03 02:39:38 +00:00
<span v-if="layers[layer].upgrades[data].fullDisplay" v-html="run(layers[layer].upgrades[data].fullDisplay, layers[layer].upgrades[data])"></span>
2020-11-29 21:28:24 +00:00
<span v-else>
<span v-if= "tmp[layer].upgrades[data].title"><h3 v-html="tmp[layer].upgrades[data].title"></h3><br></span>
<span v-html="tmp[layer].upgrades[data].description"></span>
2021-05-03 02:39:38 +00:00
<span v-if="layers[layer].upgrades[data].effectDisplay"><br>Currently: <span v-html="run(layers[layer].upgrades[data].effectDisplay, layers[layer].upgrades[data])"></span></span>
2020-11-29 21:28:24 +00:00
<br><br>Cost: {{ formatWhole(tmp[layer].upgrades[data].cost) }} {{(tmp[layer].upgrades[data].currencyDisplayName ? tmp[layer].upgrades[data].currencyDisplayName : tmp[layer].resource)}}
2021-06-10 04:54:36 +00:00
</span>
<tooltip v-if="tmp[layer].upgrades[data].tooltip" :text="tmp[layer].upgrades[data].tooltip"></tooltip>
2020-11-29 21:28:24 +00:00
</button>
`
})
Vue.component('milestones', {
2021-06-03 17:26:21 +00:00
props: ['layer', 'data'],
template: `
2020-10-25 01:03:18 +00:00
<div v-if="tmp[layer].milestones">
<table>
2021-06-03 17:26:21 +00:00
<tr v-for="id in (data === undefined ? Object.keys(tmp[layer].milestones) : data)" v-if="tmp[layer].milestones[id]!== undefined && tmp[layer].milestones[id].unlocked && milestoneShown(layer, id)">
<milestone :layer = "layer" :data = "id" v-bind:style="tmp[layer].componentStyles.milestone"></milestone>
2021-05-03 18:50:13 +00:00
</tr>
</table>
<br>
</div>
`
})
// data = id
Vue.component('milestone', {
props: ['layer', 'data'],
template: `
2021-06-10 04:54:36 +00:00
<td v-if="tmp[layer].milestones && tmp[layer].milestones[data]!== undefined && milestoneShown(layer, data) && tmp[layer].milestones[data].unlocked" v-bind:style="[tmp[layer].milestones[data].style]" v-bind:class="{milestone: !hasMilestone(layer, data), tooltipBox: true, milestoneDone: hasMilestone(layer, data)}">
<h3 v-html="tmp[layer].milestones[data].requirementDescription"></h3><br>
2021-05-03 02:39:38 +00:00
<span v-html="run(layers[layer].milestones[data].effectDescription, layers[layer].milestones[data])"></span><br>
2021-06-10 04:54:36 +00:00
<tooltip v-if="tmp[layer].milestones[data].tooltip" :text="tmp[layer].milestones[data].tooltip"></tooltip>
2020-10-21 20:14:42 +00:00
<span v-if="(tmp[layer].milestones[data].toggles)&&(hasMilestone(layer, data))" v-for="toggle in tmp[layer].milestones[data].toggles"><toggle :layer= "layer" :data= "toggle" v-bind:style="tmp[layer].componentStyles.toggle"></toggle>&nbsp;</span></td></tr>
`
})
Vue.component('toggle', {
props: ['layer', 'data'],
template: `
<button class="smallUpg can" v-bind:style="{'background-color': tmp[data[0]].color}" v-on:click="toggleAuto(data)">{{player[data[0]][data[1]]?"ON":"OFF"}}</button>
`
})
Vue.component('prestige-button', {
props: ['layer', 'data'],
template: `
2020-10-15 03:09:30 +00:00
<button v-if="(tmp[layer].type !== 'none')" v-bind:class="{ [layer]: true, reset: true, locked: !tmp[layer].canReset, can: tmp[layer].canReset}"
v-bind:style="[tmp[layer].canReset ? {'background-color': tmp[layer].color} : {}, tmp[layer].componentStyles['prestige-button']]"
2021-05-03 01:29:10 +00:00
v-html="prestigeButtonText(layer)" v-on:click="doReset(layer)">
</button>
`
})
// Displays the main resource for the layer
Vue.component('main-display', {
2021-05-12 02:29:05 +00:00
props: ['layer', 'data'],
template: `
2021-05-12 02:29:05 +00:00
<div><span v-if="player[layer].points.lt('1e1000')">You have </span><h2 v-bind:style="{'color': tmp[layer].color, 'text-shadow': '0px 0px 10px ' + tmp[layer].color}">{{data ? format(player[layer].points, data) : formatWhole(player[layer].points)}}</h2> {{tmp[layer].resource}}<span v-if="layers[layer].effectDescription">, <span v-html="run(layers[layer].effectDescription, layers[layer])"></span></span><br><br></div>
`
})
2020-10-18 00:23:39 +00:00
// Displays the base resource for the layer, as well as the best and total values for the layer's currency, if tracked
Vue.component('resource-display', {
props: ['layer'],
template: `
<div style="margin-top: -13px">
2021-04-07 18:07:22 +00:00
<span v-if="tmp[layer].baseAmount"><br>You have {{formatWhole(tmp[layer].baseAmount)}} {{tmp[layer].baseResource}}</span>
2021-06-02 00:12:14 +00:00
<span v-if="tmp[layer].passiveGeneration"><br>You are gaining {{format(tmp[layer].resetGain.times(tmp[layer].passiveGeneration))}} {{tmp[layer].resource}} per second</span>
2020-10-18 00:23:39 +00:00
<br><br>
<span v-if="tmp[layer].showBest">Your best {{tmp[layer].resource}} is {{formatWhole(player[layer].best)}}<br></span>
<span v-if="tmp[layer].showTotal">You have made a total of {{formatWhole(player[layer].total)}} {{tmp[layer].resource}}<br></span>
2020-10-18 00:23:39 +00:00
</div>
`
})
Vue.component('buyables', {
props: ['layer', 'data'],
template: `
2020-10-25 01:03:18 +00:00
<div v-if="tmp[layer].buyables" class="upgTable">
<respec-button v-if="tmp[layer].buyables.respec && !(tmp[layer].buyables.showRespec !== undefined && tmp[layer].buyables.showRespec == false)" :layer = "layer" v-bind:style="[{'margin-bottom': '12px'}, tmp[layer].componentStyles['respec-button']]"></respec-button>
2021-06-03 18:04:20 +00:00
<div v-for="row in (data === undefined ? tmp[layer].buyables.rows : data)" class="upgRow">
2020-10-25 01:03:18 +00:00
<div v-for="col in tmp[layer].buyables.cols"><div v-if="tmp[layer].buyables[row*10+col]!== undefined && tmp[layer].buyables[row*10+col].unlocked" class="upgAlign" v-bind:style="{'margin-left': '7px', 'margin-right': '7px', 'height': (data ? data : 'inherit'),}">
2021-06-03 18:04:20 +00:00
<buyable :layer = "layer" :data = "row*10+col"></buyable>
</div></div>
<br>
</div>
</div>
`
})
Vue.component('buyable', {
2021-09-08 03:53:54 +00:00
props: ['layer', 'data'],
template: `
2020-10-25 01:03:18 +00:00
<div v-if="tmp[layer].buyables && tmp[layer].buyables[data]!== undefined && tmp[layer].buyables[data].unlocked" style="display: grid">
2021-07-07 17:08:34 +00:00
<button v-bind:class="{ buyable: true, tooltipBox: true, can: tmp[layer].buyables[data].canBuy, locked: !tmp[layer].buyables[data].canBuy, bought: player[layer].buyables[data].gte(tmp[layer].buyables[data].purchaseLimit)}"
2021-09-08 03:53:54 +00:00
v-bind:style="[tmp[layer].buyables[data].canBuy ? {'background-color': tmp[layer].color} : {}, tmp[layer].componentStyles.buyable, tmp[layer].buyables[data].style]"
2021-06-07 23:40:34 +00:00
v-on:click="if(!interval) buyBuyable(layer, data)" :id='"buyable-" + layer + "-" + data' @mousedown="start" @mouseleave="stop" @mouseup="stop" @touchstart="start" @touchend="stop" @touchcancel="stop">
2020-10-17 19:50:30 +00:00
<span v-if= "tmp[layer].buyables[data].title"><h2 v-html="tmp[layer].buyables[data].title"></h2><br></span>
2021-05-03 02:39:38 +00:00
<span v-bind:style="{'white-space': 'pre-line'}" v-html="run(layers[layer].buyables[data].display, layers[layer].buyables[data])"></span>
2021-05-14 19:32:20 +00:00
<node-mark :layer='layer' :data='tmp[layer].buyables[data].marked'></node-mark>
2021-06-10 04:54:36 +00:00
<tooltip v-if="tmp[layer].buyables[data].tooltip" :text="tmp[layer].buyables[data].tooltip"></tooltip>
2021-05-14 19:32:20 +00:00
2020-10-17 19:50:30 +00:00
</button>
2020-10-25 01:03:18 +00:00
<br v-if="(tmp[layer].buyables[data].sellOne !== undefined && !(tmp[layer].buyables[data].canSellOne !== undefined && tmp[layer].buyables[data].canSellOne == false)) || (tmp[layer].buyables[data].sellAll && !(tmp[layer].buyables[data].canSellAll !== undefined && tmp[layer].buyables[data].canSellAll == false))">
<sell-one :layer="layer" :data="data" v-bind:style="tmp[layer].componentStyles['sell-one']" v-if="(tmp[layer].buyables[data].sellOne)&& !(tmp[layer].buyables[data].canSellOne !== undefined && tmp[layer].buyables[data].canSellOne == false)"></sell-one>
<sell-all :layer="layer" :data="data" v-bind:style="tmp[layer].componentStyles['sell-all']" v-if="(tmp[layer].buyables[data].sellAll)&& !(tmp[layer].buyables[data].canSellAll !== undefined && tmp[layer].buyables[data].canSellAll == false)"></sell-all>
2020-10-17 19:50:30 +00:00
</div>
`,
data() { return { interval: false, time: 0,}},
methods: {
start() {
if (!this.interval) {
this.interval = setInterval((function() {
if(this.time >= 5)
buyBuyable(this.layer, this.data)
this.time = this.time+1
}).bind(this), 50)}
},
stop() {
clearInterval(this.interval)
this.interval = false
this.time = 0
}
},
})
2020-10-16 15:39:39 +00:00
Vue.component('respec-button', {
props: ['layer', 'data'],
template: `
2021-06-01 18:56:33 +00:00
<div v-if="tmp[layer].buyables && tmp[layer].buyables.respec && !(tmp[layer].buyables.showRespec !== undefined && tmp[layer].buyables.showRespec == false)">
2021-06-10 05:09:31 +00:00
<div class="tooltipBox respecCheckbox"><input type="checkbox" v-model="player[layer].noRespecConfirm" ><tooltip v-bind:text="'Disable respec confirmation'"></tooltip></div>
2021-06-01 18:56:33 +00:00
<button v-on:click="respecBuyables(layer)" v-bind:class="{ longUpg: true, can: player[layer].unlocked, locked: !player[layer].unlocked }" style="margin-right: 18px">{{tmp[layer].buyables.respecText ? tmp[layer].buyables.respecText : "Respec"}}</button>
</div>
`
2020-10-16 15:39:39 +00:00
})
2020-10-11 20:16:36 +00:00
Vue.component('clickables', {
props: ['layer', 'data'],
template: `
2020-10-25 01:03:18 +00:00
<div v-if="tmp[layer].clickables" class="upgTable">
<master-button v-if="tmp[layer].clickables.masterButtonPress && !(tmp[layer].clickables.showMasterButton !== undefined && tmp[layer].clickables.showMasterButton == false)" :layer = "layer" v-bind:style="[{'margin-bottom': '12px'}, tmp[layer].componentStyles['master-button']]"></master-button>
2021-06-03 18:04:20 +00:00
<div v-for="row in (data === undefined ? tmp[layer].clickables.rows : data)" class="upgRow">
2020-10-25 01:03:18 +00:00
<div v-for="col in tmp[layer].clickables.cols"><div v-if="tmp[layer].clickables[row*10+col]!== undefined && tmp[layer].clickables[row*10+col].unlocked" class="upgAlign" v-bind:style="{'margin-left': '7px', 'margin-right': '7px', 'height': (data ? data : 'inherit'),}">
2021-06-03 18:04:20 +00:00
<clickable :layer = "layer" :data = "row*10+col" v-bind:style="tmp[layer].componentStyles.clickable"></clickable>
2020-10-11 20:16:36 +00:00
</div></div>
<br>
</div>
</div>
`
})
// data = id of clickable
Vue.component('clickable', {
2021-09-08 03:53:54 +00:00
props: ['layer', 'data'],
2020-10-11 20:16:36 +00:00
template: `
<button
2020-10-25 01:03:18 +00:00
v-if="tmp[layer].clickables && tmp[layer].clickables[data]!== undefined && tmp[layer].clickables[data].unlocked"
2021-06-10 04:54:36 +00:00
v-bind:class="{ upg: true, tooltipBox: true, can: tmp[layer].clickables[data].canClick, locked: !tmp[layer].clickables[data].canClick}"
2021-09-08 03:53:54 +00:00
v-bind:style="[tmp[layer].clickables[data].canClick ? {'background-color': tmp[layer].color} : {}, tmp[layer].clickables[data].style]"
2021-06-07 23:40:34 +00:00
v-on:click="if(!interval) clickClickable(layer, data)" :id='"clickable-" + layer + "-" + data' @mousedown="start" @mouseleave="stop" @mouseup="stop" @touchstart="start" @touchend="stop" @touchcancel="stop">
2020-10-11 20:16:36 +00:00
<span v-if= "tmp[layer].clickables[data].title"><h2 v-html="tmp[layer].clickables[data].title"></h2><br></span>
2021-05-03 02:39:38 +00:00
<span v-bind:style="{'white-space': 'pre-line'}" v-html="run(layers[layer].clickables[data].display, layers[layer].clickables[data])"></span>
2021-05-14 19:32:20 +00:00
<node-mark :layer='layer' :data='tmp[layer].clickables[data].marked'></node-mark>
2021-06-10 04:54:36 +00:00
<tooltip v-if="tmp[layer].clickables[data].tooltip" :text="tmp[layer].clickables[data].tooltip"></tooltip>
2020-10-11 20:16:36 +00:00
</button>
`,
data() { return { interval: false, time: 0,}},
methods: {
start() {
if (!this.interval && layers[this.layer].clickables[this.data].onHold) {
this.interval = setInterval((function() {
let c = layers[this.layer].clickables[this.data]
if(this.time >= 5 && run(c.canClick, c)) {
run(c.onHold, c)
}
this.time = this.time+1
}).bind(this), 50)}
},
stop() {
clearInterval(this.interval)
this.interval = false
this.time = 0
}
},
2020-10-11 20:16:36 +00:00
})
2020-10-16 15:39:39 +00:00
Vue.component('master-button', {
props: ['layer', 'data'],
template: `
2020-12-13 02:43:22 +00:00
<button v-if="tmp[layer].clickables && tmp[layer].clickables.masterButtonPress && !(tmp[layer].clickables.showMasterButton !== undefined && tmp[layer].clickables.showMasterButton == false)"
v-on:click="run(tmp[layer].clickables.masterButtonPress, tmp[layer].clickables)" v-bind:class="{ longUpg: true, can: player[layer].unlocked, locked: !player[layer].unlocked }">{{tmp[layer].clickables.masterButtonText ? tmp[layer].clickables.masterButtonText : "Click me!"}}</button>
2020-10-16 15:39:39 +00:00
`
})
2020-10-11 20:16:36 +00:00
2021-05-11 06:27:50 +00:00
2021-09-08 03:53:54 +00:00
// data = optionally, array of rows for the grid to show
2021-05-11 06:27:50 +00:00
Vue.component('grid', {
props: ['layer', 'data'],
template: `
<div v-if="tmp[layer].grid" class="upgTable">
2021-06-03 17:26:21 +00:00
<div v-for="row in (data === undefined ? tmp[layer].grid.rows : data)" class="upgRow">
2021-05-11 06:27:50 +00:00
<div v-for="col in tmp[layer].grid.cols"><div v-if="run(layers[layer].grid.getUnlocked, layers[layer].grid, row*100+col)"
class="upgAlign" v-bind:style="{'margin': '1px', 'height': 'inherit',}">
<gridable :layer = "layer" :data = "row*100+col" v-bind:style="tmp[layer].componentStyles.gridable"></gridable>
</div></div>
<br>
</div>
</div>
`
})
Vue.component('gridable', {
props: ['layer', 'data'],
template: `
<button
v-if="tmp[layer].grid && player[layer].grid[data]!== undefined && run(layers[layer].grid.getUnlocked, layers[layer].grid, data)"
2021-06-10 04:54:36 +00:00
v-bind:class="{ tile: true, can: canClick, locked: !canClick, tooltipBox: true,}"
2021-05-11 06:27:50 +00:00
v-bind:style="[canClick ? {'background-color': tmp[layer].color} : {}, gridRun(layer, 'getStyle', player[this.layer].grid[this.data], this.data)]"
v-on:click="clickGrid(layer, data)" @mousedown="start" @mouseleave="stop" @mouseup="stop" @touchstart="start" @touchend="stop" @touchcancel="stop">
<span v-if= "layers[layer].grid.getTitle"><h3 v-html="gridRun(this.layer, 'getTitle', player[this.layer].grid[this.data], this.data)"></h3><br></span>
2021-06-10 04:54:36 +00:00
<span v-bind:style="{'white-space': 'pre-line'}" v-html="gridRun(this.layer, 'getDisplay', player[this.layer].grid[this.data], this.data)"></span>
<tooltip v-if="layers[layer].grid.getTooltip" :text="gridRun(this.layer, 'getTooltip', player[this.layer].grid[this.data], this.data)"></tooltip>
2021-05-11 06:27:50 +00:00
</button>
`,
data() { return { interval: false, time: 0,}},
computed: {
canClick() {
return gridRun(this.layer, 'getCanClick', player[this.layer].grid[this.data], this.data)}
},
methods: {
start() {
if (!this.interval && layers[this.layer].grid.onHold) {
this.interval = setInterval((function() {
if(this.time >= 5 && gridRun(this.layer, 'getCanClick', player[this.layer].grid[this.data], this.data)) {
gridRun(this.layer, 'onHold', player[this.layer].grid[this.data], this.data) }
this.time = this.time+1
}).bind(this), 50)}
},
stop() {
clearInterval(this.interval)
this.interval = false
this.time = 0
}
},
})
2021-09-08 03:53:54 +00:00
// data = id of microtab family
Vue.component('microtabs', {
props: ['layer', 'data'],
computed: {
currentTab() {return player.subtabs[layer][data]}
},
template: `
2020-10-25 01:03:18 +00:00
<div v-if="tmp[layer].microtabs" :style="{'border-style': 'solid'}">
2020-11-29 02:25:53 +00:00
<div class="upgTable instant">
<tab-buttons :layer="layer" :data="tmp[layer].microtabs[data]" :name="data" v-bind:style="tmp[layer].componentStyles['tab-buttons']"></tab-buttons>
</div>
2020-12-05 19:52:29 +00:00
<layer-tab v-if="tmp[layer].microtabs[data][player.subtabs[layer][data]].embedLayer" :layer="tmp[layer].microtabs[data][player.subtabs[layer][data]].embedLayer" :embedded="true"></layer-tab>
2020-10-27 23:25:03 +00:00
2020-10-28 02:04:16 +00:00
<column v-else v-bind:style="tmp[layer].microtabs[data][player.subtabs[layer][data]].style" :layer="layer" :data="tmp[layer].microtabs[data][player.subtabs[layer][data]].content"></column>
</div>
`
})
2020-10-12 22:28:12 +00:00
// data = id of the bar
Vue.component('bar', {
2020-10-09 03:13:15 +00:00
props: ['layer', 'data'],
2021-05-03 02:39:38 +00:00
computed: {
style() {return constructBarStyle(this.layer, this.data)}
2021-05-03 02:39:38 +00:00
},
2020-10-09 03:13:15 +00:00
template: `
<div v-if="tmp[layer].bars && tmp[layer].bars[data].unlocked" v-bind:style="{'position': 'relative'}"><div v-bind:style="[tmp[layer].bars[data].style, style.dims, {'display': 'table'}]">
<div class = "overlayTextContainer barBorder" v-bind:style="[tmp[layer].bars[data].borderStyle, style.dims]">
2021-05-03 02:39:38 +00:00
<span class = "overlayText" v-bind:style="[tmp[layer].bars[data].style, tmp[layer].bars[data].textStyle]" v-html="run(layers[layer].bars[data].display, layers[layer].bars[data])"></span>
2020-10-12 22:28:12 +00:00
</div>
<div class ="barBG barBorder" v-bind:style="[tmp[layer].bars[data].style, tmp[layer].bars[data].baseStyle, tmp[layer].bars[data].borderStyle, style.dims]">
<div class ="fill" v-bind:style="[tmp[layer].bars[data].style, tmp[layer].bars[data].fillStyle, style.fillDims]"></div>
2020-10-16 22:45:44 +00:00
</div>
2020-10-12 22:28:12 +00:00
</div></div>
2020-10-09 03:13:15 +00:00
`
})
2020-10-12 22:28:12 +00:00
2020-10-15 01:43:16 +00:00
Vue.component('achievements', {
2021-06-03 17:26:21 +00:00
props: ['layer', 'data'],
2020-10-15 01:43:16 +00:00
template: `
2020-10-25 01:03:18 +00:00
<div v-if="tmp[layer].achievements" class="upgTable">
2021-06-03 17:26:21 +00:00
<div v-for="row in (data === undefined ? tmp[layer].achievements.rows : data)" class="upgRow">
2020-10-25 01:03:18 +00:00
<div v-for="col in tmp[layer].achievements.cols"><div v-if="tmp[layer].achievements[row*10+col]!== undefined && tmp[layer].achievements[row*10+col].unlocked" class="upgAlign">
2020-10-15 01:43:16 +00:00
<achievement :layer = "layer" :data = "row*10+col" v-bind:style="tmp[layer].componentStyles.achievement"></achievement>
</div></div>
</div>
<br>
</div>
`
})
// data = id
Vue.component('achievement', {
props: ['layer', 'data'],
2020-10-15 01:43:16 +00:00
template: `
<div v-if="tmp[layer].achievements && tmp[layer].achievements[data]!== undefined && tmp[layer].achievements[data].unlocked" v-bind:class="{ [layer]: true, achievement: true, tooltipBox:true, locked: !hasAchievement(layer, data), bought: hasAchievement(layer, data)}"
2021-05-03 02:39:38 +00:00
v-bind:style="achievementStyle(layer, data)">
<tooltip :text="
(tmp[layer].achievements[data].tooltip == '') ? false : hasAchievement(layer, data) ? (tmp[layer].achievements[data].doneTooltip ? tmp[layer].achievements[data].doneTooltip : (tmp[layer].achievements[data].tooltip ? tmp[layer].achievements[data].tooltip : 'You did it!'))
: (tmp[layer].achievements[data].goalTooltip ? tmp[layer].achievements[data].goalTooltip : (tmp[layer].achievements[data].tooltip ? tmp[layer].achievements[data].tooltip : 'LOCKED'))
"></tooltip>
2020-12-09 06:36:27 +00:00
<span v-if= "tmp[layer].achievements[data].name"><br><h3 v-bind:style="tmp[layer].achievements[data].textStyle" v-html="tmp[layer].achievements[data].name"></h3><br></span>
2020-10-15 01:43:16 +00:00
</div>
`
})
2020-10-28 02:04:16 +00:00
// Data is an array with the structure of the tree
Vue.component('tree', {
props: ['layer', 'data'],
computed: {
key() {return this.$vnode.key}
},
2020-10-28 02:04:16 +00:00
template: `<div>
2020-12-17 02:41:31 +00:00
<span class="upgRow" v-for="(row, r) in data"><table>
2020-12-14 03:23:12 +00:00
<span v-for="(node, id) in row" style = "{width: 0px}">
2021-05-26 05:44:12 +00:00
<tree-node :layer='node' :prev='layer' :abb='tmp[node].symbol' :key="key + '-' + r + '-' + id"></tree-node>
2020-12-14 03:23:12 +00:00
</span>
2020-10-28 02:04:16 +00:00
<tr><table><button class="treeNode hidden"></button></table></tr>
</span></div>
`
})
2021-06-03 17:02:47 +00:00
// Data is an array with the structure of the tree
Vue.component('upgrade-tree', {
props: ['layer', 'data'],
computed: {
key() {return this.$vnode.key}
},
2021-06-07 04:29:22 +00:00
template: `<thing-tree :layer="layer" :data = "data" :type = "'upgrade'"></thing-tree>`
})
// Data is an array with the structure of the tree
2021-06-07 23:40:34 +00:00
Vue.component('buyable-tree', {
props: ['layer', 'data'],
computed: {
key() {return this.$vnode.key}
},
template: `<thing-tree :layer="layer" :data = "data" :type = "'buyable'"></thing-tree>`
})
// Data is an array with the structure of the tree
Vue.component('clickable-tree', {
props: ['layer', 'data'],
computed: {
key() {return this.$vnode.key}
},
template: `<thing-tree :layer="layer" :data = "data" :type = "'clickable'"></thing-tree>`
})
2021-06-07 04:29:22 +00:00
Vue.component('thing-tree', {
props: ['layer', 'data', 'type'],
computed: {
key() {return this.$vnode.key}
},
2021-06-03 17:02:47 +00:00
template: `<div>
<span class="upgRow" v-for="(row, r) in data"><table>
2021-06-07 04:29:22 +00:00
<span v-for="id in row" style = "{width: 0px; height: 0px;}" v-if="tmp[layer][type+'s'][id]!== undefined && tmp[layer][type+'s'][id].unlocked" class="upgAlign">
<div v-bind:is="type" :layer = "layer" :data = "id" v-bind:style="tmp[layer].componentStyles[type]" class = "treeThing"></div>
2021-06-03 17:02:47 +00:00
</span>
<tr><table><button class="treeNode hidden"></button></table></tr>
</span></div>
`
})
2021-06-07 04:29:22 +00:00
2021-04-27 02:43:36 +00:00
// Updates the value in player[layer][data]
Vue.component('text-input', {
props: ['layer', 'data'],
template: `
<input class="instant" :id="'input-' + layer + '-' + data" :value="player[layer][data].toString()" v-on:focus="focused(true)" v-on:blur="focused(false)"
v-on:change="player[layer][data] = toValue(document.getElementById('input-' + layer + '-' + data).value, player[layer][data])">
`
})
2021-06-03 14:28:07 +00:00
// Updates the value in player[layer][data][0]
2021-04-27 03:16:34 +00:00
Vue.component('slider', {
props: ['layer', 'data'],
template: `
<div class="tooltipBox">
<tooltip :text="player[layer][data[0]]"></tooltip><input type="range" v-model="player[layer][data[0]]" :min="data[1]" :max="data[2]"></div>
2021-04-27 03:16:34 +00:00
`
})
2021-04-27 02:43:36 +00:00
2021-06-03 14:28:07 +00:00
// Updates the value in player[layer][data[0]], options are an array in data[1]
Vue.component('drop-down', {
props: ['layer', 'data'],
template: `
<select v-model="player[layer][data[0]]">
<option v-for="item in data[1]" v-bind:value="item">{{item}}</option>
</select>
`
})
2020-10-17 19:50:30 +00:00
// These are for buyables, data is the id of the corresponding buyable
Vue.component('sell-one', {
props: ['layer', 'data'],
template: `
2020-12-13 02:43:22 +00:00
<button v-if="tmp[layer].buyables && tmp[layer].buyables[data].sellOne && !(tmp[layer].buyables[data].canSellOne !== undefined && tmp[layer].buyables[data].canSellOne == false)" v-on:click="run(tmp[layer].buyables[data].sellOne, tmp[layer].buyables[data])"
v-bind:class="{ longUpg: true, can: player[layer].unlocked, locked: !player[layer].unlocked }">{{tmp[layer].buyables.sellOneText ? tmp[layer].buyables.sellOneText : "Sell One"}}</button>
2020-10-17 19:50:30 +00:00
`
})
Vue.component('sell-all', {
props: ['layer', 'data'],
template: `
2020-12-13 02:43:22 +00:00
<button v-if="tmp[layer].buyables && tmp[layer].buyables[data].sellAll && !(tmp[layer].buyables[data].canSellAll !== undefined && tmp[layer].buyables[data].canSellAll == false)" v-on:click="run(tmp[layer].buyables[data].sellAll, tmp[layer].buyables[data])"
v-bind:class="{ longUpg: true, can: player[layer].unlocked, locked: !player[layer].unlocked }">{{tmp[layer].buyables.sellAllText ? tmp[layer].buyables.sellAllText : "Sell All"}}</button>
2020-10-17 19:50:30 +00:00
`
})
2020-10-30 17:27:23 +00:00
// SYSTEM COMPONENTS
2021-05-12 03:04:59 +00:00
Vue.component('node-mark', systemComponents['node-mark'])
2020-10-30 17:27:23 +00:00
Vue.component('tab-buttons', systemComponents['tab-buttons'])
Vue.component('tree-node', systemComponents['tree-node'])
2020-10-30 17:27:23 +00:00
Vue.component('layer-tab', systemComponents['layer-tab'])
Vue.component('overlay-head', systemComponents['overlay-head'])
2020-10-30 23:40:48 +00:00
Vue.component('info-tab', systemComponents['info-tab'])
Vue.component('options-tab', systemComponents['options-tab'])
2021-04-27 05:26:07 +00:00
Vue.component('tooltip', systemComponents['tooltip'])
2021-05-14 01:40:51 +00:00
Vue.component('particle', systemComponents['particle'])
2021-06-02 22:51:33 +00:00
Vue.component('bg', systemComponents['bg'])
2020-10-27 23:25:03 +00:00
2020-08-19 02:50:24 +00:00
app = new Vue({
2020-09-11 02:15:05 +00:00
el: "#app",
data: {
player,
tmp,
2021-06-03 05:04:56 +00:00
options,
2020-09-11 02:15:05 +00:00
Decimal,
format,
formatWhole,
formatTime,
2021-05-13 06:51:18 +00:00
formatSmall,
2020-09-11 02:15:05 +00:00
focused,
2020-09-14 19:26:10 +00:00
getThemeName,
layerunlocked,
2020-09-11 02:15:05 +00:00
doReset,
buyUpg,
buyUpgrade,
startChallenge,
2020-09-11 02:15:05 +00:00
milestoneShown,
keepGoing,
2020-11-07 21:59:14 +00:00
hasUpgrade,
hasMilestone,
hasAchievement,
hasChallenge,
maxedChallenge,
getBuyableAmount,
getClickableState,
inChallenge,
2020-11-07 21:59:14 +00:00
canAffordUpgrade,
2021-05-01 02:40:59 +00:00
canBuyBuyable,
canCompleteChallenge,
2020-11-08 04:34:53 +00:00
subtabShouldNotify,
subtabResetNotify,
2021-05-03 02:39:38 +00:00
challengeStyle,
challengeButtonText,
constructBarStyle,
2021-05-14 05:38:17 +00:00
constructParticleStyle,
2020-09-14 19:26:10 +00:00
VERSION,
LAYERS,
2020-12-07 03:56:37 +00:00
hotkeys,
activePopups,
2021-05-14 01:40:51 +00:00
particles,
mouseX,
mouseY,
shiftDown,
ctrlDown,
2021-06-03 14:28:07 +00:00
run,
gridRun,
2020-09-11 02:15:05 +00:00
},
2020-08-19 02:50:24 +00:00
})
2020-10-09 01:41:50 +00:00
}