Fix current selection highlighting

This commit is contained in:
Tim Schumacher 2018-10-02 23:39:22 +02:00
parent 3d7ee89104
commit ab6f344daa
No known key found for this signature in database
GPG key ID: A3D69E3DA9A0FF34
3 changed files with 6 additions and 9 deletions

View file

@ -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);

View file

@ -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<std::string> m_SelectEntitiesFiles;
int m_SelectEntitiesImage;
std::string m_SelectEntitiesImage;
float m_WorldOffsetX;
float m_WorldOffsetY;

View file

@ -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);