-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolveWindow.cpp
More file actions
49 lines (41 loc) · 1.52 KB
/
Copy pathSolveWindow.cpp
File metadata and controls
49 lines (41 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "SolveWindow.h"
SolveWindow::SolveWindow() : winHeight(SOLVE_WIN_HEIGHT) {
int termWidth, termHeight;
// make window 4 columns wider than longest possible scramble
winWidth = SCRAMBLE_LENGTH * 3 + 3;
getmaxyx(stdscr, termHeight, termWidth);
winPtr = newwin(winHeight, winWidth, (termHeight - winHeight) / 2,
(termWidth - winWidth) / 2);
}
SolveWindow::~SolveWindow() {
delwin(winPtr);
winPtr = nullptr;
}
void SolveWindow::showWindow(Solve toShow, unsigned numOfSolve,
unsigned totalSolves) {
std::string begTopLine = "Solve " + std::to_string(numOfSolve) + "/" +
std::to_string(totalSolves) + ": ";
std::string medTopLine = toShow.toString(true);
std::string endTopLine = " @ " + toShow.timestampToString();
std::string topLine = begTopLine + medTopLine + endTopLine;
unsigned startx = (winWidth - topLine.length()) / 2;
wmove(winPtr, 2, 0);
wclrtoeol(winPtr);
wmove(winPtr, 2, startx);
wprintw(winPtr, begTopLine.c_str());
// print time in bold so it stands out
wattron(winPtr, A_BOLD);
wprintw(winPtr, medTopLine.c_str());
wattroff(winPtr, A_BOLD);
wprintw(winPtr, endTopLine.c_str());
wmove(winPtr, 4, 0);
wclrtoeol(winPtr);
wmove(winPtr, 4, (winWidth - toShow.getScramble().length()) / 2);
wprintw(winPtr, toShow.getScramble().c_str());
box(winPtr, 0, 0);
wrefresh(winPtr);
}
void SolveWindow::hideWindow() {
wclear(winPtr);
wrefresh(winPtr);
}