diff --git a/BigBaseV2/src/gui/window/window_handling.cpp b/BigBaseV2/src/gui/window/window_handling.cpp index 480082f7..e19bcd7d 100644 --- a/BigBaseV2/src/gui/window/window_handling.cpp +++ b/BigBaseV2/src/gui/window/window_handling.cpp @@ -64,6 +64,9 @@ namespace big { auto& profile = it->second; + if (profile.share_code == g_vehicle_service->get_active_profile(profile.handling_hash)) + ImGui::TextColored({ 0.1254f,0.8039f,0.3137f,1.f }, "Active"); + ImGui::BeginGroup(); ImGui::Text("Name:"); @@ -82,9 +85,7 @@ namespace big ImGui::Text("Share Code: %s", profile.share_code.c_str()); if (ImGui::Button("Load Profile")) - { - *g_local_player->m_vehicle->m_handling = profile.data; - } + g_vehicle_service->set_handling_profile(profile); ImGui::EndGroup(); @@ -139,9 +140,7 @@ namespace big ImGui::Text("Share Code: %s", profile.share_code.c_str()); if (ImGui::Button("Load Profile")) - { - *g_local_player->m_vehicle->m_handling = profile.data; - } + g_vehicle_service->set_handling_profile(profile); ImGui::EndGroup(); } diff --git a/BigBaseV2/src/services/vehicle_service.cpp b/BigBaseV2/src/services/vehicle_service.cpp index a913471b..9b80f2e4 100644 --- a/BigBaseV2/src/services/vehicle_service.cpp +++ b/BigBaseV2/src/services/vehicle_service.cpp @@ -39,6 +39,13 @@ namespace big return 1; } + std::string vehicle_service::get_active_profile(std::uint32_t hash) + { + if (auto it = this->m_active_profiles.find(hash); it != this->m_active_profiles.end()) + return it->second; + return std::string(""); + } + bool vehicle_service::get_by_share_code(const char* share_code) { static std::string up_to_date = ""; @@ -172,6 +179,7 @@ namespace big if (auto it = m_handling_backup.find(g_local_player->m_vehicle->m_handling->m_model_hash); it != m_handling_backup.end()) { *g_local_player->m_vehicle->m_handling = it->second; + this->m_active_profiles.erase(g_local_player->m_vehicle->m_handling->m_model_hash); return true; } @@ -179,6 +187,21 @@ namespace big return false; } + void vehicle_service::set_active_profile(std::uint32_t hash, std::string share_code) + { + if (auto& it = this->m_active_profiles.find(hash); it != this->m_active_profiles.end()) + it->second = share_code; + else + this->m_active_profiles.emplace(hash, share_code); + } + + void vehicle_service::set_handling_profile(HandlingProfile& profile) + { + *g_local_player->m_vehicle->m_handling = profile.data; + + this->set_active_profile(profile.handling_hash, profile.share_code); + } + bool vehicle_service::update_mine(bool force_update) { static bool busy = false; diff --git a/BigBaseV2/src/services/vehicle_service.hpp b/BigBaseV2/src/services/vehicle_service.hpp index c1335ff2..740d95c8 100644 --- a/BigBaseV2/src/services/vehicle_service.hpp +++ b/BigBaseV2/src/services/vehicle_service.hpp @@ -120,13 +120,17 @@ namespace big bool apply_from_cache(std::string id); int attempt_save(); + std::string get_active_profile(std::uint32_t hash); bool get_by_share_code(const char* share_code); bool publish_profile(const char* name, const char* description); PublishStatus publish_status(PublishStatus new_status = PublishStatus::NONE); bool restore_vehicle(); + void set_active_profile(std::uint32_t hash, std::string share_code); + void set_handling_profile(HandlingProfile& profile); bool update_mine(bool force_update = false); + inline static std::unordered_map m_active_profiles; inline static std::vector m_my_profiles; inline static std::unordered_map m_handling_profiles;