1 #include "../include/Menu.hpp" 17 srand(static_cast<unsigned int>(chrono::high_resolution_clock::now().time_since_epoch().count()));
29 _display.setFont(_fontSetting);
31 _display.clearScreen();
46 _display.setFormat(formatting);
48 for (
string line : art){
52 _display.clearFormat();
59 _display.clearScreen();
67 for (
string line : _credits){
68 cout << lBuffer << line << endl;
70 _display.clearFormat();
72 _display.setCursor(1,1);
76 _display.clearScreen();
86 ifstream settingsFile(
"settings.txt");
88 if (settingsFile.is_open()) {
89 settingsFile >> _fontSetting;
90 settingsFile >> _notiSetting;
106 ofstream settingsFile(
"settings.txt");
108 if (settingsFile.is_open()) {
109 settingsFile << _fontSetting << endl;
110 settingsFile << _notiSetting << endl;
111 settingsFile.close();
129 for (
int i = 0; i < _menuFormats.size(); ++i) {
137 _display.setCursor(1,1);
141 printArt(_menuTimer, _menuFormats.at(0));
143 printArt(_menuStopwatch, _menuFormats.at(1));
145 printArt(_menuAlarm, _menuFormats.at(2));
147 printArt(_menuSettings, _menuFormats.at(3));
149 printArt(_menuQuit, _menuFormats.at(4));
151 _display.setCursor(1,1);
153 char in = getMenuInput(selected);
155 if(_testing){ in =
'1'; }
159 _display.clearScreen();
162 if(_testing){ in =
'2'; }
166 _display.clearScreen();
169 if(_testing){ in =
'3'; }
173 _display.clearScreen();
176 if(_testing){ in =
'4'; }
178 if(in ==
's' || in ==
'4'){
179 _display.clearScreen();
181 _display.clearScreen();
184 if(_testing){ in =
'5'; }
186 if(in ==
'q' || in ==
'5'){
187 _display.clearScreen();
204 for (
int i = 0; i < _settingsFormats.size(); ++i) {
212 _display.setCursor(1,1);
216 switch(_fontSetting){
218 printArt(_settingsFont1, _settingsFormats.at(0));
221 printArt(_settingsFont2, _settingsFormats.at(0));
224 printArt(_settingsFont3, _settingsFormats.at(0));
227 printArt(_settingsFont4, _settingsFormats.at(0));
232 printArt(_settingsNotiOn, _settingsFormats.at(1));
235 printArt(_settingsNotiOff, _settingsFormats.at(1));
238 printArt(_settingsCredits, _settingsFormats.at(2));
240 printArt(_settingsBack, _settingsFormats.at(3));
242 _display.setCursor(1,1);
244 char in = getSettingsInput(selected);
246 if(_testing){ in =
'1'; }
258 if(_testing){ in =
'2'; }
261 _notiSetting = !_notiSetting;
265 if(_testing){ in =
'3'; }
270 if(_testing){ in =
'4'; }
271 if(in ==
'q' || in ==
'4' ){
273 _display.setFont(_fontSetting);
278 settingsMenu(selected);
285 _display.clearScreen();
288 bool notified =
false;
290 Timer timer = createTimer(run);
292 _display.clearScreen();
297 _display.setSplash(
"TIMER FINISHED");
298 if(_notiSetting && !notified){
304 _display.tickTimer(timer);
306 checkTimerInput(timer, run);
321 _display.clearScreen();
327 _display.setSplash(
"PRESS 'S' TO START");
329 _display.tickStopwatch(stopwatch);
334 _display.tickStopwatch(stopwatch);
336 checkStopwatchInput(stopwatch, run);
350 _display.clearScreen();
353 bool notified =
false;
355 Alarm alarm = createAlarm(run);
357 _display.clearScreen();
362 _display.setSplash(
"ALARM FINISHED");
363 if(_notiSetting && !notified){
369 _display.tickAlarm(alarm);
371 checkAlarmInput(alarm, run);
390 int countdownSeconds = 0;
392 string input =
"000000";
394 string to_print =
"00:00:00";
396 _display.tickTimerSetup(to_print);
412 if (ch == 13 && (h || m || s)) {
415 else if (ch >=
'0' && ch <=
'9') {
416 input = input.substr(1) + ch;
419 input =
'0' + input.substr(0, 5);
422 if(ch ==
'q' || ch ==
'Q' || ch == 27){
427 h = stoi(input.substr(0, 2));
428 m = stoi(input.substr(2, 2));
429 s = stoi(input.substr(4, 2));
431 to_print = (h < 10 ?
"0" :
"") + to_string(h) +
":" 432 + (m < 10 ?
"0" :
"") + to_string(m) +
":" 433 + (s < 10 ?
"0" :
"") + to_string(s);
435 _display.tickTimerSetup(to_print);
443 _display.clearScreen();
457 string input =
"0000";
459 string to_print =
"00:00";
463 _display.tickAlarmSetup(to_print, isAM);
478 if(ch == -32 || ch == 224 || ch == 0){
500 else if (ch >=
'0' && ch <=
'9') {
501 input = input.substr(1) + ch;
504 input =
'0' + input.substr(0, 3);
507 if(ch ==
'q' || ch ==
'Q' || ch == 27){
512 h = stoi(input.substr(0, 2));
513 m = stoi(input.substr(2, 2));
523 to_print = (h < 10 ?
"0" :
"") + to_string(h) +
":" 524 + (m < 10 ?
"0" :
"") + to_string(m);
526 input = to_print.substr(0, 2) + to_print.substr(3, 2);
528 _display.tickAlarmSetup(to_print, isAM);
536 _display.clearScreen();
552 alarm =
Alarm(h+12,m);
567 int milli = 1000 * seconds;
568 this_thread::sleep_for(chrono::milliseconds(milli));
600 if(_kbhit() || _testing){
602 if(!_testing) { ch = _getch(); }
603 if(_testing) { ch =
's'; }
604 if(ch ==
's' || ch ==
'S'){
607 _display.setSplash(
"TIMER PAUSED");
610 _display.clearSplash();
614 if(_testing) { ch =
'r'; }
615 if(ch ==
'R' || ch ==
'r'){
617 _display.clearScreen();
618 _display.setSplash(
"TIMER RESET, PRESS 'S' TO START");
620 if(_testing) { ch =
'a'; }
621 if(ch ==
'A' || ch ==
'a'){
622 _display.clearScreen();
623 _display.clearSplash();
624 timer = createTimer(run);
626 if(_testing) { ch =
'q'; }
627 if(ch ==
'Q' || ch ==
'q' || ch == 27){
628 _display.clearSplash();
648 if(_kbhit() || _testing){
650 if(!_testing) { ch = _getch(); }
651 if(_testing) { ch =
's'; }
652 if(ch ==
's' || ch ==
'S'){
656 int i = rand() % _stopMessages.size();
657 _display.setSplash(_stopMessages[i]);
660 _display.setSplash(
"STOPWATCH PAUSED");
664 _display.clearSplash();
668 if(_testing) { ch =
'r'; }
669 if(ch ==
'R' || ch ==
'r'){
671 _display.clearScreen();
672 _display.setSplash(
"STOPWATCH RESET, PRESS 'S' TO START");
674 if(_testing) { ch =
'a'; }
675 if(ch ==
'A' || ch ==
'a'){
677 _display.setSplash(
"SPLIT CREATED");
679 if(_testing) { ch =
'q'; }
680 if(ch ==
'Q' || ch ==
'q' || ch == 27){
681 _display.clearSplash();
702 if(_kbhit() || _testing){
704 if(!_testing) { ch = _getch(); }
705 if(_testing) { ch =
'a'; }
706 if(ch ==
'A' || ch ==
'a'){
707 _display.clearScreen();
708 _display.clearSplash();
709 alarm = createAlarm(run);
711 if(_testing) { ch =
'q'; }
712 if(ch ==
'Q' || ch ==
'q' || ch == 27){
713 _display.clearSplash();
734 if(_kbhit() || _testing){
736 if(!_testing) { ch = _getch(); }
739 return selected +
'1';
742 if(ch == -32 || ch == 224 || ch == 0){
746 selected = max(0,selected-1);
749 selected = min(4,selected+1);
758 if(_testing) { ch = 27; }
791 if(_kbhit() || _testing){
793 if(!_testing) { ch = _getch(); }
796 printArt(_settingsBlank,
"");
797 return selected +
'1';
800 if(ch == -32 || ch == 224 || ch == 0){
804 selected = max(0,selected-1);
807 selected = min(3,selected+1);
815 if(_testing) { ch = 27; }
A class to manage alarms with time-based triggers.
The Timer class provides a countdown timer with start, pause, resume, reset, and time adjustment func...
void addSplit()
Records and prints the current split time in milliseconds.
void resume()
Resumes the timer from where it was paused by recalculating the end time.
The Stopwatch class provides a simple timer with start, pause, resume, and reset functionalities.
int remainingMilliseconds()
Returns the remaining time in milliseconds.
bool isDone()
Checks if the alarm has finished.
static const string BOLD_WHITE
void pause()
Pauses the timer and calculates the remaining milliseconds.
static const string SELECTED
void reset()
Resets the stopwatch to 0 milliseconds and stops it.
static const string WHITE
void resume()
Resumes the stopwatch from the last paused time.
A class to handle system notifications using PowerShell scripts.
static const string BOLD_CYAN
bool isRunning()
Checks if the timer is currently running.
int currentMilliseconds()
Returns the current elapsed time in milliseconds.
void pause()
Pauses the stopwatch.
void reset()
Resets the timer to its original duration and pauses it.
The Display class manages the visual representation and interaction logic for timers, stopwatches, and alarms.
bool isRunning()
Checks if the stopwatch is currently running.