This commit is contained in:
HarrySilan 2022-08-04 20:36:43 +08:00
parent 1eea293f80
commit 87877bc18f

View File

@ -138,11 +138,12 @@ namespace cheat::feature
else else
{ {
std::vector list(checkedIndices.begin(), checkedIndices.end()); std::vector list(checkedIndices.begin(), checkedIndices.end());
if (selectedIndex == list.back() ? next : selectedIndex == list.front()) if (next ? selectedIndex == list.back() : selectedIndex == list.front())
return; return;
auto index = std::distance(list.begin(), std::find(list.begin(), list.end(), selectedIndex)); 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)); selectedIndex = list.at(index + (next ? 1 : -1));
position = Teleports.at(selectedIndex).position;
} }
mapTeleport.TeleportTo(position); mapTeleport.TeleportTo(position);
UpdateIndexName(); UpdateIndexName();
@ -281,8 +282,8 @@ namespace cheat::feature
{ {
std::sort(Teleports.begin(), Teleports.end(), [](const auto &a, const auto &b) 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; }); { 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 = std::includes(checkedIndices.begin(), checkedIndices.end(), searchIndices.begin(), searchIndices.end()) && !searchIndices.empty();
bool allSearchChecked = checkedIndices.size() == searchIndices.size() && !searchIndices.empty(); bool allChecked = (checkedIndices.size() == Teleports.size() && !Teleports.empty()) || allSearchChecked;
ImGui::Checkbox("All", &allChecked); ImGui::Checkbox("All", &allChecked);
if (ImGui::IsItemClicked()) if (ImGui::IsItemClicked())
{ {
@ -320,7 +321,6 @@ namespace cheat::feature
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, maxNameLength * 8 + 10); ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, maxNameLength * 8 + 10);
ImGui::TableSetupColumn("Position"); ImGui::TableSetupColumn("Position");
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth;
for (const auto &[name, position, description] : Teleports) for (const auto &[name, position, description] : Teleports)
{ {
@ -374,15 +374,11 @@ namespace cheat::feature
selectedByClick = true; selectedByClick = true;
UpdateIndexName(); 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::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::Text("%s", name.c_str());
ImGui::PopStyleColor();
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
{ {
ImGui::BeginTooltip(); ImGui::BeginTooltip();