Skip to content

Commit 0a4a459

Browse files
committed
New: Custom keyboard and gamepad shortcuts
1 parent 9ba46d7 commit 0a4a459

File tree

113 files changed

+1812
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1812
-478
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010

1111
- Reload button in file list [`31675a5`](https://github.com/ollm/OpenComic/commit/31675a5a8334abedc056a09a5107f718dc5304e0)
1212
- Check if there is a new version when starting OpenComic [`82f1abd`](https://github.com/ollm/OpenComic/commit/82f1abdac5c1ae6f26e88f5f2374c54edcfcaae7)
13+
- Custom keyboard and gamepad shortcuts
1314

1415
### 🐛 Bug Fixes
1516

languages/ca.json

+17
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"currentReading": "Lectura actual"
9999
},
100100
"settings": {
101+
"general": "General",
101102
"reading": {
102103
"main": "Preferències de lectura",
103104
"maxMargin": "Marge horitzontal i vertical màxim",
@@ -116,6 +117,22 @@
116117
"main": "Comprovar noves versions",
117118
"checkReleases": "Comprovar si hi ha una nova versió en iniciar OpenComic",
118119
"checkPreReleases": "Mostrar versions preliminars (versions beta/alfa)"
120+
},
121+
"shortcuts": {
122+
"main": "Dreceres",
123+
"keyboard": "Teclat",
124+
"whenReading": "A l'hora de llegir",
125+
"gamepadMenu": "Menú del comandament",
126+
"useGamepad": "Fes servir un comandament per canviar l'acció",
127+
"restoreDefaults": "Restaurar valors per defecte",
128+
"action": "Acció",
129+
"key1": "Tecla 1",
130+
"key2": "Tecla 2",
131+
"key3": "Tecla 3",
132+
"key4": "Tecla 4",
133+
"key5": "Tecla 5",
134+
"gamepad1": "Botó 1",
135+
"gamepad2": "Botó 2"
119136
}
120137
},
121138
"menu": {

languages/en.json

+17
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"currentReading": "Current reading"
9999
},
100100
"settings": {
101+
"general": "General",
101102
"reading": {
102103
"main": "Reading preferences",
103104
"maxMargin": "Maximum horizontal and vertical margin",
@@ -116,6 +117,22 @@
116117
"main": "Check for new versions",
117118
"checkReleases": "Check if there is a new version when starting OpenComic",
118119
"checkPreReleases": "Show pre-release versions (beta/alpha versions)"
120+
},
121+
"shortcuts": {
122+
"main": "Shortcuts",
123+
"keyboard": "Keyboard",
124+
"whenReading": "When reading",
125+
"gamepadMenu": "Gamepad menu",
126+
"useGamepad": "Use a gamepad to change the action",
127+
"restoreDefaults": "Restore default values",
128+
"action": "Action",
129+
"key1": "Key 1",
130+
"key2": "Key 2",
131+
"key3": "Key 3",
132+
"key4": "Key 4",
133+
"key5": "Key 5",
134+
"gamepad1": "Button 1",
135+
"gamepad2": "Button 2"
119136
}
120137
},
121138
"menu": {

languages/es.json

+18-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"currentReading": "Lectura actual"
9999
},
100100
"settings": {
101+
"general": "General",
101102
"reading": {
102103
"main": "Preferencias de lectura",
103104
"maxMargin": "Margen horizontal y vertical máximo",
@@ -109,13 +110,29 @@
109110
"showFullPathOpened": "Mostrar la ruta completa al abrir un archivo o carpeta"
110111
},
111112
"others": {
112-
"main": "Otras ajustes",
113+
"main": "Otros ajustes",
113114
"startInFullScreen": "Inicial OpenComic en pantalla completa"
114115
},
115116
"releases": {
116117
"main": "Comprobar nuevas versiones",
117118
"checkReleases": "Comprobar si existe una nueva versión al iniciar OpenComic",
118119
"checkPreReleases": "Mostrar versiones preliminares (versiones beta/alfa)"
120+
},
121+
"shortcuts": {
122+
"main": "Atajos",
123+
"keyboard": "Teclado",
124+
"whenReading": "Al leer",
125+
"gamepadMenu": "Menú del mando",
126+
"useGamepad": "Utiliza un mando para cambiar la acción",
127+
"restoreDefaults": "Restaurar valores por defecto",
128+
"action": "Acción",
129+
"key1": "Tecla 1",
130+
"key2": "Tecla 2",
131+
"key3": "Tecla 3",
132+
"key4": "Tecla 4",
133+
"key5": "Tecla 5",
134+
"gamepad1": "Botón 1",
135+
"gamepad2": "Botón 2"
119136
}
120137
},
121138
"menu": {

package-lock.json

+12-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"productName": "OpenComic",
44
"version": "1.0.0-beta.2",
55
"main": "scripts/main.js",
6+
"type": "commonjs",
67
"keywords": [
78
"comics",
89
"manga",
@@ -22,7 +23,7 @@
2223
"url": "git+https://github.com/ollm/OpenComic.git"
2324
},
2425
"scripts": {
25-
"start": "npm run prebuild && electron --trace-warnings scripts/main.js",
26+
"start": "npm run prebuild && electron --trace-warnings --enable-logging scripts/main.js",
2627
"rebuild": "electron-rebuild -f -w sharp",
2728
"rebuild2": "electron-builder node-gyp-rebuild",
2829
"prebuild": "node scripts/build.js; node themes/material-design/colors/generate-colors.js",
@@ -71,13 +72,14 @@
7172
"pdfjs-dist": "^3.8.162",
7273
"sha1": "^1.1.1",
7374
"sharp": "^0.32.4",
75+
"shosho": "^1.4.2",
7476
"tar-fs": "^3.0.4",
7577
"unrar": "^0.2.0",
7678
"unzipper": "^0.10.14"
7779
},
7880
"devDependencies": {
7981
"@electron/rebuild": "^3.2.13",
80-
"electron": "^25.5.0",
82+
"electron": "^27.0.0-alpha.2",
8183
"electron-builder": "^24.6.3",
8284
"node-abi": "^3.46.0",
8385
"nodemon": "^3.0.1"

scripts/dom.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
735735

736736
justifyViewModule();
737737

738+
shortcuts.register('browse');
738739
gamepad.updateBrowsableItems(path ? sha1(path) : 'library');
739740

740741
$(window).off('resize').on('resize', function(){
@@ -1061,6 +1062,7 @@ function loadLanguagesPage(animation = true)
10611062
floatingActionButton(false);
10621063

10631064
events.events();
1065+
gamepad.updateBrowsableItems('languagesPage');
10641066

10651067
if(readingActive)
10661068
readingActive = false;
@@ -1524,13 +1526,14 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
15241526

15251527
generateAppMenu();
15261528

1529+
shortcuts.register('reading');
15271530
gamepad.updateBrowsableItems('reading-'+sha1(path));
15281531
}
15291532

15301533
// Gamepad events
15311534
gamepad.setButtonEvent('reading', 1, function(key, button) {
15321535

1533-
if(key == 1)
1536+
if(key == 1 && !onReading)
15341537
gamepad.goBack();
15351538

15361539
});

scripts/drag-and-drop.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ function showDropZone(event)
99
clearTimeout(hideDropZoneST);
1010
clearTimeout(showDropZoneST);
1111

12+
allowDrag(event);
13+
1214
let dropZone = document.querySelector('.drop-zone');
1315

1416
if(!dragAndDropStarted)
@@ -61,10 +63,10 @@ function hideDropZone(event, force = false)
6163

6264
}
6365

64-
function checkDragPosition()
66+
function allowDrag(event)
6567
{
66-
event.dataTransfer.dropEffect = 'link';
6768
event.preventDefault();
69+
event.dataTransfer.dropEffect = 'link';
6870
}
6971

7072
function handleDrop(event)
@@ -106,7 +108,7 @@ function start()
106108
{
107109
app.event(window, 'dragenter', showDropZone);
108110
app.event(window, 'dragleave', hideDropZone);
109-
app.event(window, 'dragover', checkDragPosition);
111+
app.event(window, 'dragover', allowDrag);
110112
app.event(window, 'drop', handleDrop);
111113

112114
app.event(document, 'mouseenter', function(event){

scripts/events.js

+83-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,66 @@
11
var buttonCancel, buttonPulsed;
22

3+
function eventsTab()
4+
{
5+
app.event('.big-tabs > div > div', 'click', _eventsTab, {capture: false});
6+
7+
let tabs = document.querySelectorAll('.big-tabs > div > div');
8+
9+
for(let i = 0, len = tabs.length; i < len; i++)
10+
{
11+
tabs[i].dataset.index = i;
12+
}
13+
}
14+
15+
var eventsTabST = false;
16+
17+
function _eventsTab(event)
18+
{
19+
if(!this.classList.contains('active') && !eventsTabST)
20+
{
21+
let current = this.parentElement.querySelector('.active');
22+
let currentIndex = +current.dataset.index;
23+
let currentName = current.dataset.name;
24+
25+
let index = +this.dataset.index;
26+
let name = this.dataset.name;
27+
let onEndAnimation = this.dataset.onEndAnimation;
28+
29+
current.classList.remove('active');
30+
this.classList.add('active');
31+
32+
33+
let contentRight = template._contentRight();
34+
35+
let currentContent = contentRight.querySelector('.big-tabs-content .big-tabs-'+currentName);
36+
let content = contentRight.querySelector('.big-tabs-content .big-tabs-'+name);
37+
38+
let classShow = currentIndex > index ? 'show-from-left' : 'show-from-right';
39+
let classRemove = currentIndex > index ? 'hide-to-right' : 'hide-to-left';
40+
41+
currentContent.classList.add(classRemove, 'show');
42+
currentContent.classList.remove('active');
43+
44+
eventsTabST = setTimeout(function(){
45+
46+
content.classList.add(classShow, 'active');
47+
48+
eventsTabST = setTimeout(function(){
49+
50+
content.classList.remove(classShow);
51+
currentContent.classList.remove(classRemove, 'show');
52+
53+
if(onEndAnimation)
54+
eval(onEndAnimation);
55+
56+
eventsTabST = false;
57+
58+
}, 250);
59+
60+
}, 250);
61+
}
62+
}
63+
364
function eventButton()
465
{
566

@@ -179,16 +240,32 @@ function rangePosition(input, range)
179240

180241
if(step && (max - min) / step < 60) // Only show steps if has less 60
181242
{
243+
let rangeSteps = range.querySelectorAll('.range-steps > div');
244+
let len = rangeSteps.length;
245+
182246
let total = Math.round((max - min) / step);
183-
let steps = '';
184247

185-
for(let i = 0; i <= total; i++)
248+
if(len > 0)
186249
{
187-
let stepValue = i * step;
188-
steps += '<div'+(stepValue > (value - min) ? '' : ' class="active"')+' style="left: '+(i / total * 100)+'%"></div>';
250+
for(let i = 0; i < len; i++)
251+
{
252+
if(i * step > (value - min))
253+
rangeSteps[i].classList.remove('active');
254+
else
255+
rangeSteps[i].classList.add('active');
256+
}
189257
}
258+
else
259+
{
260+
let steps = '';
190261

191-
range.querySelector('.range-steps').innerHTML = steps;
262+
for(let i = 0; i <= total; i++)
263+
{
264+
steps += '<div'+(i * step > (value - min) ? '' : ' class="active"')+' style="left: '+(i / total * 100)+'%"></div>';
265+
}
266+
267+
range.querySelector('.range-steps').innerHTML = steps;
268+
}
192269
}
193270
}
194271

@@ -254,6 +331,7 @@ function events()
254331
eventButton();
255332
eventSwitch();
256333
eventRange();
334+
eventsTab();
257335
}
258336

259337
function showHoverText()

0 commit comments

Comments
 (0)