Skip to content

Commit 7519ac5

Browse files
committed
New: Allow disabling Do not enlarge more than its original size in Webtoon mode
1 parent 128bddf commit 7519ac5

6 files changed

Lines changed: 56 additions & 18 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## v1.5.1 (dd-mm-yyyy)
88

9+
##### 🚀 New Features
10+
11+
- Allow disabling `Do not enlarge more than its original size` in Webtoon mode
12+
913
##### 🐛 Bug Fixes
1014

1115
- Error opening files from the system file explorer [`cecc15d`](https://github.com/ollm/OpenComic/commit/cecc15d44c15545fddb932ee87d99213015f295e)

‎scripts/events.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,4 +1447,5 @@ module.exports = {
14471447
goRange: goRange,
14481448
loadingProgress: loadingProgress,
14491449
buttonLoading: buttonLoading,
1450+
swiftClick: swiftClick,
14501451
};

‎scripts/migration.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,30 @@ function migrateCompressedFilesWithUnsupportedCharsInWindows(data)
320320
return data;
321321
}
322322

323+
function migrateWebtoonNotEnlargeMoreThanOriginalSize(data)
324+
{
325+
console.time('Migration: webtoonNotEnlargeMoreThanOriginalSize');
326+
327+
if(data.config.readingWebtoon)
328+
data.config.readingNotEnlargeMoreThanOriginalSize = true;
329+
330+
for(let key in data.readingShortcutPagesConfig)
331+
{
332+
if(data.readingShortcutPagesConfig[key].readingWebtoon)
333+
data.readingShortcutPagesConfig[key].readingNotEnlargeMoreThanOriginalSize = true;
334+
}
335+
336+
for(let key in data.readingPagesConfig)
337+
{
338+
if(data.readingPagesConfig[key].readingWebtoon)
339+
data.readingPagesConfig[key].readingNotEnlargeMoreThanOriginalSize = true;
340+
}
341+
342+
console.timeEnd('Migration: webtoonNotEnlargeMoreThanOriginalSize');
343+
344+
return data;
345+
}
346+
323347
function start(data)
324348
{
325349
let changes = data.config.changes;
@@ -353,6 +377,9 @@ function start(data)
353377
if(changes < 113) // Fix compressed files with unsupported characters in Windows
354378
data = migrateCompressedFilesWithUnsupportedCharsInWindows(data);
355379

380+
if(changes < 119) // Fix compressed files with unsupported characters in Windows
381+
data = migrateWebtoonNotEnlargeMoreThanOriginalSize(data);
382+
356383
data = opds.addNewDefaultCatalogs(data, changes);
357384

358385
return data;

‎scripts/reading.js‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ function disposeImages(data = false)
345345
imageElements[key1][key2].push(image.firstElementChild);
346346
}
347347

348-
let readingNotEnlargeMoreThanOriginalSize = (_config.readingNotEnlargeMoreThanOriginalSize || _config.readingWebtoon) ? true : false;
348+
let readingNotEnlargeMoreThanOriginalSize = _config.readingNotEnlargeMoreThanOriginalSize ? true : false;
349349

350350
for(let key1 in _imagesDistribution)
351351
{
@@ -3097,6 +3097,8 @@ function changePagesView(mode, value, save)
30973097
if(currentScale != 1)
30983098
reading.resetZoom(true, false, false);
30993099

3100+
const imageIndex = reloadIndex();
3101+
31003102
if(mode == 0)
31013103
{
31023104
let selectTab = document.querySelector('#reading-pages .tabs > div > div.active').dataset.name;
@@ -3105,7 +3107,7 @@ function changePagesView(mode, value, save)
31053107
if(readingIsEbook) handlebarsContext.loading = true;
31063108
template.loadContentRight('reading.content.right.html', true);
31073109

3108-
reading.reload();
3110+
reading.reload(false, imageIndex);
31093111
}
31103112
else if(mode == 1) // Set the scroll mode
31113113
{
@@ -3122,7 +3124,7 @@ function changePagesView(mode, value, save)
31223124
if(readingIsEbook) handlebarsContext.loading = true;
31233125
template.loadContentRight('reading.content.right.html', true);
31243126

3125-
reading.reload();
3127+
reading.reload(false, imageIndex);
31263128
}
31273129
else if(mode == 2) // Sets the margin of the pages
31283130
{
@@ -3140,7 +3142,7 @@ function changePagesView(mode, value, save)
31403142
if(readingIsEbook) handlebarsContext.loading = true;
31413143
template.loadContentRight('reading.content.right.html', true);
31423144

3143-
reading.reload();
3145+
reading.reload(false, imageIndex);
31443146
}
31453147
else if(mode == 4) // Set the speed of the animation when changing pages
31463148
{
@@ -3162,7 +3164,7 @@ function changePagesView(mode, value, save)
31623164
if(readingIsEbook) handlebarsContext.loading = true;
31633165
template.loadContentRight('reading.content.right.html', true);
31643166

3165-
reading.reload();
3167+
reading.reload(false, imageIndex);
31663168
}
31673169
else if(mode == 7) // Disables double-page reading in horizontal images
31683170
{
@@ -3171,12 +3173,10 @@ function changePagesView(mode, value, save)
31713173
if(readingIsEbook) handlebarsContext.loading = true;
31723174
template.loadContentRight('reading.content.right.html', true);
31733175

3174-
reading.reload();
3176+
reading.reload(false, imageIndex);
31753177
}
31763178
else if(mode == 8) // Manga reading, invert the direction and double pages
31773179
{
3178-
const imageIndex = reloadIndex();
3179-
31803180
updateReadingPagesConfig('readingManga', value);
31813181

31823182
if(readingIsEbook) handlebarsContext.loading = true;
@@ -3190,7 +3190,13 @@ function changePagesView(mode, value, save)
31903190

31913191
if(value)
31923192
{
3193-
template.globalElement('.reading-view, .reading-reading-manga, .reading-double-page, .reading-do-not-apply-to-horizontals, .reading-blank-page, .reading-align-with-next-horizontal, .reading-ajust-to-width, .reading-not-enlarge-more-than-original-size, .reading-margin-vertical, .reading-force-single-page').addClass('disable-pointer');
3193+
template.globalElement('.reading-view, .reading-reading-manga, .reading-double-page, .reading-do-not-apply-to-horizontals, .reading-blank-page, .reading-align-with-next-horizontal, .reading-ajust-to-width, .reading-margin-vertical, .reading-force-single-page').addClass('disable-pointer');
3194+
3195+
if(!_config.readingNotEnlargeMoreThanOriginalSize)
3196+
{
3197+
events.swiftClick.call(template._globalElement().querySelector('.reading-not-enlarge-more-than-original-size .switch'));
3198+
updateReadingPagesConfig('readingNotEnlargeMoreThanOriginalSize', true);
3199+
}
31943200
}
31953201
else
31963202
{
@@ -3200,13 +3206,13 @@ function changePagesView(mode, value, save)
32003206
if(_config.readingDoublePage)
32013207
template.globalElement('.reading-do-not-apply-to-horizontals, .reading-blank-page, .reading-align-with-next-horizontal').removeClass('disable-pointer');
32023208

3203-
template.globalElement('.reading-view, .reading-reading-manga, .reading-double-page, .reading-not-enlarge-more-than-original-size, .reading-margin-vertical').removeClass('disable-pointer');
3209+
template.globalElement('.reading-view, .reading-reading-manga, .reading-double-page, .reading-margin-vertical').removeClass('disable-pointer');
32043210
}
32053211

32063212
if(readingIsEbook) handlebarsContext.loading = true;
32073213
template.loadContentRight('reading.content.right.html', true);
32083214

3209-
reading.reload();
3215+
reading.reload(false, imageIndex);
32103216
}
32113217
else if(mode == 10) // Set horizontal margin of the pages
32123218
{
@@ -3237,7 +3243,7 @@ function changePagesView(mode, value, save)
32373243
if(readingIsEbook) handlebarsContext.loading = true;
32383244
template.loadContentRight('reading.content.right.html', true);
32393245

3240-
reading.reload();
3246+
reading.reload(false, imageIndex);
32413247
}
32423248
else if(mode == 13) // Set width adjustment
32433249
{
@@ -3251,7 +3257,7 @@ function changePagesView(mode, value, save)
32513257
else
32523258
template.globalElement('.reading-horizontals-margin').addClass('disable-pointer');
32533259

3254-
reading.reload();
3260+
reading.reload(false, imageIndex);
32553261
}
32563262
else if(mode == 14) // Set horizontal margin of the horizontals pages
32573263
{
@@ -3307,7 +3313,7 @@ function changePagesView(mode, value, save)
33073313
if(readingIsEbook) handlebarsContext.loading = true;
33083314
template.loadContentRight('reading.content.right.html', true);
33093315

3310-
reading.reload();
3316+
reading.reload(false, imageIndex);
33113317
}
33123318
else if(mode == 19) // Rotate horizontal images
33133319
{
@@ -3316,7 +3322,7 @@ function changePagesView(mode, value, save)
33163322
if(readingIsEbook) handlebarsContext.loading = true;
33173323
template.loadContentRight('reading.content.right.html', true);
33183324

3319-
reading.reload();
3325+
reading.reload(false, imageIndex);
33203326
}
33213327
else if(mode == 20) // Force show single page in scroll mode
33223328
{
@@ -3336,7 +3342,7 @@ function changePagesView(mode, value, save)
33363342
if(readingIsEbook) handlebarsContext.loading = true;
33373343
template.loadContentRight('reading.content.right.html', true);
33383344

3339-
reading.reload();
3345+
reading.reload(false, imageIndex);
33403346
}
33413347
}
33423348

‎scripts/storage.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const safe = require(p.join(appDir, 'scripts/storage/safe.js'));
22

3-
const changes = 118; // Update this if readingPagesConfig is updated
3+
const changes = 119; // Update this if readingPagesConfig is updated
44

55
const readingPagesConfig = {
66
readingConfigName: '',

‎templates/reading.elements.menus.pages.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@
394394
<svg viewBox="0 0 52 32"><path d="M 8,0 C 3.58,0 0,3.58 0,8 0,12.42 3.58,16 8,16 8,16 8,16 8,16 12.42,16 16,12.42 16,8 16,3.58 12.42,0 8,0 8,0 8,0 8,0 Z"></path></svg>
395395
</div>
396396
</div>
397-
<div class="menu-simple-text reading-not-enlarge-more-than-original-size gamepad-item{{#if _config.readingWebtoon}} disable-pointer{{/if}}">
397+
<div class="menu-simple-text reading-not-enlarge-more-than-original-size gamepad-item">
398398
{{language.reading.pages.notEnlargeMoreThanOriginalSize}}
399399
<div class="switch{{#if _config.readingNotEnlargeMoreThanOriginalSize}} a{{/if}}" on="reading.changePagesView(18, true, false)" off="reading.changePagesView(18, false, false)">
400400
<div></div>

0 commit comments

Comments
 (0)