From 87877bc18fd43b928ecb04a54d8ef12b8cc85400 Mon Sep 17 00:00:00 2001 From: HarrySilan Date: Thu, 4 Aug 2022 20:36:43 +0800 Subject: [PATCH] fix #413 --- .../user/cheat/teleport/CustomTeleports.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/cheat-library/src/user/cheat/teleport/CustomTeleports.cpp b/cheat-library/src/user/cheat/teleport/CustomTeleports.cpp index 8e6738f..39b000c 100644 --- a/cheat-library/src/user/cheat/teleport/CustomTeleports.cpp +++ b/cheat-library/src/user/cheat/teleport/CustomTeleports.cpp @@ -138,11 +138,12 @@ namespace cheat::feature else { std::vector list(checkedIndices.begin(), checkedIndices.end()); - if (selectedIndex == list.back() ? next : selectedIndex == list.front()) + if (next ? selectedIndex == list.back() : selectedIndex == list.front()) return; + auto index = std::distance(list.begin(), std::find(list.begin(), list.end(), selectedIndex)); - position = Teleports.at(list.at(index + (next ? 1 : -1))).position; selectedIndex = list.at(index + (next ? 1 : -1)); + position = Teleports.at(selectedIndex).position; } mapTeleport.TeleportTo(position); UpdateIndexName(); @@ -281,8 +282,8 @@ namespace cheat::feature { std::sort(Teleports.begin(), Teleports.end(), [](const auto &a, const auto &b) { return StrCmpLogicalW(std::wstring(a.name.begin(), a.name.end()).c_str(), std::wstring(b.name.begin(), b.name.end()).c_str()) < 0; }); - bool allChecked = checkedIndices.size() == Teleports.size() && !Teleports.empty(); - bool allSearchChecked = checkedIndices.size() == searchIndices.size() && !searchIndices.empty(); + bool allSearchChecked = std::includes(checkedIndices.begin(), checkedIndices.end(), searchIndices.begin(), searchIndices.end()) && !searchIndices.empty(); + bool allChecked = (checkedIndices.size() == Teleports.size() && !Teleports.empty()) || allSearchChecked; ImGui::Checkbox("All", &allChecked); if (ImGui::IsItemClicked()) { @@ -320,7 +321,6 @@ namespace cheat::feature ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, maxNameLength * 8 + 10); ImGui::TableSetupColumn("Position"); ImGui::TableHeadersRow(); - ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth; for (const auto &[name, position, description] : Teleports) { @@ -374,15 +374,11 @@ namespace cheat::feature selectedByClick = true; UpdateIndexName(); } - ImGui::SameLine(); - ImGui::PushStyleColor(ImGuiCol_Text, selected ? IM_COL32(40, 90, 175, 255) : IM_COL32(255, 255, 255, 255)); - - if (selected) - nodeFlags |= ImGuiTreeNodeFlags_Selected; - ImGui::PopStyleColor(); ImGui::TableNextColumn(); + ImGui::PushStyleColor(ImGuiCol_Text, selected ? IM_COL32(40, 90, 175, 255) : ImGui::ColorConvertFloat4ToU32(ImGui::GetStyle().Colors[ImGuiCol_Text])); ImGui::Text("%s", name.c_str()); + ImGui::PopStyleColor(); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip();