feat(PersonalVehicles): Alphabetic list

This commit is contained in:
Yimura 2022-01-08 17:48:46 +01:00
parent b7a0c39c02
commit 0167556de5
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682
3 changed files with 21 additions and 9 deletions

View File

@ -53,16 +53,17 @@ namespace big
{
for (auto& it : g_mobile_service->m_personal_vehicles)
{
std::string label = it.first;
auto& personal_veh = it.second;
std::string lower = personal_veh.get_display_name().c_str();
std::string lower = label.c_str();
std::transform(lower.begin(), lower.end(), lower.begin(), tolower);
if (lower.find(lower_search) != std::string::npos)
{
if (ImGui::Selectable(
personal_veh.get_display_name().c_str(),
personal_veh.get_id() == mobile::util::get_current_personal_vehicle()
label.c_str(),
personal_veh->get_id() == mobile::util::get_current_personal_vehicle()
))
{
strcpy(search, "");
@ -70,7 +71,7 @@ namespace big
QUEUE_JOB_BEGIN_CLAUSE(&personal_veh)
{
personal_veh.summon();
personal_veh->summon();
}QUEUE_JOB_END_CLAUSE
}
}

View File

@ -56,10 +56,20 @@ namespace big
Hash hash = *veh_idx_global.at(66).as<Hash*>();
if (STREAMING::IS_MODEL_A_VEHICLE(hash))
{
if (auto& it = m_personal_vehicles.find(i); it != m_personal_vehicles.end() && it->second.get_hash() != hash)
it->second = PersonalVehicle(i, veh_idx_global);
else
m_personal_vehicles.emplace(i, PersonalVehicle(i, veh_idx_global));
auto veh = std::make_unique<PersonalVehicle>(i, veh_idx_global);
if (auto& it = m_pv_lookup.find(i); it != m_pv_lookup.end())
{
m_personal_vehicles.erase(it->second);
it->second = veh->get_display_name();
m_personal_vehicles.emplace(veh->get_display_name(), std::move(veh));
continue;
}
m_pv_lookup.emplace(i, veh->get_display_name());
m_personal_vehicles.emplace(veh->get_display_name(), std::move(veh));
}
script::get_current()->yield();

View File

@ -29,7 +29,8 @@ namespace big
void register_vehicles();
std::map<int, PersonalVehicle> m_personal_vehicles;
std::map<std::string, std::unique_ptr<PersonalVehicle>> m_personal_vehicles;
std::map<int, std::string> m_pv_lookup;
};