-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUtility.cpp
More file actions
77 lines (68 loc) · 1.91 KB
/
Utility.cpp
File metadata and controls
77 lines (68 loc) · 1.91 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
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
#include "Utility.h"
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void InitializeSettings() {
SetConsoleOutputCP( 65001 );
system("title Information system prototype");
}
string KeyCheck(int Key) {
if (Key == 'w' or Key == 'W' or Key == 230 or Key == 150) {
return "w";
}
if (Key == 'a' or Key == 'A' or Key == 228 or Key == 148) {
return "a";
}
if (Key == 's' or Key == 'S' or Key == 235 or Key == 155) {
return "s";
}
if (Key == 'd' or Key == 'D' or Key == 162 or Key == 130) {
return "d";
}
if (Key == 13){
return "enter";
}
if (Key == 'e' or Key == 'E' or Key == 227 or Key == 147) {
return "e";
}
if (Key == VK_ESCAPE) {
return "esc";
}
if(Key == VK_TAB){
return "tab";
} else {return "NONE";}
}
void AdvancedOutputToXY(int x, int y, string str, WINBOOL Color) {
gotoxy(x, y);
cout << str;
TurnWhite;
}
void AdvancedOutputToXY(int x, int y, WINBOOL Color, string str) { //overload
AdvancedOutputToXY(x, y, str, Color);
TurnWhite;
}
void AdvancedOutputToXY(int x, int y, WINBOOL Color, int num) { //overload
gotoxy(x, y);
cout << num;
TurnWhite;
}
std::vector<std::string> split(std::string s, std::string delimiter) {
size_t pos_start = 0, pos_end, delim_len = delimiter.length();
std::string token;
std::vector<std::string> res;
while ((pos_end = s.find(delimiter, pos_start)) != std::string::npos) {
token = s.substr(pos_start, pos_end - pos_start);
pos_start = pos_end + delim_len;
res.push_back(token);
}
res.push_back(s.substr(pos_start));
return res;
}
bool in_range(char *buff, const char *max) {
int lb = strlen(buff), lm = strlen(max);
return (lb != lm) ? (lb < lm) : strcmp(max, buff) >= 0;
}