-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplay_Card_Message_function.cpp
More file actions
175 lines (150 loc) · 4.8 KB
/
Copy pathDisplay_Card_Message_function.cpp
File metadata and controls
175 lines (150 loc) · 4.8 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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include "const_Value.h"
#include "about_class.h"
#include "about_operation.h"
#include "about_Draw.h"
using namespace std;
/************************************************
now format: X X X
| | |
X X X
| | |
X X X
************************************************/
void Display_Card_Process(vector<Card> &card,HANDLE hOut)
{
REDISPLAY:;
Draw_Display_Window(hOut);
COORD pos={DISPLAY_FIRST_CARD_POS_X,DISPLAY_FIRST_CARD_POS_Y};
SetConsoleCursorPosition(hOut,pos);
for(unsigned short n=0;n<3;n++)
{
card[n].Display_Message_in_CareBoxshow(hOut);
}
pos={DISPLAY_SECOND_CARD_POS_X,DISPLAY_SECOND_CARD_POS_Y};
SetConsoleCursorPosition(hOut,pos);
for(unsigned short n=3;n<6;n++)
{
card[n].Display_Message_in_CareBoxshow(hOut);
}
pos={DISPLAY_THIRD_CARD_POS_X,DISPLAY_THIRD_CARD_POS_Y};
SetConsoleCursorPosition(hOut,pos);
for(unsigned short n=6;n<NUMBER_CARD;n++)
{
card[n].Display_Message_in_CareBoxshow(hOut);
}
COORD choice_pos={DISPLAY_FIRST_CARD_POS_X,DISPLAY_FIRST_CARD_POS_Y};
Draw_Cursor_in_Display_Card_Message(choice_pos,hOut);//in about_Draw_function.cpp
SetConsoleCursorPosition(hOut,choice_pos);
while(1)
{
//direct change the choice_pos value and get the key event to temp_ope
if(_kbhit())
{
int temp_ope = Get_and_Respone_Key_Event_in_Display_Card_Message(choice_pos,hOut);
if(temp_ope==VK_RETURN)
{
Display_One_Card(choice_pos,card,hOut);
goto REDISPLAY;
}
if(temp_ope==VK_ESCAPE)
return;
}
}
//don't care the last cursor position
}
int Get_and_Respone_Key_Event_in_Display_Card_Message(COORD &choice_pos,HANDLE hOut)
{
int b=_getch();
if(b!=VK_ESCAPE&&b!=VK_RETURN&&b==224)
{
b=_getch();
switch(b)
{
case UP:
if(choice_pos.Y==DISPLAY_FIRST_CARD_POS_Y)
choice_pos.Y=DISPLAY_FIRST_CARD_POS_Y+2*DISPLAY_CARD_HIGH;
else
choice_pos.Y-=DISPLAY_CARD_HIGH;
Draw_Cursor_in_Display_Card_Message(choice_pos,hOut);//in about_Draw_function.cpp
SetConsoleCursorPosition(hOut,choice_pos);
return 0;
case DOWN:
if(choice_pos.Y==DISPLAY_FIRST_CARD_POS_Y+2*DISPLAY_CARD_HIGH)
choice_pos.Y=DISPLAY_FIRST_CARD_POS_Y;
else
choice_pos.Y+=DISPLAY_CARD_HIGH;
Draw_Cursor_in_Display_Card_Message(choice_pos,hOut);//in about_Draw_function.cpp
SetConsoleCursorPosition(hOut,choice_pos);
return 0;
case LEFT:
if(choice_pos.X==DISPLAY_FIRST_CARD_POS_X)
choice_pos.X=DISPLAY_THIRD_CARD_POS_X;
else
choice_pos.X-=DISPLAY_CARD_WIDTH;
Draw_Cursor_in_Display_Card_Message(choice_pos,hOut);//in about_Draw_function.cpp
SetConsoleCursorPosition(hOut,choice_pos);
return 0;
case RIGHT:
if(choice_pos.X==DISPLAY_THIRD_CARD_POS_X)
choice_pos.X=DISPLAY_FIRST_CARD_POS_X;
else
choice_pos.X+=DISPLAY_CARD_WIDTH;
Draw_Cursor_in_Display_Card_Message(choice_pos,hOut);//in about_Draw_function.cpp
SetConsoleCursorPosition(hOut,choice_pos);
return 0;
}
}
if(b==VK_RETURN)
{
return VK_RETURN;
}
if(b==VK_ESCAPE)
{
return VK_ESCAPE;
}
}
void Display_One_Card(COORD choice_pos,vector<Card> &card,HANDLE hOut)
{
Draw_Display_Window(hOut);
int n=0;
for(unsigned short a=0;a<3;a++)
for(unsigned short b=0;b<3;b++)
{
if(choice_pos.X==DISPLAY_FIRST_CARD_POS_X+a*DISPLAY_CARD_WIDTH
&&choice_pos.Y==DISPLAY_FIRST_CARD_POS_Y+b*DISPLAY_CARD_HIGH)
n=a*3+b;
}
Draw_one_Card_Introduce(card[n],hOut);
//the tips position depend on the effect
COORD pos={80,35};
SetConsoleCursorPosition(hOut,pos);
cout<<" Please press any key to back......";
while(1)
{
if(_kbhit())
{
int b=_getch();
return;
}
}
}
int Get_and_Respone_Key_Event_in_Number_Story(HANDLE hOut)
{
int b=_getch();
if(b!=VK_ESCAPE&&b!=VK_RETURN&&b==224)
{
b=_getch();
if(b==LEFT)
return TO_LEFT;
if(b==RIGHT)
return TO_RIGHT;
}
if(b==VK_RETURN)
{
return VK_RETURN;
}
if(b==VK_ESCAPE)
{
return VK_ESCAPE;
}
}