This repository was archived by the owner on Jan 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSingIn.h
158 lines (152 loc) · 4.37 KB
/
SingIn.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#pragma once
constexpr INT NICKFIELD = 0;
constexpr INT KEYFIELD = 1;
constexpr INT ENTER = 13;
constexpr INT TAB = 9;
constexpr INT BACKSPACE = 8;
class SINGIN {
public:
int currentInputField = 0;
string InfoBuf;
vector <char> NickBuf;
vector <char> KeyBuf;
BOOL CompareKeys() {
KeyBuf.push_back('\0');
string k = KeyBuf.data();
KeyBuf.erase(KeyBuf.end() - 1);
if (k == key) {
return TRUE;
}
else {
return FALSE;
}
}
private:
const string key = "1";
};
VOID DrawSingIn(VOID) {
SINGIN SingIn;
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl;
while (true) {
int size = SingIn.NickBuf.size();
string Nick;
for (int n = 0; n < 28; n++) {
if (n < size) {
Nick += SingIn.NickBuf[n];
}
else {
Nick += ' ';
}
}
size = SingIn.KeyBuf.size();
string Key;
for (int n = 0; n < 28; n++) {
if (n < size) {
Key += '*';
}
else {
Key += ' ';
}
}
size = SingIn.InfoBuf.size();
string Info;
for (int n = 0; n < 80; n++) {
if (n < size) {
Info += SingIn.InfoBuf[n];
}
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 4);
cout << " ÚÄÄÄ´Sing inÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ";
cout << " ³ ³ ";
cout << " ³ ³ ";
cout << " ³ Nick: [" << Nick.c_str() << "] ³ ";
cout << " ³ ³ ";
cout << " ³ Key: [" << Key.c_str() << "] ³ ";
cout << " ³ ³ ";
cout << " ³ ³ ";
cout << " ³ [TAB] Change Fields ³ ";
cout << " ³ ³ ";
cout << " ³ [ENTER] Enter [BACKSPACE] Clear ³ ";
cout << " ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ";
cout << " ";
cout << " ";
cout << " ";
cout << " ";
cout << " ";
cout << " ";
cout << "ÄÄÄ´";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 64);
cout << Info.c_str();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), DEFFAULTCOLOR);
int c;
int extended = 0;
c = _getch();
if (!c)
extended = _getch();
SingIn.InfoBuf = "";
switch (c)
{
case ENTER:
if (SingIn.NickBuf.size() == 0) {
SingIn.InfoBuf = "“ª ¦¨â¥ ¨ª";
break;
}
if (SingIn.KeyBuf.size() == 0) {
SingIn.InfoBuf = "“ª ¦¨â¥ ª«îç";
break;
}
if (SingIn.CompareKeys()) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), DEFFAULTCOLOR);
return;
}
else {
SingIn.InfoBuf = "Š«îç ¥ ¢¥à¥?";
}
break;
case TAB:
if (SingIn.currentInputField == 1) {
SingIn.currentInputField = 0;
}
else {
SingIn.currentInputField += 1;
}
break;
case BACKSPACE:
switch (SingIn.currentInputField)
{
case NICKFIELD:
if (SingIn.NickBuf.size() != 0) {
SingIn.NickBuf.erase(SingIn.NickBuf.end() - 1);
}
break;
case KEYFIELD:
if (SingIn.KeyBuf.size() != 0) {
SingIn.KeyBuf.erase(SingIn.KeyBuf.end() - 1);
}
break;
}
break;
default:
if (extended) {
SingIn.InfoBuf = "Š« ¢¨è¨ ¥ ¯®¤¤¥à¦¨¢ îâìáï";
}
else {
switch (SingIn.currentInputField)
{
case NICKFIELD:
if (SingIn.NickBuf.size() < 28) {
SingIn.NickBuf.push_back(c);
}
break;
case KEYFIELD:
if (SingIn.KeyBuf.size() < 28) {
SingIn.KeyBuf.push_back(c);
}
break;
}
}
break;
}
cout << endl << endl << endl << endl<< endl << endl << endl << endl << endl;
}
}