From 80e556ca8a6b4cbed58281c7f454c114e2d6e8e1 Mon Sep 17 00:00:00 2001 From: nimetu Date: Mon, 14 Mar 2022 13:49:15 +0200 Subject: [PATCH] Limit media playlist using list maxelements property --- nel/include/nel/gui/group_list.h | 2 ++ ryzom/client/src/interface_v3/music_player.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/nel/include/nel/gui/group_list.h b/nel/include/nel/gui/group_list.h index e7fda6eb3..02e3847f7 100644 --- a/nel/include/nel/gui/group_list.h +++ b/nel/include/nel/gui/group_list.h @@ -99,6 +99,8 @@ namespace NLGUI // Get the number of active children uint getNumActiveChildren() const; + uint getMaxElements() const { return _MaxElements; } + /** * set the template that will be used to add text; * \templ : a CViewText object. Only its font size, color and shadow are required. diff --git a/ryzom/client/src/interface_v3/music_player.cpp b/ryzom/client/src/interface_v3/music_player.cpp index e406b83a8..ab79c96c1 100644 --- a/ryzom/client/src/interface_v3/music_player.cpp +++ b/ryzom/client/src/interface_v3/music_player.cpp @@ -158,8 +158,21 @@ bool CMusicPlayer::isShuffleEnabled() const // *************************************************************************** void CMusicPlayer::playSongs (const std::vector &filenames) { + CGroupList *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(MP3_PLAYER_PLAYLIST_LIST)); + if (!pList) + { + nlwarning("MusicPlayer UI not found (%s)", MP3_PLAYER_PLAYLIST_LIST); + return; + } + + uint limit = pList->getMaxElements(); + if (filenames.size() > limit) + { + CInterfaceManager::getInstance()->displaySystemInfo(toString("Found %u, limit %u", filenames.size(), limit), "SYS"); + } + _Songs.clear(); - for (uint i=0; i