Skip to content

Commit

Permalink
move hovered entity info and coords to tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Dec 22, 2022
1 parent 5cf01e1 commit eccb5f2
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/injected/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2782,11 +2782,11 @@ void update_filter(std::string s)
scroll_top = true;
}

void tooltip(const char* tip)
void tooltip(const char* tip, bool force = false)
{
if (!options["show_tooltips"])
if (!options["show_tooltips"] && !force)
return;
if (ImGui::IsItemHovered())
if (ImGui::IsItemHovered() || force)
{
ImGuiContext& g = *GImGui;
if (options["hd_cursor"])
Expand Down Expand Up @@ -4260,13 +4260,7 @@ void render_clickhandler()
{
ImVec2 mpos = normalize(mouse_pos());
std::pair<float, float> cpos = UI::click_position(mpos.x, mpos.y);
// std::pair<float, float> campos = get_camera_position();
ImDrawList* dl = ImGui::GetBackgroundDrawList();
std::string buf = fmt::format("{:.2f}, {:.2f}", cpos.first, cpos.second);
// char buf2[32];
// sprintf(buf2, "Camera: %0.2f, %0.2f", campos.first, campos.second);
dl->AddText(ImVec2(io.MousePos.x + 16, io.MousePos.y), ImColor(1.0f, 1.0f, 1.0f, 1.0f), buf.c_str());
// dl->AddText(ImVec2(io.MousePos.x + 16, io.MousePos.y + 16), ImColor(1.0f, 1.0f, 1.0f, 1.0f), buf2);
std::string coords = fmt::format("{:.2f}, {:.2f}", cpos.first, cpos.second);
unsigned int mask = safe_entity_mask;
if (ImGui::GetIO().KeyShift) // TODO: Get the right modifier from mouse_destroy_unsafe
{
Expand All @@ -4276,9 +4270,11 @@ void render_clickhandler()
if (hovered != nullptr)
{
render_hitbox(hovered, true, ImColor(50, 50, 255, 200));
std::string buf3 = fmt::format("{}, {}", hovered->uid, entity_names[hovered->type->id]);
dl->AddText(ImVec2(io.MousePos.x + 16, io.MousePos.y + 16), ImColor(1.0f, 1.0f, 1.0f, 1.0f), buf3.c_str());
coords += fmt::format("\n{}, {}", hovered->uid, entity_names[hovered->type->id]);
}
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {4.0f, 4.0f});
tooltip(coords.c_str(), true);
ImGui::PopStyleVar(ImGuiStyleVar_WindowPadding);
}
}

Expand Down

0 comments on commit eccb5f2

Please sign in to comment.