Show end of book screen when navigating past last page
This commit is contained in:
@@ -79,6 +79,14 @@ void EpubReaderScreen::handleInput() {
|
|||||||
return;
|
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;
|
const bool skipChapter = inputManager.getHeldTime() > SKIP_CHAPTER_MS;
|
||||||
|
|
||||||
if (skipChapter) {
|
if (skipChapter) {
|
||||||
@@ -143,9 +151,22 @@ void EpubReaderScreen::renderScreen() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSpineIndex >= epub->getSpineItemsCount() || currentSpineIndex < 0) {
|
// edge case handling for sub-zero spine index
|
||||||
|
if (currentSpineIndex < 0) {
|
||||||
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) {
|
if (!section) {
|
||||||
const auto filepath = epub->getSpineItem(currentSpineIndex);
|
const auto filepath = epub->getSpineItem(currentSpineIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user