From 4fedd9102061ee311075d305af69fa991fe67b19 Mon Sep 17 00:00:00 2001 From: Learath Date: Mon, 8 Oct 2018 19:07:25 +0300 Subject: [PATCH] Arrow keys should account for visibility --- src/game/editor/editor.cpp | 26 ++++++++++++++++++++++++-- src/game/editor/editor.h | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 259fd6138..25836912d 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -4153,9 +4153,11 @@ void CEditor::RenderFileDialog() int ScrollNum = 0; for(int i = 0; i < m_FileList.size(); i++) { + m_FileList[i].m_IsVisible = false; if(!m_aFileDialogSearchText[0] || str_find_nocase(m_FileList[i].m_aName, m_aFileDialogSearchText)) { AddFileDialogEntry(i, &View); + m_FileList[i].m_IsVisible = true; ScrollNum++; } } @@ -4171,6 +4173,10 @@ void CEditor::RenderFileDialog() else ScrollNum = 0; + if(!m_FileList[m_FilesSelectedIndex].m_IsVisible) + { + m_FilesSelectedIndex = 0; + } if(m_FilesSelectedIndex > -1) { @@ -4179,8 +4185,24 @@ void CEditor::RenderFileDialog() int NewIndex = -1; if(Input()->GetEvent(i).m_Flags&IInput::FLAG_PRESS) { - if(Input()->GetEvent(i).m_Key == KEY_DOWN) NewIndex = m_FilesSelectedIndex + 1; - if(Input()->GetEvent(i).m_Key == KEY_UP) NewIndex = m_FilesSelectedIndex - 1; + if(Input()->GetEvent(i).m_Key == KEY_DOWN) + { + for(NewIndex = m_FilesSelectedIndex + 1; NewIndex < m_FileList.size(); NewIndex++) + { + if(m_FileList[NewIndex].m_IsVisible) + break; + } + dbg_msg("DEBUG", "NewIndex='%d'", NewIndex); + } + if(Input()->GetEvent(i).m_Key == KEY_UP) + { + for(NewIndex = m_FilesSelectedIndex - 1; NewIndex >= 0; NewIndex--) + { + if(m_FileList[NewIndex].m_IsVisible) + break; + } + dbg_msg("DEBUG", "NewIndex='%d'", NewIndex); + } } if(NewIndex > -1 && NewIndex < m_FileList.size()) { diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 768caa60f..d13758349 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -859,6 +859,7 @@ public: bool m_IsDir; bool m_IsLink; int m_StorageType; + bool m_IsVisible; bool operator<(const CFilelistItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false : m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false :