Skip to content

Commit

Permalink
Minor improvement of entities background map settings
Browse files Browse the repository at this point in the history
Reset the selected map when reloading the map list to fix the wrong selection being shown for one frame when navigating directories in the map selection popup.

Increase scrolling speed for consistency with other listboxes (scroll 3 entries instead of 1).
  • Loading branch information
Robyt3 committed Dec 14, 2024
1 parent 0e9b9a8 commit 60b2486
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3303,7 +3303,6 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
static SPopupMenuId s_PopupMapPickerId;
static CPopupMapPickerContext s_PopupMapPickerContext;
s_PopupMapPickerContext.m_pMenus = this;

s_PopupMapPickerContext.MapListPopulate();
Ui()->DoPopupMenu(&s_PopupMapPickerId, Ui()->MouseX(), Ui()->MouseY(), 300.0f, 250.0f, &s_PopupMapPickerContext, PopupMapPicker);
}
Expand Down Expand Up @@ -3406,7 +3405,7 @@ CUi::EPopupMenuFunctionResult CMenus::PopupMapPicker(void *pContext, CUIRect Vie

static CListBox s_ListBox;
s_ListBox.SetActive(Active);
s_ListBox.DoStart(20.0f, pPopupContext->m_vMaps.size(), 1, 1, -1, &View, false);
s_ListBox.DoStart(20.0f, pPopupContext->m_vMaps.size(), 1, 3, -1, &View, false);

int MapIndex = 0;
for(auto &Map : pPopupContext->m_vMaps)
Expand Down Expand Up @@ -3450,7 +3449,7 @@ CUi::EPopupMenuFunctionResult CMenus::PopupMapPicker(void *pContext, CUIRect Vie
pPopupContext->m_Selection = NewSelected >= 0 ? NewSelected : -1;
if(s_ListBox.WasItemSelected() || s_ListBox.WasItemActivated())
{
const CMapListItem SelectedItem = pPopupContext->m_vMaps[pPopupContext->m_Selection];
const CMapListItem &SelectedItem = pPopupContext->m_vMaps[pPopupContext->m_Selection];

if(SelectedItem.m_IsDirectory)
{
Expand Down Expand Up @@ -3483,6 +3482,7 @@ void CMenus::CPopupMapPickerContext::MapListPopulate()
str_format(aTemp, sizeof(aTemp), "maps/%s", m_aCurrentMapFolder);
m_pMenus->Storage()->ListDirectoryInfo(IStorage::TYPE_ALL, aTemp, MapListFetchCallback, this);
std::stable_sort(m_vMaps.begin(), m_vMaps.end(), CompareFilenameAscending);
m_Selection = -1;
}

int CMenus::CPopupMapPickerContext::MapListFetchCallback(const CFsFileInfo *pInfo, int IsDir, int StorageType, void *pUser)
Expand Down

0 comments on commit 60b2486

Please sign in to comment.