-
Notifications
You must be signed in to change notification settings - Fork 7
/
Config.hpp
172 lines (157 loc) · 6.14 KB
/
Config.hpp
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
// Config.hpp
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include "Aimbot.hpp"
#include "Camera.hpp"
#include "Glow.hpp"
class Config {
public:
static Config& GetInstance() {
static Config instance;
return instance;
}
// Method to initialize the Config instance.
void Initialize(const std::string& filePath, Aimbot* aimAssistance, Camera* gameCamera, Sense* esp) {
if (!initialized) {
configFilePath = filePath;
AimAssistance = aimAssistance;
GameCamera = gameCamera;
ESP = esp;
Update();
initialized = true;
}
}
void Update() {
std::ifstream configFile(configFilePath);
std::string line;
if (!configFile.is_open()) {
std::cerr << "Failed to open config file: " << configFilePath << std::endl;
return;
}
while (getline(configFile, line)) {
std::istringstream lineStream(line);
std::string key, value;
if (getline(lineStream, key, '=') && getline(lineStream, value)) {
updateVariable(key, value);
}
}
}
void Save() {
std::ofstream configFile(configFilePath);
if (!configFile.is_open()) {
std::cerr << "Failed to open config file: " << configFilePath << std::endl;
return;
}
configFile << "AimSticky=" << (AimAssistance->Sticky ? "true" : "false") << std::endl;
configFile << "AimFOV=" << AimAssistance->FOV << std::endl;
configFile << "AimSmooth=" << AimAssistance->Smooth << std::endl;
configFile << "AimSmoothMaxIncrease=" << AimAssistance->MaxSmoothIncrease << std::endl;
configFile << "AimRecoilCompensation=" << AimAssistance->RecoilCompensation << std::endl;
configFile << "AimBotKey=" << AimAssistance->AimBotKey << std::endl;
configFile << "AimBotKey2=" << AimAssistance->AimBotKey2 << std::endl;
configFile << "AimTriggerKey=" << AimAssistance->AimTriggerKey << std::endl;
configFile << "AimFlickKey=" << AimAssistance->AimFlickKey << std::endl;
configFile << "GlowItem=" << (ESP->ItemGlow ? "true" : "false") << std::endl;
configFile << "GlowItemRarity=" << ESP->MinimumItemRarity << std::endl;
configFile << "ResolutionX=" << GameCamera->ScreenSize.x << std::endl;
configFile << "ResolutionY=" << GameCamera->ScreenSize.y << std::endl;
configFile << "FOV=" << GameCamera->FOV << std::endl;
configFile << "KmboxType=" << AimAssistance->KmboxType << std::endl;
configFile << "KmboxIP=" << AimAssistance->KmboxIP << std::endl;
configFile << "KmboxPort=" << AimAssistance->KmboxPort << std::endl;
configFile << "KmboxUUID=" << AimAssistance->KmboxUUID << std::endl;
configFile << "KmboxComPort=" << AimAssistance->KmboxComPort << std::endl;
}
private:
std::string configFilePath;
Aimbot* AimAssistance = nullptr;
Camera* GameCamera = nullptr;
Sense* ESP = nullptr;
bool initialized = false;
// Private constructor
Config() {}
// Existing methods...
// Delete copy constructor and assignment operator
Config(Config const&) = delete;
void operator=(Config const&) = delete;
void updateVariable(const std::string& key, const std::string& value) {
if (key == "AimSticky") {
if (value == "true") {
AimAssistance->Sticky = true;
}
else if (value == "false") {
AimAssistance->Sticky = false;
}
}
else if (key == "AimFOV") {
AimAssistance->FOV = std::stof(value);
}
else if (key == "AimSmooth") {
AimAssistance->Smooth = std::stof(value);
}
else if (key == "AimSmoothMaxIncrease") {
AimAssistance->MaxSmoothIncrease = std::stof(value);
}
else if (key == "AimRecoilCompensation") {
AimAssistance->RecoilCompensation = std::stof(value);
}
else if (key == "AimBotKey") {
AimAssistance->AimBotKey = std::stoi(value);
}
else if (key == "AimBotKey2") {
AimAssistance->AimBotKey2 = std::stoi(value);
}
else if (key == "AimTriggerKey") {
AimAssistance->AimTriggerKey = std::stoi(value);
}
else if (key == "AimFlickKey") {
AimAssistance->AimFlickKey = std::stoi(value);
}
else if (key == "GlowItem") {
if (value == "true") {
ESP->ItemGlow = true;
}
else if (value == "false") {
ESP->ItemGlow = false;
}
}
else if (key == "GlowItemRarity") {
ESP->MinimumItemRarity = std::stoi(value);
}
else if (key == "ResolutionX") {
GameCamera->ScreenSize.x = std::stoi(value);
}
else if (key == "ResolutionY") {
GameCamera->ScreenSize.y = std::stoi(value);
}
else if (key == "FOV") {
GameCamera->FOV = std::stof(value);
}
else if (key == "KmboxType") {
AimAssistance->KmboxType = value;
}
else if (key == "KmboxIP") {
// Ensure we don't exceed the buffer size, including space for the null terminator
std::strncpy(AimAssistance->KmboxIP, value.c_str(), sizeof(AimAssistance->KmboxIP) - 1);
// Ensure null termination
AimAssistance->KmboxIP[sizeof(AimAssistance->KmboxIP) - 1] = '\0';
}
else if (key == "KmboxPort") {
// Ensure we don't exceed the buffer size, including space for the null terminator
std::strncpy(AimAssistance->KmboxPort, value.c_str(), sizeof(AimAssistance->KmboxPort) - 1);
// Ensure null termination
AimAssistance->KmboxPort[sizeof(AimAssistance->KmboxPort) - 1] = '\0';
}
else if (key == "KmboxUUID") {
// Ensure we don't exceed the buffer size, including space for the null terminator
std::strncpy(AimAssistance->KmboxUUID, value.c_str(), sizeof(AimAssistance->KmboxUUID) - 1);
// Ensure null termination
AimAssistance->KmboxUUID[sizeof(AimAssistance->KmboxUUID) - 1] = '\0';
}
else if (key == "KmboxComPort") {
AimAssistance->KmboxComPort = std::stoi(value);
}
}
};