diff options
| author | xalduin <xalduin@gmail.com> | 2010-06-01 23:04:56 -0400 |
|---|---|---|
| committer | xalduin <xalduin@gmail.com> | 2010-06-01 23:04:56 -0400 |
| commit | b066bb07e13701d53008d80880d116c56c12bcf2 (patch) | |
| tree | 15495dbf49716f7638f388dcb0dae02ef9b61aa0 /src/game/editor/ed_popups.cpp | |
| parent | 4d35f63174a8304ad2b4c1178f1fe10e3f84ae14 (diff) | |
| download | zcatch-b066bb07e13701d53008d80880d116c56c12bcf2.tar.gz zcatch-b066bb07e13701d53008d80880d116c56c12bcf2.zip | |
Sorting images somewhat working, save is bugged
Diffstat (limited to 'src/game/editor/ed_popups.cpp')
| -rw-r--r-- | src/game/editor/ed_popups.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp index 2e58ae3a..f59ad74c 100644 --- a/src/game/editor/ed_popups.cpp +++ b/src/game/editor/ed_popups.cpp @@ -375,10 +375,10 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View) CUIRect ButtonBar, ImageView; View.VSplitLeft(80.0f, &ButtonBar, &View); View.Margin(10.0f, &ImageView); - + int ShowImage = g_SelectImageCurrent; - for(int i = -1; i < pEditor->m_Map.m_lImages.size(); i++) + for(int i = -1; i < pEditor->m_Map.m_lSortedImages.size(); i++) { CUIRect Button; ButtonBar.HSplitTop(12.0f, &Button, &ButtonBar); @@ -389,18 +389,18 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View) if(i == -1) { - if(pEditor->DoButton_MenuItem(&pEditor->m_Map.m_lImages[i], "None", i==g_SelectImageCurrent, &Button)) + if(pEditor->DoButton_MenuItem(&pEditor->m_Map.m_lSortedImages[i], "None", i==g_SelectImageCurrent, &Button)) g_SelectImageSelected = -1; } else { - if(pEditor->DoButton_MenuItem(&pEditor->m_Map.m_lImages[i], pEditor->m_Map.m_lImages[i]->m_aName, i==g_SelectImageCurrent, &Button)) + if(pEditor->DoButton_MenuItem(&pEditor->m_Map.m_lSortedImages[i], pEditor->m_Map.m_lSortedImages[i]->m_aName, i==g_SelectImageCurrent, &Button)) g_SelectImageSelected = i; } } - if(ShowImage >= 0 && ShowImage < pEditor->m_Map.m_lImages.size()) - pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lImages[ShowImage]->m_TexId); + if(ShowImage >= 0 && ShowImage < pEditor->m_Map.m_lSortedImages.size()) + pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lSortedImages[ShowImage]->m_TexId); else pEditor->Graphics()->TextureSet(-1); pEditor->Graphics()->QuadsBegin(); @@ -413,6 +413,16 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View) void CEditor::PopupSelectImageInvoke(int Current, float x, float y) { + SortImages(); + + // Current = index of non sorted image, we want image of sorted image + for(int i = 0; i < m_Map.m_lSortedImages.size(); i++) + if( m_Map.m_lImages[Current] == m_Map.m_lSortedImages[i] ) + { + Current = i; + break; + } + static int s_SelectImagePopupId = 0; g_SelectImageSelected = -100; g_SelectImageCurrent = Current; @@ -423,10 +433,16 @@ int CEditor::PopupSelectImageResult() { if(g_SelectImageSelected == -100) return -100; - g_SelectImageCurrent = g_SelectImageSelected; g_SelectImageSelected = -100; - return g_SelectImageCurrent; + + // The user selected the sorted image, but we must return the index of the non sorted image + for(int i = 0; i < m_Map.m_lImages.size(); i++) + if(m_Map.m_lImages[i] == m_Map.m_lSortedImages[g_SelectImageCurrent]) + return i; + + // Shouldn't ever reach here + return -100; } |