Skip to content

Commit

Permalink
✨ Support ct.touch module in ct.vkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Apr 22, 2019
1 parent afad9eb commit 33c5384
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions app/data/ct.libs/vkeys/injects/types.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
ct.types.templates.VKEY = {
onStep: function () {
if (ct.mouse.hovers(this)) {
this.tex = this.opts.texHover || this.opts.texNormal;
if (ct.mouse.down) {
this.tex = this.opts.texActive || this.opts.texNormal;
ct.inputs.registry['vkeys.' + this.opts.key] = 1;
} else {
ct.inputs.registry['vkeys.' + this.opts.key] = 0;
var down = false,
hover = false;
if (ct.mouse) {
if (ct.mouse.hovers(this)) {
hover = true;
if (ct.mouse.down) {
down = true;
}
}
}
if (ct.touch) {
for (const touch of ct.touch.events) {
if (ct.touch.collide(this, touch.id)) {
down = hover = true;
break;
}
}
}

if (down) {
this.tex = this.opts.texActive || this.opts.texNormal;
ct.inputs.registry['vkeys.' + this.opts.key] = 1;
} else {
this.tex = this.opts.texNormal;
ct.inputs.registry['vkeys.' + this.opts.key] = 0;
if (hover) {
this.tex = this.opts.texHover || this.opts.texNormal;
} else {
this.tex = this.opts.texNormal;
}
}
},
onDraw: function () {
Expand Down

0 comments on commit 33c5384

Please sign in to comment.