ConfigMenu: Fix redraw logic

This commit is contained in:
Maschell 2024-05-03 17:37:04 +02:00
parent be24d2c67a
commit 343092c338
2 changed files with 8 additions and 5 deletions

View File

@ -95,6 +95,7 @@ ConfigSubState CategoryRenderer::UpdateStateMain(Input &input, const WUPSConfigS
mCurrentOpen = mCursorPos; mCurrentOpen = mCursorPos;
mState = STATE_SUB; mState = STATE_SUB;
mNeedsRedraw = true; mNeedsRedraw = true;
return SUB_STATE_RUNNING;
} }
} }
} }
@ -149,7 +150,7 @@ ConfigSubState CategoryRenderer::UpdateStateMain(Input &input, const WUPSConfigS
void CategoryRenderer::ResetNeedsRedraw() { void CategoryRenderer::ResetNeedsRedraw() {
mNeedsRedraw = false; mNeedsRedraw = false;
if (mState == STATE_SUB && mSubCategoryRenderer) { if (mSubCategoryRenderer) {
mSubCategoryRenderer->ResetNeedsRedraw(); mSubCategoryRenderer->ResetNeedsRedraw();
} }
for (auto &item : mItemRenderer) { for (auto &item : mItemRenderer) {
@ -162,7 +163,7 @@ bool CategoryRenderer::NeedsRedraw() const {
if (mNeedsRedraw) { if (mNeedsRedraw) {
return true; return true;
} }
if (mState == STATE_SUB && mSubCategoryRenderer) { if (mSubCategoryRenderer) {
if (mSubCategoryRenderer->NeedsRedraw()) { if (mSubCategoryRenderer->NeedsRedraw()) {
return true; return true;
} }

View File

@ -66,6 +66,7 @@ void ConfigRenderer::drawConfigEntry(uint32_t yOffset, const GeneralConfigInform
ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) { ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
if (mConfigs.empty()) { if (mConfigs.empty()) {
mNeedRedraw = true;
return SUB_STATE_ERROR; return SUB_STATE_ERROR;
} }
auto prevSelectedItem = mCursorPos; auto prevSelectedItem = mCursorPos;
@ -80,10 +81,12 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
mCategoryRenderer.reset(); mCategoryRenderer.reset();
mCategoryRenderer = make_unique_nothrow<CategoryRenderer>(&(mConfigs[mCursorPos].getConfigInformation()), &(mConfigs[mCursorPos].getConfig()), true); mCategoryRenderer = make_unique_nothrow<CategoryRenderer>(&(mConfigs[mCursorPos].getConfigInformation()), &(mConfigs[mCursorPos].getConfig()), true);
} }
mNeedRedraw = true;
mCurrentOpen = mCursorPos; mCurrentOpen = mCursorPos;
mState = STATE_SUB; mState = STATE_SUB;
return SUB_STATE_RUNNING; return SUB_STATE_RUNNING;
} else if (input.data.buttons_d & (Input::eButtons::BUTTON_B | Input::eButtons::BUTTON_HOME)) { } else if (input.data.buttons_d & (Input::eButtons::BUTTON_B | Input::eButtons::BUTTON_HOME)) {
mNeedRedraw = true;
mCategoryRenderer.reset(); mCategoryRenderer.reset();
for (const auto &element : mConfigs) { for (const auto &element : mConfigs) {
CallOnCloseCallback(element.getConfigInformation(), element.getConfig()); CallOnCloseCallback(element.getConfigInformation(), element.getConfig());
@ -114,7 +117,7 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
bool ConfigRenderer::NeedsRedraw() const { bool ConfigRenderer::NeedsRedraw() const {
if (mNeedRedraw) { if (mNeedRedraw) {
return true; return true;
} else if (mState == STATE_SUB && mCategoryRenderer) { } else if (mCategoryRenderer) {
return mCategoryRenderer->NeedsRedraw(); return mCategoryRenderer->NeedsRedraw();
} }
return false; return false;
@ -122,12 +125,11 @@ bool ConfigRenderer::NeedsRedraw() const {
void ConfigRenderer::ResetNeedsRedraw() { void ConfigRenderer::ResetNeedsRedraw() {
mNeedRedraw = false; mNeedRedraw = false;
if (mState == STATE_SUB && mCategoryRenderer) { if (mCategoryRenderer) {
mCategoryRenderer->ResetNeedsRedraw(); mCategoryRenderer->ResetNeedsRedraw();
} }
} }
void ConfigRenderer::Render() const { void ConfigRenderer::Render() const {
switch (mState) { switch (mState) {
case STATE_MAIN: case STATE_MAIN: