custom spam/killsay files automatically reload. fix imgui int for some

catvars
This commit is contained in:
nullifiedcat 2017-07-14 20:47:27 +03:00
parent 30bba4ceb4
commit 9d13e787b6
7 changed files with 29 additions and 0 deletions

View File

@ -31,6 +31,7 @@ void CatVar_Integer(CatVar& var) {
int value = var;
ImGui::PushItemWidth(120.0f);
int step = var.restricted ? (var.max - var.min) / 50 : 1;
if (step == 0) step = 1;
if (ImGui::InputInt(label, &value, step, step * 20)) {
var = value;
}

View File

@ -272,6 +272,7 @@ void hack::Initialize() {
hacks::shared::anticheat::Init();
hacks::tf2::healarrow::Init();
InitSpinner();
hacks::shared::spam::Init();
logging::Info("Initialized Fidget Spinner");
}

View File

@ -82,6 +82,9 @@ void Reload() {
void Init() {
g_IEventManager2->AddListener(&getListener(), (const char*)"player_death", false);
filename.InstallChangeCallback([](IConVar* var, const char* pszOV, float flOV) {
file.TryLoad(std::string(filename.GetString()));
});
}
void Shutdown() {

View File

@ -137,6 +137,12 @@ int QueryPlayer(Query query) {
return index_result;
}
void Init() {
filename.InstallChangeCallback([](IConVar* var, const char* pszOV, float flOV) {
file.TryLoad(std::string(filename.GetString()));
});
}
bool SubstituteQueries(std::string& input) {
size_t index = input.find("%query:");
while (index != std::string::npos) {

View File

@ -25,6 +25,7 @@ extern CatVar enabled;
extern CatVar filename;
extern CatCommand reload;
void Init();
void CreateMove();
void Reset();
void Reload();

View File

@ -18,6 +18,21 @@
TextFile::TextFile()
: lines {} {}
bool TextFile::TryLoad(std::string name) {
if (name.length() == 0) return false;
std::string filename = format("cathook/", name);
std::ifstream file(filename, std::ios::in);
if (!file) {
return false;
}
lines.clear();
for (std::string line; std::getline(file, line);) {
if (*line.rbegin() == '\r') line.erase(line.length() - 1, 1);
lines.push_back(line);
}
return true;
}
void TextFile::Load(std::string name) {
std::string filename = format("cathook/", name);
std::ifstream file(filename, std::ios::in);
@ -27,6 +42,7 @@ void TextFile::Load(std::string name) {
}
lines.clear();
for (std::string line; std::getline(file, line);) {
if (*line.rbegin() == '\r') line.erase(line.length() - 1, 1);
lines.push_back(line);
}
}

View File

@ -17,6 +17,7 @@ class TextFile {
public:
TextFile();
void Load(std::string filename);
bool TryLoad(std::string filename);
size_t LineCount() const;
const std::string& Line(size_t id) const;
public: