diff options
| -rw-r--r-- | src/game/editor/ed_editor.cpp | 43 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.h | 4 | ||||
| -rw-r--r-- | src/game/editor/ed_popups.cpp | 32 |
3 files changed, 15 insertions, 64 deletions
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 0913370e..b2b3e1ca 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -1,7 +1,5 @@ // copyright (c) 2007 magnus auvinen, see licence.txt for more info -#include <stdlib.h> - #include <base/system.h> #include <base/tl/sorted_array.h> #include <base/tl/string.h> @@ -1811,37 +1809,9 @@ int CEditor::PopupImage(CEditor *pEditor, CUIRect View) return 0; } -static int CompareImageName(const void *Object1, const void *Object2) -{ - CEditorImage *Image1 = *(CEditorImage**)Object1; - CEditorImage *Image2 = *(CEditorImage**)Object2; - return str_comp(Image1->m_aName, Image2->m_aName); -} - -void CEditor::SortImages() -{ - //array<CEditorImage*> lImages = array<CEditorImage*>(m_Map.m_lImages); - //int aIndexes[lImages.size()]; - - if( m_Map.m_lSortedImages.size() != m_Map.m_lImages.size() ) - m_Map.m_lSortedImages = array<CEditorImage*>(m_Map.m_lImages); - - bool Sorted = true; - for(int i = 1; i < m_Map.m_lSortedImages.size(); i++) - if( str_comp(m_Map.m_lSortedImages[i]->m_aName, m_Map.m_lSortedImages[i-1]->m_aName) < 0 ) - { - Sorted = false; - break; - } - - if(!Sorted) - qsort(m_Map.m_lSortedImages.base_ptr(), m_Map.m_lSortedImages.size(), sizeof(CEditorImage*), CompareImageName); -} void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) { - SortImages(); - for(int e = 0; e < 2; e++) // two passes, first embedded, then external { CUIRect Slot; @@ -1851,19 +1821,19 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) else UI()->DoLabel(&Slot, "External", 12.0f, 0); - for(int i = 0; i < m_Map.m_lSortedImages.size(); i++) + for(int i = 0; i < m_Map.m_lImages.size(); i++) { - if((e && !m_Map.m_lSortedImages[i]->m_External) || - (!e && m_Map.m_lSortedImages[i]->m_External)) + if((e && !m_Map.m_lImages[i]->m_External) || + (!e && m_Map.m_lImages[i]->m_External)) { continue; } char aBuf[128]; - str_copy(aBuf, m_Map.m_lSortedImages[i]->m_aName, sizeof(aBuf)); + str_copy(aBuf, m_Map.m_lImages[i]->m_aName, sizeof(aBuf)); ToolBox.HSplitTop(12.0f, &Slot, &ToolBox); - if(int Result = DoButton_Editor(&m_Map.m_lSortedImages[i], aBuf, m_SelectedImage == i, &Slot, + if(int Result = DoButton_Editor(&m_Map.m_lImages[i], aBuf, m_SelectedImage == i, &Slot, BUTTON_CONTEXT, "Select image")) { m_SelectedImage = i; @@ -1884,7 +1854,7 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) r.w = r.h; else r.h = r.w; - Graphics()->TextureSet(m_Map.m_lSortedImages[i]->m_TexId); + Graphics()->TextureSet(m_Map.m_lImages[i]->m_TexId); Graphics()->BlendNormal(); Graphics()->QuadsBegin(); IGraphics::CQuadItem QuadItem(r.x, r.y, r.w, r.h); @@ -2738,7 +2708,6 @@ void CEditorMap::Clean() m_lGroups.delete_all(); m_lEnvelopes.delete_all(); m_lImages.delete_all(); - m_lSortedImages.clear(); m_pGameLayer = 0x0; m_pGameGroup = 0x0; diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index 863c36e4..d027c162 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -261,7 +261,6 @@ public: array<CLayerGroup*> m_lGroups; array<CEditorImage*> m_lImages; - array<CEditorImage*> m_lSortedImages; array<CEnvelope*> m_lEnvelopes; class CLayerGame *m_pGameLayer; @@ -598,8 +597,7 @@ public: static void ReplaceImage(const char *pFilename, void *pUser); static void AddImage(const char *pFilename, void *pUser); - void SortImages(); - + void RenderImages(CUIRect Toolbox, CUIRect Toolbar, CUIRect View); void RenderLayers(CUIRect Toolbox, CUIRect Toolbar, CUIRect View); void RenderModebar(CUIRect View); diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp index f59ad74c..2e58ae3a 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_lSortedImages.size(); i++) + for(int i = -1; i < pEditor->m_Map.m_lImages.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_lSortedImages[i], "None", i==g_SelectImageCurrent, &Button)) + if(pEditor->DoButton_MenuItem(&pEditor->m_Map.m_lImages[i], "None", i==g_SelectImageCurrent, &Button)) g_SelectImageSelected = -1; } else { - if(pEditor->DoButton_MenuItem(&pEditor->m_Map.m_lSortedImages[i], pEditor->m_Map.m_lSortedImages[i]->m_aName, i==g_SelectImageCurrent, &Button)) + if(pEditor->DoButton_MenuItem(&pEditor->m_Map.m_lImages[i], pEditor->m_Map.m_lImages[i]->m_aName, i==g_SelectImageCurrent, &Button)) g_SelectImageSelected = i; } } - if(ShowImage >= 0 && ShowImage < pEditor->m_Map.m_lSortedImages.size()) - pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lSortedImages[ShowImage]->m_TexId); + if(ShowImage >= 0 && ShowImage < pEditor->m_Map.m_lImages.size()) + pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lImages[ShowImage]->m_TexId); else pEditor->Graphics()->TextureSet(-1); pEditor->Graphics()->QuadsBegin(); @@ -413,16 +413,6 @@ 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; @@ -433,16 +423,10 @@ int CEditor::PopupSelectImageResult() { if(g_SelectImageSelected == -100) return -100; + g_SelectImageCurrent = g_SelectImageSelected; g_SelectImageSelected = -100; - - // 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; + return g_SelectImageCurrent; } |