Skip to content

Commit

Permalink
New change menu function
Browse files Browse the repository at this point in the history
Move the most basic change menu to here
  • Loading branch information
hezy0426 committed Dec 13, 2023
1 parent ccbac66 commit 53ce76f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/LiquidMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,12 @@ class LiquidSystem
/// Switches to the next screen.
void next_screen();

/**
* @brief Change to the next screen
* @return Whether we change the screen correctly or not
*/
bool changeToNextScreen();

/// Switches to the next screen.
/**
@note Prefix increment operator overloading.
Expand Down
21 changes: 21 additions & 0 deletions src/LiquidSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,27 @@ void LiquidSystem::next_screen() {
_p_liquidMenu[_currentMenu]->next_screen();
}

bool LiquidSystem::changeToNextScreen()
{
LiquidScreen *currentScreen = _p_liquidMenu[_currentMenu]->get_currentScreen();
if (currentScreen->get_next_screen() == NULL)
{
if (currentScreen->get_next_menu())
{
change_menu(*currentScreen->get_next_menu(), true);
return true;
}
}
else
{
change_menu(*currentScreen->get_next_menu(), false);
change_screen(currentScreen->get_next_screen());
return true;
}

return false;
}

void LiquidSystem::operator++() {
next_screen();
}
Expand Down

0 comments on commit 53ce76f

Please sign in to comment.