-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcontrols.cpp
82 lines (75 loc) · 1.77 KB
/
controls.cpp
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
#include "stdafx.h"
namespace controls {
bool isMenuEnabled = false;
bool optionpress = false;
bool leftpress = false;
bool rightpress = false;
bool uppress = false;
bool downpress = false;
int optioncount;
int currentoption;
int menulevel = 0;
int Delay = GetTickCount();
char* currentmenu[100];
char* actualmenu = (char*)"mainmenu";
int lastoption[100];
void changeMenu(const char* menuname) {
currentmenu[menulevel] = actualmenu;
lastoption[menulevel] = currentoption;
menulevel++;
actualmenu = (char*)menuname;
currentoption = 1;
}
bool currentMenu(const char* menuname) {
if (menuname == actualmenu) return true;
else return false;
}
void backMenu() {
menulevel--;
actualmenu = currentmenu[menulevel];
currentoption = lastoption[menulevel];
}
void CheckKeys() {
optionpress = false;
if (GetTickCount() - Delay > 100) {
if (GetAsyncKeyState(VK_MULTIPLY)) {
if (menulevel == 0) changeMenu("mainmenu");
else if (menulevel == 1) backMenu();
Delay = GetTickCount();
}
if (GetAsyncKeyState(VK_NUMPAD0)) {
if (menulevel > 0)
backMenu();
Delay = GetTickCount();
}
if (GetAsyncKeyState(VK_NUMPAD5)) {
optionpress = true;
Delay = GetTickCount();
}
if (GetAsyncKeyState(VK_NUMPAD2)) {
if (currentoption < optioncount)
currentoption++;
else
currentoption = 1;
Delay = GetTickCount();
downpress = true;
}
if (GetAsyncKeyState(VK_NUMPAD8)) {
if (currentoption > 1)
currentoption--;
else
currentoption = optioncount;
Delay = GetTickCount();
uppress = true;
}
if (GetAsyncKeyState(VK_NUMPAD4)) {
leftpress = true;
Delay = GetTickCount();
}
if (GetAsyncKeyState(VK_NUMPAD6)) {
rightpress = true;
Delay = GetTickCount();
}
}
}
}