From 46b0861b9ba0757ae26ef9bd63c3ff3beaefae22 Mon Sep 17 00:00:00 2001 From: praydog Date: Wed, 25 Oct 2023 21:33:59 -0700 Subject: [PATCH] UObjectHook: Add "Detach all" button --- src/mods/UObjectHook.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/mods/UObjectHook.cpp b/src/mods/UObjectHook.cpp index aa81caf9..4f1aff47 100644 --- a/src/mods/UObjectHook.cpp +++ b/src/mods/UObjectHook.cpp @@ -475,6 +475,30 @@ void UObjectHook::on_draw_ui() { std::shared_lock _{m_mutex}; + if (!m_motion_controller_attached_components.empty()) { + if (ImGui::Button("Detach all")) { + for (auto it : m_motion_controller_attached_components) { + auto comp = it.first; + auto& state = it.second; + + if (state.adjustment_visualizer != nullptr) { + auto vis = state.adjustment_visualizer; + GameThreadWorker::get().enqueue([this, vis]() { + if (!this->exists(vis)) { + return; + } + + vis->destroy_actor(); + }); + + state.adjustment_visualizer = nullptr; + } + } + + m_motion_controller_attached_components.clear(); + } + } + ImGui::Text("Objects: %zu (%zu actual)", m_objects.size(), sdk::FUObjectArray::get()->get_object_count()); if (ImGui::TreeNode("Recent Objects")) {