Use the train track colors in the popup part picker.

This commit is contained in:
Leonardo Zide
2025-04-19 12:58:58 -07:00
parent 2dbc7bc1ca
commit e07c069bb1
2 changed files with 13 additions and 2 deletions
+12 -2
View File
@@ -10,6 +10,7 @@
#include "pieceinf.h"
#include "lc_glextensions.h"
#include "lc_category.h"
#include "lc_traintrack.h"
Q_DECLARE_METATYPE(QList<int>)
@@ -241,7 +242,14 @@ void lcPartSelectionListModel::SetCustomParts(const std::vector<PieceInfo*>& Par
mParts.clear();
for (PieceInfo* Part : Parts)
mParts.emplace_back().Info = Part;
{
lcPartSelectionListModelEntry& Entry = mParts.emplace_back();
Entry.Info = Part;
if (lcTrainTrackInfo* TrainTrackInfo = Part->GetTrainTrackInfo())
Entry.ColorIndex = lcGetColorIndex(TrainTrackInfo->GetColorCode());
}
auto lcPartSortFunc = [](const lcPartSelectionListModelEntry& a, const lcPartSelectionListModelEntry& b)
{
@@ -416,7 +424,9 @@ void lcPartSelectionListModel::RequestThumbnail(int PartIndex)
return;
PieceInfo* Info = mParts[PartIndex].Info;
auto [ThumbnailId, Thumbnail] = lcGetPiecesLibrary()->GetThumbnailManager()->RequestThumbnail(Info, mColorIndex, mIconSize);
int ColorIndex = mParts[PartIndex].ColorIndex == -1 ? mColorIndex : mParts[PartIndex].ColorIndex;
auto [ThumbnailId, Thumbnail] = lcGetPiecesLibrary()->GetThumbnailManager()->RequestThumbnail(Info, ColorIndex, mIconSize);
mParts[PartIndex].ThumbnailId = ThumbnailId;
+1
View File
@@ -57,6 +57,7 @@ protected:
struct lcPartSelectionListModelEntry
{
PieceInfo* Info = nullptr;
int ColorIndex = -1;
QPixmap Pixmap;
lcPartThumbnailId ThumbnailId = lcPartThumbnailId::Invalid;
};