summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcommon/array.cpp9
-rwxr-xr-xcommon/array.h1
-rw-r--r--win/Piecebar.cpp19
3 files changed, 17 insertions, 12 deletions
diff --git a/common/array.cpp b/common/array.cpp
index 8d1b663..a91a47f 100755
--- a/common/array.cpp
+++ b/common/array.cpp
@@ -159,6 +159,15 @@ PtrArray<T>& PtrArray<T>::operator=(const PtrArray<T>& Array)
memcpy(m_pData, Array.m_pData, (m_nAlloc) * sizeof(T*));
}
+template <class T>
+PtrArray<T>& PtrArray<T>::operator+=(const PtrArray<T>& Array)
+{
+ Expand(Array.m_nLength);
+ memcpy(m_pData + m_nLength, Array.m_pData, Array.m_nLength * sizeof(T*));
+ m_nLength += Array.m_nLength;
+ return *this;
+}
+
// ============================================================================
template <class T>
diff --git a/common/array.h b/common/array.h
index 581d660..2cb4764 100755
--- a/common/array.h
+++ b/common/array.h
@@ -23,6 +23,7 @@ public:
void Sort(LC_PTRARRAY_COMPARE_FUNC SortFunc, void* SortData);
PtrArray<T>& operator=(const PtrArray<T>& Array);
+ PtrArray<T>& operator+=(const PtrArray<T>& Array);
T* operator [](int nIndex) const
{ return m_pData[nIndex]; }
diff --git a/win/Piecebar.cpp b/win/Piecebar.cpp
index 1975b2f..0a0c0f1 100644
--- a/win/Piecebar.cpp
+++ b/win/Piecebar.cpp
@@ -1051,7 +1051,10 @@ BOOL CPiecesBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
Lib->GetCategoryEntries(CategoryIndex, true, SinglePieces, GroupedPieces);
+ // Merge and sort the arrays.
+ SinglePieces += GroupedPieces;
SinglePieces.Sort(PiecesSortFunc, NULL);
+
for (i = 0; i < SinglePieces.GetSize(); i++)
{
PieceInfo* Info = SinglePieces[i];
@@ -1059,18 +1062,10 @@ BOOL CPiecesBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
if (!m_bSubParts && Info->IsSubPiece())
continue;
- m_PiecesTree.InsertItem(TVIF_PARAM|TVIF_TEXT, Info->m_strDescription, 0, 0, 0, 0, (LPARAM)Info, CategoryItem, TVI_LAST);
- }
-
- GroupedPieces.Sort(PiecesSortFunc, NULL);
- for (i = 0; i < GroupedPieces.GetSize(); i++)
- {
- PieceInfo* Info = GroupedPieces[i];
-
- if (!m_bSubParts && Info->IsSubPiece())
- continue;
-
- m_PiecesTree.InsertItem(TVIF_CHILDREN|TVIF_PARAM|TVIF_TEXT, Info->m_strDescription, 0, 0, 0, 0, (LPARAM)Info, CategoryItem, TVI_LAST);
+ if (GroupedPieces.FindIndex(Info) == -1)
+ m_PiecesTree.InsertItem(TVIF_PARAM|TVIF_TEXT, Info->m_strDescription, 0, 0, 0, 0, (LPARAM)Info, CategoryItem, TVI_LAST);
+ else
+ m_PiecesTree.InsertItem(TVIF_CHILDREN|TVIF_PARAM|TVIF_TEXT, Info->m_strDescription, 0, 0, 0, 0, (LPARAM)Info, CategoryItem, TVI_LAST);
}
}