-
Notifications
You must be signed in to change notification settings - Fork 0
/
PongIO.h
71 lines (58 loc) · 1.64 KB
/
PongIO.h
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
#ifndef PongIO
#define PongIO
#include<windows.h>
#define CONSOLE_LOGGING
//#define BOX_LOGGING
#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
inline void error(std::string text){
#ifdef CONSOLE_LOGGING
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_RED);
std::cout<<"Error: ";
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
std::cout<<text<<"\n";
#endif
#ifdef BOX_LOGGING
MessageBox(NULL, text.c_str(), "Error", MB_OK | MB_ICONERROR);
#endif
}
inline void warn(std::string text){
#ifdef CONSOLE_LOGGING
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN);
std::cout<<"Warning: ";
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
std::cout<<text<<"\n";
#endif
#ifdef BOX_LOGGING
MessageBox(NULL, text.c_str(), "Warning", MB_OK | MB_ICONWARNING);
#endif
}
inline void print(std::string text){
#ifdef CONSOLE_LOGGING
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE);
std::cout<<"Message: ";
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
std::cout<<text<<"\n";
#endif
#ifdef BOX_LOGGING
MessageBox(NULL, text.c_str(), "Message", MB_OK | MB_ICONINFORMATION);
#endif
}
std::string readFile(std::string filename){
std::ifstream ifs(filename);
std::stringstream ss;
ss<<ifs.rdbuf();
return ss.str();
}
#ifdef CONSOLE_LOGGING
#undef CONSOLE_LOGGING
#endif
#ifdef BOX_LOGGING
#undef BOX_LOGGING
#endif
#endif