-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu_control.cpp
More file actions
79 lines (59 loc) · 1.25 KB
/
Copy pathmenu_control.cpp
File metadata and controls
79 lines (59 loc) · 1.25 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
#include <iostream>
#include <windows.h>
#include <string.h>
#include <conio.h>
using namespace std ;
extern int menu_control ( int , int , int , int esc = 0 ) ;
extern void gotoxy ( int , int ) ;
extern bool newsPause ;
extern int menu_control ( int x , int start_y , int end_y , int esc )
{
string str = "" ;
string a = "" ;
char ch ;
char s[5] = "" ;
int b = 1 ;
int pos = 0 ;
while ( a != "13" )
{
gotoxy ( x , start_y + pos ) ;
newsPause = true ;
cout << " >> " ;
newsPause = false ;
b = 1 ;
while ( b )
{
ch=_getch();
if ( b ) b = 0 ;
if ( ch == -32 || ch == 0 ) b = 1 ;
if ( esc && ch == 27 )
{
a = "27" ;
break ;
}
str += itoa(ch,s,10) ;
a = str ;
if ( b == 1 && ch != -32 && ch != 0 ) { b = 0 ; str = "" ; }
if ( ch != -32 && ch != 0 ) str = "" ;
}
if ( esc && a == "27" )
{
return -1 ;
}
if ( a == "-3272" ) // UP KEY
{
gotoxy ( x , start_y + pos ) ;
cout << " " ;
if ( (start_y + pos) - 2 < start_y ) pos = ( end_y - start_y ) ;
else pos -= 2 ;
}
if ( a == "-3280" ) // DOWN KEY
{
gotoxy ( x , start_y + pos ) ;
cout << " " ;
if ( start_y + pos + 2 > end_y ) pos = 0 ;
else pos += 2 ;
}
}
return pos ;
}