2026-02-21 03:04:48 -05:00
|
|
|
#include "EndOfBookMenuActivity.h"
|
|
|
|
|
|
|
|
|
|
#include <GfxRenderer.h>
|
|
|
|
|
#include <I18n.h>
|
|
|
|
|
|
|
|
|
|
#include "MappedInputManager.h"
|
|
|
|
|
#include "components/UITheme.h"
|
|
|
|
|
#include "fontIds.h"
|
|
|
|
|
|
|
|
|
|
void EndOfBookMenuActivity::buildMenuItems() {
|
|
|
|
|
menuItems.clear();
|
|
|
|
|
menuItems.push_back({Action::ARCHIVE, StrId::STR_ARCHIVE_BOOK});
|
|
|
|
|
menuItems.push_back({Action::DELETE, StrId::STR_DELETE_BOOK});
|
2026-02-21 07:37:36 -05:00
|
|
|
menuItems.push_back({Action::TABLE_OF_CONTENTS, StrId::STR_TABLE_OF_CONTENTS});
|
2026-02-21 03:04:48 -05:00
|
|
|
menuItems.push_back({Action::BACK_TO_BEGINNING, StrId::STR_BACK_TO_BEGINNING});
|
|
|
|
|
menuItems.push_back({Action::CLOSE_BOOK, StrId::STR_CLOSE_BOOK});
|
|
|
|
|
menuItems.push_back({Action::CLOSE_MENU, StrId::STR_CLOSE_MENU});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EndOfBookMenuActivity::onEnter() {
|
|
|
|
|
Activity::onEnter();
|
|
|
|
|
selectedIndex = 0;
|
|
|
|
|
requestUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EndOfBookMenuActivity::onExit() { Activity::onExit(); }
|
|
|
|
|
|
|
|
|
|
void EndOfBookMenuActivity::loop() {
|
|
|
|
|
buttonNavigator.onNext([this] {
|
|
|
|
|
selectedIndex = ButtonNavigator::nextIndex(selectedIndex, static_cast<int>(menuItems.size()));
|
|
|
|
|
requestUpdate();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
buttonNavigator.onPrevious([this] {
|
|
|
|
|
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, static_cast<int>(menuItems.size()));
|
|
|
|
|
requestUpdate();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
|
|
|
|
if (selectedIndex < static_cast<int>(menuItems.size())) {
|
|
|
|
|
auto cb = onAction;
|
|
|
|
|
cb(menuItems[selectedIndex].action);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
|
|
|
|
|
auto cb = onAction;
|
|
|
|
|
cb(Action::CLOSE_MENU);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EndOfBookMenuActivity::render(Activity::RenderLock&&) {
|
|
|
|
|
renderer.clearScreen();
|
|
|
|
|
|
|
|
|
|
const auto pageWidth = renderer.getScreenWidth();
|
|
|
|
|
const auto pageHeight = renderer.getScreenHeight();
|
2026-02-21 07:37:36 -05:00
|
|
|
auto metrics = UITheme::getInstance().getMetrics();
|
2026-02-21 03:04:48 -05:00
|
|
|
|
2026-02-21 07:37:36 -05:00
|
|
|
GUI.drawHeader(renderer, Rect{0, metrics.topPadding, pageWidth, metrics.headerHeight}, tr(STR_END_OF_BOOK));
|
2026-02-21 03:04:48 -05:00
|
|
|
|
2026-02-21 07:37:36 -05:00
|
|
|
const int contentTop = metrics.topPadding + metrics.headerHeight + metrics.verticalSpacing;
|
|
|
|
|
const int contentHeight = pageHeight - contentTop - metrics.buttonHintsHeight - metrics.verticalSpacing;
|
|
|
|
|
|
|
|
|
|
GUI.drawList(
|
|
|
|
|
renderer, Rect{0, contentTop, pageWidth, contentHeight}, static_cast<int>(menuItems.size()), selectedIndex,
|
|
|
|
|
[this](int index) { return std::string(I18N.get(menuItems[index].labelId)); });
|
2026-02-21 03:04:48 -05:00
|
|
|
|
2026-02-21 07:37:36 -05:00
|
|
|
const auto labels = mappedInput.mapLabels(tr(STR_BACK), tr(STR_SELECT), tr(STR_DIR_UP), tr(STR_DIR_DOWN));
|
2026-02-21 03:04:48 -05:00
|
|
|
GUI.drawButtonHints(renderer, labels.btn1, labels.btn2, labels.btn3, labels.btn4);
|
|
|
|
|
|
|
|
|
|
renderer.displayBuffer();
|
|
|
|
|
}
|