Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum AnimationTypes { STATIC, DYNAMIC, INTERP };
- std::string pChar(std::string first_, std::string second_) {
- return (std::stringstream{} << first_ << second_).str();
- }
- float Animate(const char* label, const char* second_label, bool if_, float Maximal_, float Speed_, int type) {
- auto ID = ImGui::GetID(pChar(label, second_label).c_str());
- static std::map<ImGuiID, float> pValue;
- auto this_e = pValue.find(ID);
- if (this_e == pValue.end()) {
- pValue.insert({ ID, 0.f });
- this_e = pValue.find(ID);
- }
- switch (type) {
- case DYNAMIC: {
- if (if_) //do
- this_e->second += abs(Maximal_ - this_e->second) / Speed_;
- else
- this_e->second -= (0 + this_e->second) / Speed_;
- }
- break;
- case INTERP: {
- this_e->second += (Maximal_ - this_e->second) / Speed_;
- }
- break;
- case STATIC: {
- if (if_) //do
- this_e->second += Speed_;
- else
- this_e->second -= Speed_;
- }
- break;
- }
- if (type != INTERP) {
- if (this_e->second < 0.f)
- this_e->second = 0.f;
- else if (this_e->second > Maximal_)
- this_e->second = Maximal_;
- }
- return this_e->second;
- }
- void DrawShapeAnimated(const char* label, ImVec2 min, ImVec2 max, ImVec2 pos, ImColor color) {
- int hovered_delta = Animate(label, "hovered_rect", ImGui::IsMouseHoveringRect(min, max, false), 255.f, 15.f, STATIC);
- ImGui::SetCursorPos(pos - ImGui::GetWindowPos());
- auto clicked = ImGui::GetIO().MouseClicked[0] && ImGui::IsMouseHoveringRect(min, max, false);
- auto ID = ImGui::GetID(pChar(label, "b_animation").c_str());
- static std::map<ImGuiID, bool> pValue;
- auto ItPLibrary = pValue.find(ID);
- if (ItPLibrary == pValue.end()) {
- pValue.insert({ ID, false });
- ItPLibrary = pValue.find(ID);
- }
- float radius = Animate(label, "circle_radius", ItPLibrary->second, 100.f, 10.f, DYNAMIC);
- static std::map<ImGuiID, int> pValue2;
- static POINT MousePoint;
- GetCursorPos(&MousePoint);
- static std::map<ImGuiID, ImVec2> CirclePosMap;
- auto CirclePos = CirclePosMap.find(ID);
- if (CirclePos == CirclePosMap.end()) {
- CirclePosMap.insert({ ID, ImVec2(MousePoint.x, MousePoint.y) });
- CirclePos = CirclePosMap.find(ID);
- }
- if (clicked) {
- CirclePos->second = ImVec2(MousePoint.x, MousePoint.y);
- ItPLibrary->second = true;
- }
- if (ItPLibrary->second) {
- if (radius >= 95.f) {
- ItPLibrary->second = false;
- radius = 0.f;
- }
- }
- ImRect bb = ImRect(min, max);
- auto size = bb.GetSize();
- //calc circle start radius and scale radius
- float StartRad = sqrt((size.x + size.y) / 2);
- //scale :::
- float ScaleRad = ((StartRad + radius) + (sqrt(size.x * size.y) / ((size.x - size.y) / StartRad))) * 0.5;
- ImGui::BeginChild(pChar("drawlist_zone", label).c_str(), size, false); {
- if (ItPLibrary->second)
- ImGui::GetWindowDrawList()->AddCircleFilled(CirclePos->second, StartRad + ScaleRad, ImColor(int(255.f * color.Value.x), int(255.f * color.Value.y), int(255.f * color.Value.z), 95 - (int)(radius)), (StartRad + ScaleRad) * 15.f);
- }
- ImGui::EndChild();
- }
- void create_window(const char* name, std::vector <std::string> vec ) {
- ImGui::SetNextWindowSize(ImVec2(170, 30));
- //draw
- //flags -
- static const WORD dw_window_flags{
- ImGuiWindowFlags_NoBackground
- | ImGuiWindowFlags_NoTitleBar
- | ImGuiWindowFlags_NoCollapse
- | ImGuiWindowFlags_NoResize
- | ImGuiWindowFlags_NoScrollbar
- | ImGuiWindowFlags_NoScrollWithMouse
- };
- if (ImGui::Begin(name, nullptr, dw_window_flags))
- {
- //get vars :::
- ImColor theme = ImColor(45, 130, 242, 255);
- ImColor theme_zero = ImColor(45, 130, 242, 0);
- ImColor black = ImColor(0, 0, 0, 210);
- ImColor black_zero = ImColor(0, 0, 0, 0);
- ImColor black_half = ImColor(0, 0, 0, 60);
- const auto draw = ImGui::GetBackgroundDrawList();
- const auto p = ImGui::GetWindowPos();
- const auto s = ImGui::GetWindowSize();
- //background
- draw->AddRectFilledMultiColor(p + ImVec2(10, 0), p + ImVec2(s.x / 2, s.y), black_half, black_half, black_half, black_half);
- draw->AddRectFilledMultiColor(p + ImVec2(s.x / 2, 0), p + ImVec2(s.x, s.y) - ImVec2(10, 0), black_half, black_half, black_half, black_half);
- //up
- draw->AddRectFilledMultiColor(p + ImVec2(10, 0), p + ImVec2(s.x / 2, 2), theme_zero, theme, theme, theme_zero);
- draw->AddRectFilledMultiColor(p + ImVec2(s.x / 2, 0), p + ImVec2(s.x, 2) - ImVec2(10, 0), theme, theme_zero, theme_zero, theme);
- auto spec_sz = ImGui::CalcTextSize(name);
- draw->AddText(p + ImVec2(s.x / 2 - spec_sz.x / 2, s.y / 2 - spec_sz.y / 2), ImColor(255, 255, 255), name);
- ImVec2 shape_pos = p + ImVec2(10, 0);
- ImVec2 shape_sz = s - ImVec2(20, -2);
- DrawShapeAnimated(name, shape_pos, shape_pos + shape_sz, shape_pos, theme);
- for (auto i = 0; i < vec.size(); i++) {
- int alpha_of_this = Animate("Spectators", vec[i].c_str(), true, 255, 15, STATIC);
- auto first_circle_pos = ImVec2(p.x + 20, p.y + s.y + 15 + 25 * i);
- draw->AddCircleFilled(first_circle_pos, 2.3f, ImColor(45, 130, 242, alpha_of_this), 5.f * 15.f);
- draw->AddCircleFilled(first_circle_pos, 2.f, ImColor(45, 130, 242, alpha_of_this), 5.f * 15.f);
- draw->AddText(first_circle_pos + ImVec2(10, -9), ImColor(255, 255, 255, alpha_of_this), vec[i].c_str());
- }
- draw->AddRectFilled(p + ImVec2(10, s.y), p + ImVec2(s.x - 10, 4 + s.y + 25 * vec.size()), ImColor(0, 0, 0, 100), 0, 15);
- }
- ImGui::End();
- }
- void init() {
- static std::vector <std::string> binds {"Rapidfire", "Hideshots", "Force-body"};
- create_window("Keys state", binds);
- static std::vector <std::string> spec {"Bot Maxim"};
- create_window("Spectators", spec);
- }
Advertisement
Add Comment
Please, Sign In to add comment