Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use left/right to jump a full page on the toplevel menu. #84

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions source/utils/config/ConfigRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void ConfigRenderer::RenderStateMain() const {
// draw bottom bar
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_BLACK);
DrawUtils::setFontSize(18);
DrawUtils::print(16, SCREEN_HEIGHT - 10, "\ue07d Navigate ");
DrawUtils::print(16, SCREEN_HEIGHT - 10, "\ue07d/\ue07e Navigate ");
DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\ue000 Select", true);

// draw scroll indicator
Expand Down Expand Up @@ -71,9 +71,31 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
}
auto prevSelectedItem = mCursorPos;

auto totalElementSize = mConfigs.size();
int32_t totalElementSize = mConfigs.size();
dkosmari marked this conversation as resolved.
Show resolved Hide resolved
if (input.data.buttons_d & Input::eButtons::BUTTON_DOWN) {
mCursorPos++;
} else if (input.data.buttons_d & Input::eButtons::BUTTON_LEFT) {
// Paging up
if (mCursorPos == 0) {
// cursor at top pos, behaves as if pressed up
mCursorPos--;
} else {
mCursorPos -= MAX_BUTTONS_ON_SCREEN;
dkosmari marked this conversation as resolved.
Show resolved Hide resolved
// otherwise, don't jump past the top
if (mCursorPos < 0)
mCursorPos = 0;
}
} else if (input.data.buttons_d & Input::eButtons::BUTTON_RIGHT) {
// Paging down
if (mCursorPos == totalElementSize - 1) {
// cursor at bottom pos, behaves as if pressed down
dkosmari marked this conversation as resolved.
Show resolved Hide resolved
mCursorPos++;
} else {
mCursorPos += MAX_BUTTONS_ON_SCREEN;
dkosmari marked this conversation as resolved.
Show resolved Hide resolved
// otherwise, don't jump past the bottom
if (mCursorPos >= totalElementSize)
mCursorPos = totalElementSize - 1;
}
} else if (input.data.buttons_d & Input::eButtons::BUTTON_UP) {
mCursorPos--;
} else if (input.data.buttons_d & Input::eButtons::BUTTON_A) {
Expand All @@ -95,8 +117,8 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
}

if (mCursorPos < 0) {
mCursorPos = (int32_t) totalElementSize - 1;
} else if (mCursorPos > (int32_t) (totalElementSize - 1)) {
mCursorPos = totalElementSize - 1;
} else if (mCursorPos > totalElementSize - 1) {
mCursorPos = 0;
}

Expand Down