From 23533c77defbd86f66dc2a66882c328f09e90090 Mon Sep 17 00:00:00 2001 From: "Daniel K. O. (dkosmari)" Date: Sun, 26 Jan 2025 21:19:26 -0300 Subject: [PATCH] Ported the paging code from the main branch. --HG-- branch : page-up-down-nav --- source/utils/config/ConfigRenderer.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/source/utils/config/ConfigRenderer.cpp b/source/utils/config/ConfigRenderer.cpp index 9f30546..bed3d52 100644 --- a/source/utils/config/ConfigRenderer.cpp +++ b/source/utils/config/ConfigRenderer.cpp @@ -110,8 +110,21 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) { } }; + auto totalElementSize = (int32_t) configs.size(); if (input.data.buttons_d & Input::eButtons::BUTTON_DOWN) { mCursorPos++; + } else if (input.data.buttons_d & Input::eButtons::BUTTON_LEFT) { + // Paging up + mCursorPos -= MAX_BUTTONS_ON_SCREEN - 1; + // Don't jump past the top + if (mCursorPos < 0) + mCursorPos = 0; + } else if (input.data.buttons_d & Input::eButtons::BUTTON_RIGHT) { + // Paging down + mCursorPos += MAX_BUTTONS_ON_SCREEN - 1; + // 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_PLUS) { @@ -160,10 +173,9 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) { } } - auto totalElementSize = (int32_t) configs.size(); if (mCursorPos < 0) { mCursorPos = totalElementSize - 1; - } else if (mCursorPos > (totalElementSize - 1)) { + } else if (mCursorPos >= totalElementSize) { mCursorPos = 0; } if (mCursorPos < 0) { @@ -241,9 +253,9 @@ 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 "); if (mSetActivePluginsMode) { - DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\ue000 Toggle | \uE045 Apply", true); + DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\uE000 Toggle | \uE045 Apply", true); } else if (totalElementSize > 0) { const auto text = string_format("\ue000 Select | %s Manage plugins", mLastInputWasOnWiimote ? "\uE048" : "\uE002"); DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, text.c_str(), true); @@ -333,4 +345,4 @@ const std::vector> &ConfigRenderer::Ge return mAllConfigs; } return mActiveConfigs; -} \ No newline at end of file +}