Skip to content

Commit

Permalink
Update GameEngine.h
Browse files Browse the repository at this point in the history
Drying up the following lines occuring 3 times: "restore_cursor(); show_cursor(); on_quit();" by packaging them in a small private function called pre_quit() in lack of a better name.
  • Loading branch information
razterizer authored Sep 27, 2024
1 parent 779ebb8 commit 9cfe91c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions GameEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ class GameEngine
void request_exit() { exit_requested = true; }

private:
void pre_quit()
{
restore_cursor();
show_cursor();
on_quit();
}

bool engine_update()
{
if (exit_requested)
Expand Down Expand Up @@ -280,9 +287,7 @@ class GameEngine

if (!m_params.enable_quit_confirm_screen && quit)
{
restore_cursor();
show_cursor();
on_quit();
pre_quit();
return false;
}
else if (show_quit_confirm && !show_hiscores && !show_input_hiscore)
Expand All @@ -309,9 +314,7 @@ class GameEngine
{
if (quit_confirm_button == YesNoButtons::Yes)
{
restore_cursor();
show_cursor();
on_quit();
pre_quit();
return false;
}
else
Expand Down Expand Up @@ -415,9 +418,7 @@ class GameEngine

if (key == ' ' || quit)
{
restore_cursor();
show_cursor();
on_quit();
pre_quit();
return false;
}
}
Expand Down

0 comments on commit 9cfe91c

Please sign in to comment.