From 3cdaf619ed7097c791fd844f99e8b0ea376be3a7 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Sat, 24 Sep 2022 00:51:37 +0600 Subject: [PATCH] Bug fixes --- resource/common/locale/English.toml | 1 + src/custom/vehcustmzr.cpp | 8 ++++++++ src/utils/widget.cpp | 9 +++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/resource/common/locale/English.toml b/resource/common/locale/English.toml index 4d75d6a..6bc6f89 100644 --- a/resource/common/locale/English.toml +++ b/resource/common/locale/English.toml @@ -625,6 +625,7 @@ TrafficType = "Traffic type" TuneTab = "Tune" TurnMass = "Turn mass" Type = "Type" +Unsupported = "This vehicle isn't compatible" UpperLimit = "Upper limit" Watertight = "Watertight car" WatertightTip = """ diff --git a/src/custom/vehcustmzr.cpp b/src/custom/vehcustmzr.cpp index f945ff4..a007a79 100644 --- a/src/custom/vehcustmzr.cpp +++ b/src/custom/vehcustmzr.cpp @@ -88,6 +88,13 @@ void VehCustmzrMgr::ApplyCustomizations(std::string& cat, std::string& key, std: int model = pVeh->m_nModelIndex; std::string name = Util::GetCarName(model); std::string index = std::format("{}.{}.", name, key); + int reqModel = m_CustomizeData.m_pData->Get((index + "Model").c_str(), -1); + + if (model != reqModel) + { + Util::SetMessage(TEXT("Vehicle.Unsupported")); + return; + } // colors toml::array *temp = m_CustomizeData.m_pData->GetArray((index + "ColorMat").c_str()); @@ -144,6 +151,7 @@ void VehCustmzrMgr::SaveCustomizations() int model = pVeh->m_nModelIndex; std::string name = Util::GetCarName(model); std::string index = std::format("{}.{} - {}.", name, name, m_nLabel); + m_CustomizeData.m_pData->Set((index + "Model").c_str(), model); // Save colors auto paintData = Paint.Get().GetData(pVeh); diff --git a/src/utils/widget.cpp b/src/utils/widget.cpp index 4e1b3e8..163919d 100644 --- a/src/utils/widget.cpp +++ b/src/utils/widget.cpp @@ -304,19 +304,16 @@ void DrawClippedImages(ResourceStore& data, ImVec2 imgSz, size_t imagesInRow, bo int imageCount = 1; size_t totalSz = data.m_nSearchList.size(); - ImGuiListClipper clipper((totalSz > 3 ? totalSz/3 : totalSz), imgSz.y); + ImGuiListClipper clipper((totalSz > imagesInRow ? totalSz/imagesInRow : totalSz), imgSz.y); while (clipper.Step()) { // hack to get clipper working with rowed items size_t start = clipper.DisplayStart * imagesInRow; size_t end = clipper.DisplayEnd * imagesInRow + imagesInRow; + end = (end > totalSz) ? totalSz : end; + for (size_t i = start; i < end; ++i) { - if (data.m_nSearchList.size() == i) - { - break; - } - std::string &text = std::get(data.m_nSearchList[i]).m_FileName; std::string &modelName = std::get(data.m_nSearchList[i]).m_ModelName; bool custom = std::get(data.m_nSearchList[i]).m_bCustom;