-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConsoleApplicationCPP.cpp
106 lines (77 loc) · 2.09 KB
/
ConsoleApplicationCPP.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <iostream>
#include <Windows.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
static void sigHandler(int sig) {
exit(0);
}
class ProgressBar {
public:
double neededProgress;
int timesRan;
void update(double newProgress) {
currentProgress += newProgress;
amountOfFiller = (int)((currentProgress / neededProgress) * (double)ProgressBarLength);
this->print();
}
string firstPartOfProgressBar = "[",
lastPartOfProgressBar = "]",
ProgressBarFiller = "|",
ProgressBarUpdater = "/-\\|";
void print() {
currUpdateVal %= ProgressBarUpdater.length();
cout << "\r"
<< firstPartOfProgressBar;
for (int a = 0; a < amountOfFiller; a++) {
cout << ProgressBarFiller;
}
cout << ProgressBarUpdater[currUpdateVal];
for (int b = 0; b < ProgressBarLength - amountOfFiller; b++) {
cout << " ";
}
cout << lastPartOfProgressBar
<< " (" << (int)(100 * (currentProgress / neededProgress)) << "%)"
<< " Brewed Coffee " << timesRan << " times! "
<< flush;
currUpdateVal += 1;
}
private:
int amountOfFiller,
ProgressBarLength = 50,
currUpdateVal = 0;
double currentProgress = 0;
};
static void ToggleNumLock() {
byte bScan = 0x45;
keybd_event(VK_NUMLOCK, bScan, KEYEVENTF_EXTENDEDKEY | 0, 0); // Key-down
keybd_event(VK_NUMLOCK, bScan, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); // Key-Up
}
int main() {
string Dev = "Ambushfall";
signal(SIGINT, sigHandler);
#ifdef SIGBREAK
signal(SIGBREAK, sigHandler);
#endif
signal(SIGABRT, sigHandler);
signal(SIGTERM, sigHandler);
cout << "Coffee Brewer " << "Made with <3 by " << Dev << endl;
cout << "Brewing Coffee..." << endl << endl;
cout << "Press Ctrl+C to exit..." << endl << endl;
int TimesRan = 0;
while (true) {
ProgressBar bar;
int Progress = 35 * 100;
// int Progress = 10;
bar.neededProgress = Progress;
bar.timesRan = TimesRan;
for (int i = 0; i < Progress; i++) {
bar.update(1);
Sleep(1);
}
ToggleNumLock();
TimesRan += 1;
}
return 0;
}