mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-16 22:27:42 +03:00
Show end of book screen when navigating past last page
This commit is contained in:
parent
5bae283838
commit
f69fc90b5c
@ -79,6 +79,14 @@ void EpubReaderScreen::handleInput() {
|
||||
return;
|
||||
}
|
||||
|
||||
// any botton press when at end of the book goes back to the last page
|
||||
if (currentSpineIndex > 0 && currentSpineIndex >= epub->getSpineItemsCount()) {
|
||||
currentSpineIndex = epub->getSpineItemsCount() - 1;
|
||||
nextPageNumber = UINT16_MAX;
|
||||
updateRequired = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const bool skipChapter = inputManager.getHeldTime() > SKIP_CHAPTER_MS;
|
||||
|
||||
if (skipChapter) {
|
||||
@ -143,9 +151,22 @@ void EpubReaderScreen::renderScreen() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentSpineIndex >= epub->getSpineItemsCount() || currentSpineIndex < 0) {
|
||||
// edge case handling for sub-zero spine index
|
||||
if (currentSpineIndex < 0) {
|
||||
currentSpineIndex = 0;
|
||||
}
|
||||
// based bounds of book, show end of book screen
|
||||
if (currentSpineIndex > epub->getSpineItemsCount()) {
|
||||
currentSpineIndex = epub->getSpineItemsCount();
|
||||
}
|
||||
|
||||
// Show end of book screen
|
||||
if (currentSpineIndex == epub->getSpineItemsCount()) {
|
||||
renderer.clearScreen();
|
||||
renderer.drawCenteredText(READER_FONT_ID, 300, "End of book", true, BOLD);
|
||||
renderer.displayBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!section) {
|
||||
const auto filepath = epub->getSpineItem(currentSpineIndex);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user