-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.cpp
More file actions
96 lines (78 loc) · 2.2 KB
/
Menu.cpp
File metadata and controls
96 lines (78 loc) · 2.2 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
#include "pch.h"
#include "Menu.h"
#include "Features.h"
namespace Colors
{
const char* red = "\x1B[31m";
const char* green = "\x1B[32m";
const char* end = "\x1B[0m";
};
void Menu::WriteMenu()
{
system("cls");
std::cout << Menu::ascii << "\n\n";
for (size_t i = 0; i < Menu::TOTAL_OPTIONS; ++i)
{
unsigned int pad = Menu::padding - options[i].length();
if (Menu::toggled[i] == true)
{
std::cout << options[i] << std::setw(pad+2) << " [ " << Colors::green << "ON" << Colors::end << " ]" << std::endl;
}
else if (Menu::toggled[i] == false)
{
std::cout << options[i] << std::setw(pad+2) << " [ " << Colors::red << "OFF" << Colors::end << " ]" << std::endl;
}
}
std::cout << "\n\n";
}
void Menu::Select(const unsigned int numberChoice)
{
bool on_off = false;
if (!Menu::IsSelected(numberChoice))
on_off = true;
unsigned int idx = numberChoice - 1;
Menu::toggled[idx] = on_off;
if (on_off == true)
{
switch (numberChoice)
{
case 1:
Menu::threads[idx] = std::thread(Features::UnlimitedHP, idx);
Menu::threads[idx].detach();
break;
case 2:
Menu::threads[idx] = std::thread(Features::UnlimitedAmmo, idx);
Menu::threads[idx].detach();
break;
case 3:
Menu::threads[idx] = std::thread(Features::NoRecoil, idx);
Menu::threads[idx].detach();
default:
break;
}
}
Menu::WriteMenu();
}
char Menu::IsSelected(const unsigned int numberChoice)
{
if (Menu::TOTAL_OPTIONS < numberChoice)
return -1;
return true ? Menu::toggled[numberChoice - 1] == true : false;
}
const char* Menu::ascii = R"(
_____ .__ __ ____ __. ___.
/ _ \ __________ | |_/ |_ | |/ _|__ _\_ |__ ____
/ /_\ \ / ___/ _ \| |\ __\ | < | | \ __ \_/ __ \
/ | \\___ ( <_> ) |_| | | | \| | / \_\ \ ___/
\____|__ /____ >____/|____/__| |____|__ \____/|___ /\___ >
\/ \/ \/ \/
)";
std::string Menu::options[Menu::TOTAL_OPTIONS] = {
"1 | Unlimited Health",
"2 | Unlimited Ammo",
"3 | No Recoil",
};
bool Menu::toggled[Menu::TOTAL_OPTIONS] = {};
std::thread Menu::threads[Menu::TOTAL_OPTIONS] = {};
unsigned int Menu::padding = 25;
unsigned int Menu::largestString = 0;