mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2024-11-21 16:13:55 +00:00
Add "click-and-drag-to-buy" feature to upgrades
This commit is contained in:
parent
bfbd41aad4
commit
95711f4af7
1 changed files with 10 additions and 2 deletions
|
@ -172,7 +172,7 @@ function loadVue() {
|
|||
Vue.component('upgrade', {
|
||||
props: ['layer', 'data'],
|
||||
template: `
|
||||
<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))}"
|
||||
<button v-if="tmp[layer].upgrades && tmp[layer].upgrades[data]!== undefined && tmp[layer].upgrades[data].unlocked" :id='"upgrade-" + layer + "-" + data' v-on:mousedown="handleMouseEvent" v-on:mouseenter="handleMouseEvent" 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]">
|
||||
<span v-if="layers[layer].upgrades[data].fullDisplay" v-html="run(layers[layer].upgrades[data].fullDisplay, layers[layer].upgrades[data])"></span>
|
||||
<span v-else>
|
||||
|
@ -184,7 +184,15 @@ function loadVue() {
|
|||
<tooltip v-if="tmp[layer].upgrades[data].tooltip" :text="tmp[layer].upgrades[data].tooltip"></tooltip>
|
||||
|
||||
</button>
|
||||
`
|
||||
`,
|
||||
methods: {
|
||||
handleMouseEvent(event) {
|
||||
// event.buttons is a bitmask, 0b1 is primary mouse button (usually left)
|
||||
if (event.buttons & 1) {
|
||||
buyUpg(this.layer, this.data)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Vue.component('milestones', {
|
||||
|
|
Loading…
Reference in a new issue