mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
feat(VehicleService): Keep track of active profile
This commit is contained in:
parent
6f5e12168b
commit
be66188f7c
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<std::uint32_t, std::string> m_active_profiles;
|
||||
inline static std::vector<std::string> m_my_profiles;
|
||||
inline static std::unordered_map<std::string, HandlingProfile> m_handling_profiles;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user