diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index 070d80b3..d93ef834 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -10,6 +10,7 @@ #include "pieceinf.h" #include "lc_glextensions.h" #include "lc_category.h" +#include "lc_traintrack.h" Q_DECLARE_METATYPE(QList) @@ -241,7 +242,14 @@ void lcPartSelectionListModel::SetCustomParts(const std::vector& 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; diff --git a/common/lc_partselectionwidget.h b/common/lc_partselectionwidget.h index 0e905fa7..de6fa60d 100644 --- a/common/lc_partselectionwidget.h +++ b/common/lc_partselectionwidget.h @@ -57,6 +57,7 @@ protected: struct lcPartSelectionListModelEntry { PieceInfo* Info = nullptr; + int ColorIndex = -1; QPixmap Pixmap; lcPartThumbnailId ThumbnailId = lcPartThumbnailId::Invalid; };