aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBDKPlayer <55560692+BDKPlayer@users.noreply.github.com>2020-06-04 17:43:30 +0200
committerGitHub <noreply@github.com>2020-06-04 17:43:30 +0200
commit3a8e1f17e6a2a032271157da906c6f44c196f77e (patch)
tree45362762a13bd6cb6e8c8bc5c61471e4b4743078
parent106a7257fe6f0a6edf717b07bd48a431da1fd1e0 (diff)
parenteb2b7afb970254e71fdee7702f708f9696951ed9 (diff)
Merge pull request #1 from leocdi/master
ESP Refact
-rw-r--r--ESP.cpp103
-rw-r--r--ESP.h9
2 files changed, 68 insertions, 44 deletions
diff --git a/ESP.cpp b/ESP.cpp
index 43f57b6..3cf5c35 100644
--- a/ESP.cpp
+++ b/ESP.cpp
@@ -3,7 +3,7 @@
#include "Sdk.h"
#include "Renderer.h"
#include "Engine.h"
-
+#include <map>
#include <math.h>
#include "Config.h"
@@ -243,59 +243,74 @@ void ESP::OnNeutralUnit(Unit* unit)
return;
}
- if (strcmp(unitName.c_str(), "FISHS") == 0 || strcmp(unitName.c_str(), "FISHX") == 0 ||
- strcmp(unitName.c_str(), "FISH1") == 0 || strcmp(unitName.c_str(), "FISH2") == 0 ||
- strcmp(unitName.c_str(), "FISH3") == 0 || strcmp(unitName.c_str(), "FISH4") == 0 ||
- strcmp(unitName.c_str(), "turtles") == 0)
- {
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
- }
+ typedef void (ESP::* fPtr)(Vector2&, std::string&);
+ typedef std::map<std::vector<std::string>, fPtr> Actions;
+ Actions link;
- if (strcmp(unitName.c_str(), "BOARX") == 0 || strcmp(unitName.c_str(), "RHINO") == 0 ||
- strcmp(unitName.c_str(), "BOAR") == 0 || strcmp(unitName.c_str(), "BOARJ") == 0 ||
- strcmp(unitName.c_str(), "WELEF") == 0)
- {
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ff00);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
- }
+ std::vector<std::string> valuesFish = { "FISHS", "FISHX","FISH1","FISH2","FISH3","FISH4","turtles" };
+ std::vector<std::string> valuesHeavyFood = { "BOARX", "RHINO","BOAR","BOARJ","WELEF" };
+ std::vector<std::string> valuesLighthuntable = { "DEERX", "IBEX","ZEBRA","OSTRICH" };
+ std::vector<std::string> valuesLightFood = { "SHEEPG", "GOOSE","PIG", "LLAMAG", "Cow Black", "Cow Brown", "Cow Black and White", "BUFFALO", "TURKYG", "GOAT" };
+ std::vector<std::string> valuesDangerousAnimal = { "WOLFX", "KOMODO","GJAGR", "SLEOPA", "BEAR", "CROCO", "LION", "TIGER" };
+ std::vector<std::string> valuesRelic = { "RELIC" };
- if (strcmp(unitName.c_str(), "DEERX") == 0 || strcmp(unitName.c_str(), "IBEX") == 0 ||
- strcmp(unitName.c_str(), "ZEBRA") == 0 || strcmp(unitName.c_str(), "OSTRICH") == 0)
- {
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ffff);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
- }
+ void (ESP:: * RenderStyleAction)(Vector2&, std::string&);
- if (strcmp(unitName.c_str(), "SHEEPG") == 0 || strcmp(unitName.c_str(), "GOOSE") == 0 ||
- strcmp(unitName.c_str(), "PIG") == 0 || strcmp(unitName.c_str(), "LLAMAG") == 0 ||
- strcmp(unitName.c_str(), "Cow Black") == 0 || strcmp(unitName.c_str(), "Cow Brown") == 0 ||
- strcmp(unitName.c_str(), "Cow Black and White") == 0 || strcmp(unitName.c_str(), "BUFFALO") == 0 ||
- strcmp(unitName.c_str(), "TURKYG") == 0 || strcmp(unitName.c_str(), "Cow Black") == 0 ||
- strcmp(unitName.c_str(), "GOAT") == 0)
- {
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
- }
+ link.emplace(valuesFish, &ESP::RenderStyleFish);
+ link.emplace(valuesHeavyFood, &ESP::RenderStyleHeavyFood);
+ link.emplace(valuesLighthuntable, &ESP::RenderStyleLighHuntable);
+ link.emplace(valuesLightFood, &ESP::RenderStyleLightFood);
+ link.emplace(valuesDangerousAnimal, &ESP::RenderStyleDangerousAnimal);
+ link.emplace(valuesRelic, &ESP::RenderStyleRelic);
- if (strcmp(unitName.c_str(), "WOLFX") == 0 || strcmp(unitName.c_str(), "KOMODO") == 0 ||
- strcmp(unitName.c_str(), "GJAGR") == 0 || strcmp(unitName.c_str(), "SLEOPA") == 0 ||
- strcmp(unitName.c_str(), "BEAR") == 0 || strcmp(unitName.c_str(), "CROCO") == 0 ||
- strcmp(unitName.c_str(), "LION") == 0 || strcmp(unitName.c_str(), "TIGER") == 0)
+ for (std::pair<std::vector<std::string>, fPtr> element : link)
{
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x40ff0000);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+ if (std::find(element.first.begin(), element.first.end(), unitName) != element.first.end())
+ {
+ RenderStyleAction = element.second;
+ }
}
-
- if (strcmp(unitName.c_str(), "RELIC") == 0)
- {
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 50, 0x40ffffff);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
- }
+ (this->*RenderStyleAction)(screenPos, unitName);
}
}
+void ESP::RenderStyleRelic(Vector2& screenPos, std::string& unitName)
+{
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 50, 0x40ffffff);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+}
+
+void ESP::RenderStyleDangerousAnimal(Vector2& screenPos, std::string& unitName)
+{
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x40ff0000);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+}
+
+void ESP::RenderStyleLighHuntable(Vector2& screenPos, std::string& unitName)
+{
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ffff);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+}
+
+void ESP::RenderStyleHeavyFood(Vector2& screenPos, std::string& unitName)
+{
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ff00);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+}
+
+void ESP::RenderStyleLightFood(Vector2& screenPos, std::string& unitName)
+{
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+}
+
+void ESP::RenderStyleFish(Vector2& screenPos, std::string& unitName)
+{
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+}
+
void ESP::OnMenuMainWindow()
{
ImGui::Separator();
diff --git a/ESP.h b/ESP.h
index a083348..1595556 100644
--- a/ESP.h
+++ b/ESP.h
@@ -1,5 +1,6 @@
#pragma once
#include "Feature.h"
+#include <string>
struct Vector2;
struct Vector3;
@@ -31,5 +32,13 @@ class ESP : public Feature
void DrawBox(Unit* unit, int32_t color, bool drawName);
void DrawBox(Vector3 position, Vector2 edgeSize, int32_t color);
+
+ void RenderStyleRelic(Vector2& screenPos, std::string& unitName);
+ void RenderStyleDangerousAnimal(Vector2& screenPos, std::string& unitName);
+ void RenderStyleLighHuntable(Vector2& screenPos, std::string& unitName);
+ void RenderStyleHeavyFood(Vector2& screenPos, std::string& unitName);
+ void RenderStyleLightFood(Vector2& screenPos, std::string& unitName);
+ void RenderStyleFish(Vector2& screenPos, std::string& unitName);
+
void DrawCircle(Unit* unit, int radius, int32_t color, int smoothness , float thickness, bool drawName);
}; \ No newline at end of file