mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #6750
6750: Select new demo file after renaming and slicing demo, scroll to selected demo when sorting, refreshing etc. r=def- a=Robyt3 ## Checklist - [X] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
e22e0c9777
|
@ -1530,6 +1530,9 @@ int CMenus::Render()
|
|||
}
|
||||
else if(Storage()->RenameFile(aBufOld, aBufNew, m_vDemos[m_DemolistSelectedIndex].m_StorageType))
|
||||
{
|
||||
str_copy(g_Config.m_UiDemoSelected, m_DemoRenameInput.GetString());
|
||||
if(str_endswith(g_Config.m_UiDemoSelected, ".demo"))
|
||||
g_Config.m_UiDemoSelected[str_length(g_Config.m_UiDemoSelected) - str_length(".demo")] = '\0';
|
||||
DemolistPopulate();
|
||||
DemolistOnUpdate(false);
|
||||
}
|
||||
|
|
|
@ -323,6 +323,7 @@ protected:
|
|||
CLineInputBuffered<IO_MAX_PATH_LENGTH> m_DemoRenderInput;
|
||||
int m_DemolistSelectedIndex;
|
||||
bool m_DemolistSelectedIsDir;
|
||||
bool m_DemolistSelectedReveal = false;
|
||||
int m_DemolistStorageType;
|
||||
int m_Speed = 4;
|
||||
|
||||
|
|
|
@ -708,6 +708,9 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
|
|||
{
|
||||
char aPath[IO_MAX_PATH_LENGTH];
|
||||
str_format(aPath, sizeof(aPath), "%s/%s", m_aCurrentDemoFolder, m_DemoSliceInput.GetString());
|
||||
str_copy(g_Config.m_UiDemoSelected, m_DemoSliceInput.GetString());
|
||||
if(str_endswith(g_Config.m_UiDemoSelected, ".demo"))
|
||||
g_Config.m_UiDemoSelected[str_length(g_Config.m_UiDemoSelected) - str_length(".demo")] = '\0';
|
||||
m_DemoPlayerState = DEMOPLAYER_NONE;
|
||||
Client()->DemoSlice(aPath, CMenus::DemoFilterChat, &s_RemoveChat);
|
||||
DemolistPopulate();
|
||||
|
@ -795,6 +798,7 @@ void CMenus::DemolistOnUpdate(bool Reset)
|
|||
m_DemolistSelectedIndex = Reset ? !m_vDemos.empty() ? 0 : -1 :
|
||||
m_DemolistSelectedIndex >= (int)m_vDemos.size() ? m_vDemos.size() - 1 : m_DemolistSelectedIndex;
|
||||
m_DemolistSelectedIsDir = m_DemolistSelectedIndex < 0 ? false : m_vDemos[m_DemolistSelectedIndex].m_IsDir;
|
||||
m_DemolistSelectedReveal = true;
|
||||
}
|
||||
|
||||
bool CMenus::FetchHeader(CDemoItem &Item)
|
||||
|
@ -1047,6 +1051,11 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
|||
}
|
||||
|
||||
static CListBox s_ListBox;
|
||||
if(m_DemolistSelectedReveal)
|
||||
{
|
||||
s_ListBox.ScrollToSelected();
|
||||
m_DemolistSelectedReveal = false;
|
||||
}
|
||||
s_ListBox.DoStart(ms_ListheaderHeight, m_vDemos.size(), 1, 3, m_DemolistSelectedIndex, &ListBox, false);
|
||||
|
||||
int ItemIndex = -1;
|
||||
|
|
Loading…
Reference in a new issue