Skip to content

Commit 1f31ddb

Browse files
Add Preview Card Size Option
1 parent d2b178a commit 1f31ddb

File tree

4 files changed

+56
-37
lines changed

4 files changed

+56
-37
lines changed

config-cards.html

+39-25
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,42 @@ <h2>Cards</h2>
44
<div>
55
<table class="table" style="margin-bottom: 0;">
66
<tbody>
7-
<tr>
8-
<th scope="row"><h5 class="no-margin">Misc.</h4></th>
9-
<td></td>
10-
</tr>
11-
<tr>
12-
<th scope="row" style="padding-left: 40px;">Opacity</th>
13-
<td>
14-
<input type="text" class="form-control" id="card-opacity">
15-
</td>
16-
</tr>
17-
<tr>
18-
<th scope="row" style="padding-left: 40px;">Margin</th>
19-
<td>
20-
<input type="text" class="form-control" id="margin">
21-
</td>
22-
</tr>
23-
<tr>
24-
<th scope="row" style="padding-left: 60px;">
25-
<input type="checkbox" class="form-check-input" id="swap-increment">
26-
<label class="form-check-label" for="swap-increment">Swap Increment and Decrement</label>
27-
</th>
28-
<td>
7+
<tr>
8+
<th scope="row"><h5 class="no-margin">Preview Card Size</h4></th>
9+
<td></td>
10+
</tr>
11+
<tr>
12+
<th scope="row" style="padding-left: 40px;">Width</th>
13+
<td>
14+
<input type="text" class="form-control" id="preview-width">
15+
</td>
16+
</tr>
17+
<tr>
18+
<th scope="row"><h5 class="no-margin">Card Stack</h4></th>
19+
<td></td>
20+
</tr>
21+
<tr>
22+
<th scope="row" style="padding-left: 40px;">Opacity</th>
23+
<td>
24+
<input type="text" class="form-control" id="card-opacity">
25+
</td>
26+
</tr>
27+
<tr>
28+
<th scope="row" style="padding-left: 40px;">Margin</th>
29+
<td>
30+
<input type="text" class="form-control" id="margin">
31+
</td>
32+
</tr>
33+
<tr>
34+
<th scope="row" style="padding-left: 60px;">
35+
<input type="checkbox" class="form-check-input" id="swap-increment">
36+
<label class="form-check-label" for="swap-increment">Swap Increment and Decrement</label>
37+
</th>
38+
<td>
2939

30-
</td>
31-
</tr>
40+
</td>
41+
</tr>
42+
</tbody>
3243

3344
</table>
3445
<div class="d-flex">
@@ -40,12 +51,15 @@ <h2>Cards</h2>
4051
<script>
4152
$("#card-opacity").val(config.get("card-opacity"));
4253
$("#margin").val(config.get("margin"));
54+
$("#preview-width").val(config.get("preview-width"));
4355
$('#swap-increment').prop('checked', config.get("swap-increment"));
4456

4557
$('#save').click(function() {
4658
config.set("card-opacity", parseFloat($("#card-opacity").val()));
47-
config.set("margin", parseFloat($("#margin").val()));
59+
config.set("margin", parseInt($("#margin").val()));
60+
config.set("preview-width", parseInt($("#preview-width").val()));
4861
config.set("swap-increment", $('#swap-increment').is(':checked'));
4962
require("electron").ipcRenderer.send('saveUpdate');
63+
// Reload details window
5064
})
5165
</script>

main.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ const config = new Store({
2929
"record-ai-games": false,
3030
"hotkey": "Control+Shift+D",
3131
"dark-mode": true,
32-
"exit-on-close": false,
32+
"exit-on-close": true,
3333
"margin": 3,
34-
"swap-increment": false
34+
"swap-increment": false,
35+
"preview-width": 340
3536
}
3637
});
3738
const data = new Store({
@@ -171,7 +172,7 @@ function createWindow () {
171172
nodeIntegration:true
172173
}
173174
})
174-
mainWindow.webContents.openDevTools()
175+
//mainWindow.webContents.openDevTools()
175176
mainWindow.loadFile("main.html");
176177

177178
mainWindow.on('close', function (event) {
@@ -238,8 +239,8 @@ function createWindow () {
238239
});
239240

240241
fullCardWindow = new BrowserWindow({
241-
width:340,
242-
height:512,
242+
width:config.get("preview-width"),
243+
height:parseInt(config.get("preview-width") * 512 / 340),
243244
maximizable:false,
244245
transparent:true,
245246
skipTaskbar:true,
@@ -388,6 +389,7 @@ function createWindow () {
388389
let windowPosition;
389390
let windowSize;
390391
let windowY;
392+
let fullSize = fullCardWindow.getSize();
391393

392394
switch (window) {
393395
case "tracker":
@@ -409,18 +411,18 @@ function createWindow () {
409411
break;
410412
}
411413

412-
if (windowPosition[1] - 256 + y < 0) {
414+
if (windowPosition[1] - (fullSize[1] / 2) + y < 0) {
413415
windowY = 0;
414416
}
415-
else if (windowPosition[1] + 256 + y > screen.getPrimaryDisplay().workAreaSize.height) {
416-
windowY = screen.getPrimaryDisplay().workAreaSize.height - 512;
417+
else if (windowPosition[1] + (fullSize[1] / 2) + y > screen.getPrimaryDisplay().workAreaSize.height) {
418+
windowY = parseInt(screen.getPrimaryDisplay().workAreaSize.height - fullSize[1]);
417419
}
418420
else {
419-
windowY = windowPosition[1] - 256 + y;
421+
windowY = parseInt(windowPosition[1] - (fullSize[1] / 2) + y);
420422
}
421423

422424
if (windowPosition[0] > screen.getPrimaryDisplay().workAreaSize.width / 2 || window === "main") { // config
423-
fullCardWindow.setPosition(windowPosition[0] - 340, windowY);
425+
fullCardWindow.setPosition(windowPosition[0] - fullSize[0], windowY);
424426
}
425427
else {
426428
fullCardWindow.setPosition(windowPosition[0] + windowSize[0], windowY);
@@ -477,6 +479,9 @@ function createWindow () {
477479
if (config.get("opponent-deck-disabled")) {
478480
oppDeckWindow.hide();
479481
}
482+
483+
fullCardWindow.setSize(config.get("preview-width"), parseInt(config.get("preview-width") * 512 / 340));
484+
480485
});
481486

482487
registerHotkeys();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lor-tracker",
3-
"version": "1.4.1",
3+
"version": "1.5.0",
44
"description": "A deck tracker for Legends of Runeterra",
55
"main": "main.js",
66
"scripts": {

previewCard.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<link rel="stylesheet" href="myStyle.css">
33
</head>
44
<body>
5-
<img class="full-card" id="card">
5+
<img class="full" id="card">
66
</body>
77
<script>
88
const {ipcRenderer} = require('electron');

0 commit comments

Comments
 (0)