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

View File

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