diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 0128789e2..49e0a079e 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1159,11 +1159,6 @@ void CEditor::DoToolbar(CUIRect ToolBar) Storage()->ListDirectory(IStorage::TYPE_ALL, "editor/entities", EntitiesListdirCallback, this); std::sort(m_SelectEntitiesFiles.begin(), m_SelectEntitiesFiles.end()); - for(int i = 0; i < (int)m_SelectEntitiesFiles.size(); i++) { - if (m_SelectEntitiesFiles[i] == "DDNet") - m_SelectEntitiesImage = i; - } - static int s_EntitiesPopupID = 0; UiInvokePopupMenu(&s_EntitiesPopupID, 0, Button.x, Button.y+18.0f, 250, m_SelectEntitiesFiles.size()*14 + 10, PopupEntities); diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 6d76dc7b4..4b8260526 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -668,6 +668,8 @@ public: m_FilesCur = 0; m_FilesStopAt = 999; + m_SelectEntitiesImage = "DDNet"; + m_WorldOffsetX = 0; m_WorldOffsetY = 0; m_EditorOffsetX = 0.0f; @@ -859,7 +861,7 @@ public: int m_FilesStopAt; std::vector m_SelectEntitiesFiles; - int m_SelectEntitiesImage; + std::string m_SelectEntitiesImage; float m_WorldOffsetX; float m_WorldOffsetY; diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 7e6c11c41..36d67f415 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -1664,9 +1664,9 @@ int CEditor::PopupEntities(CEditor *pEditor, CUIRect View) const char *Name = pEditor->m_SelectEntitiesFiles[i].c_str(); - if(pEditor->DoButton_MenuItem(Name, Name, i==pEditor->m_SelectEntitiesImage, &Button)) { - if (i != pEditor->m_SelectEntitiesImage) { - pEditor->m_SelectEntitiesImage = i; + if(pEditor->DoButton_MenuItem(Name, Name, pEditor->m_SelectEntitiesFiles[i] == pEditor->m_SelectEntitiesImage, &Button)) { + if (pEditor->m_SelectEntitiesFiles[i] != pEditor->m_SelectEntitiesImage) { + pEditor->m_SelectEntitiesImage = pEditor->m_SelectEntitiesFiles[i]; char aBuf[512]; str_format(aBuf, sizeof(aBuf), "editor/entities/%s.png", Name);