-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoppDeckRenderer.js
86 lines (62 loc) · 2.1 KB
/
oppDeckRenderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const {ipcRenderer, remote} = require('electron');
const createCanvas = require('./createCanvas.js');
const Store = require('electron-store');
const config = new Store();
const log = require("electron-log");
log.catchErrors();
ipcRenderer.on('update', (event, test) => {
updateOppDeck();
});
ipcRenderer.on('resize', (event, width, height) => {
this.width = width;
this.height = height;
updateTracker();
});
$(".font-loader").each(function() {
this.remove();
})
function minimize() {
if (document.getElementById("cardContents").style.display == "none") {
document.getElementById("cardContents").style.display = "block";
ipcRenderer.send('size', config.get("opponent-deck-height"), "oppDeck");
}
else {
document.getElementById("cardContents").style.display = "none";
ipcRenderer.send('size', $("#top").height(), "oppDeck");
}
updateTracker();
}
document.getElementById("top-container").style.opacity = config.get("opponent-deck-opacity");
document.getElementById("cardContents").style.opacity = config.get("card-opacity");
var cTop = document.getElementById("top");
var ctxTop = cTop.getContext("2d");
ctxTop.scale(cTop.width/226,cTop.height/40);
var imgStart = new Image;
imgStart.src = './images/top-window.png';
imgStart.onload = function () {
ctxTop.drawImage(imgStart, 0 ,0);
ctxTop.textAlign = "center";
ctxTop.fillStyle = "white";
ctxTop.font = "16px BeaufortforLOL-Bold";
ctxTop.fillText("OPPONENT", imgStart.width / 2, imgStart.height / 2 + 5);
};
var cardArr = [];
var imgCard;
var width;
var height;
var margin = 3;
function updateOppDeck() {
cardArr = remote.getGlobal('oppDeckArr');
updateTracker();
}
function updateTracker() {
cardArr.sort((a,b) => (a.mana > b.mana) ? 1 : ((b.mana > a.mana) ? -1 : 0));
createCanvas.render($("#cardContents"), cardArr);
}
function previewCard (cardCode, element) {
ipcRenderer.send('preview', "./cards/" + cardCode + ".webp", "x", parseInt(element.getBoundingClientRect()['y']), "oppDeck");
/// Send Quantity
}
function unpreviewCard () {
ipcRenderer.send('unpreview');
}