Don't show time elapsed screen if you quit.
This commit is contained in:
parent
baca448ea2
commit
c105ed13a0
35
main.cpp
35
main.cpp
@ -66,12 +66,12 @@ int main(int argc, char *argv[])
|
|||||||
// Keep track of time:
|
// Keep track of time:
|
||||||
auto start_time = std::chrono::steady_clock::now();
|
auto start_time = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
|
unsigned int input = 'q';
|
||||||
while(selected != problems.end() && *selected)
|
while(selected != problems.end() && *selected)
|
||||||
{
|
{
|
||||||
|
|
||||||
Problem *current_problem = *selected;
|
Problem *current_problem = *selected;
|
||||||
current_problem->Draw(true, input_style); // refresh with new input
|
current_problem->Draw(true, input_style); // refresh with new input
|
||||||
auto input = getch();
|
input = getch();
|
||||||
if(input == 'q') // early exit
|
if(input == 'q') // early exit
|
||||||
break;
|
break;
|
||||||
switch(input)
|
switch(input)
|
||||||
@ -106,21 +106,24 @@ int main(int argc, char *argv[])
|
|||||||
current_problem->Draw(current_problem == *selected, input_style); // refresh with new input
|
current_problem->Draw(current_problem == *selected, input_style); // refresh with new input
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of time:
|
if(input != 'q') // if you didn't quit
|
||||||
auto end_time = std::chrono::steady_clock::now();
|
{
|
||||||
auto elapsed_time = std::chrono::duration_cast<std::chrono::seconds>(end_time - start_time);
|
// Keep track of time:
|
||||||
int middle_h = COLS / 2;
|
auto end_time = std::chrono::steady_clock::now();
|
||||||
int middle_v = LINES / 2;
|
auto elapsed_time = std::chrono::duration_cast<std::chrono::seconds>(end_time - start_time);
|
||||||
clear();
|
int middle_h = COLS / 2;
|
||||||
mvprintw(middle_v - 1, middle_h - 10,
|
int middle_v = LINES / 2;
|
||||||
"Time Elapsed: %02dm %02ds\n",
|
clear();
|
||||||
elapsed_time / 60, elapsed_time % 60);
|
mvprintw(middle_v - 1, middle_h - 10,
|
||||||
mvprintw(middle_v + 1, middle_h - 8,
|
"Time Elapsed: %02dm %02ds\n",
|
||||||
"Press Q to quit.");
|
elapsed_time / 60, elapsed_time % 60);
|
||||||
wrefresh(stdscr);
|
mvprintw(middle_v + 1, middle_h - 8,
|
||||||
|
"Press Q to quit.");
|
||||||
|
wrefresh(stdscr);
|
||||||
|
|
||||||
while(!(getch() == 'q'))
|
while(!(getch() == 'q'))
|
||||||
;
|
;
|
||||||
|
}
|
||||||
|
|
||||||
for(auto *problem : problems)
|
for(auto *problem : problems)
|
||||||
if(problem)
|
if(problem)
|
||||||
|
Loading…
Reference in New Issue
Block a user