Added support for cyclePlaylist key control.

This commit is contained in:
Pieter Hulshoff 2019-10-06 14:40:37 +02:00
parent 28a77d8c2f
commit e6f9192bb8
8 changed files with 65 additions and 1 deletions

View File

@ -60,6 +60,7 @@ bool UserInput::initialize()
MapKey("favPlaylist", KeyCodeFavPlaylist, false);
MapKey("nextPlaylist", KeyCodeNextPlaylist, false);
MapKey("prevPlaylist", KeyCodePrevPlaylist, false);
MapKey("cyclePlaylist", KeyCodeCyclePlaylist, false);
MapKey("addPlaylist", KeyCodeAddPlaylist, false);
MapKey("removePlaylist", KeyCodeRemovePlaylist, false);
MapKey("random", KeyCodeRandom, false);

View File

@ -44,6 +44,7 @@ public:
KeyCodeFavPlaylist,
KeyCodeNextPlaylist,
KeyCodePrevPlaylist,
KeyCodeCyclePlaylist,
KeyCodeRandom,
KeyCodeMenu,
KeyCodeAddPlaylist,

View File

@ -1071,6 +1071,43 @@ void Page::selectPlaylist(std::string playlist)
}
void Page::cyclePlaylist(std::vector<std::string> list)
{
// Empty list
if (list.size() == 0)
return;
// Find the current playlist in the list
std::vector<std::string>::iterator it = list.begin();
while (*it != getPlaylistName() && it != list.end())
++it;
// If current playlist not found, switch to the first found cycle playlist in the playlist list
if (it == list.end())
{
for (std::vector<std::string>::iterator it2 = list.begin(); it2 != list.end(); ++it2)
{
selectPlaylist( *it2 );
if (*it2 == getPlaylistName())
break;
}
}
// Current playlist found; switch to the next found playlist in the list
else
{
for(;; ++it)
{
if (it == list.end()) it = list.begin(); // wrap
selectPlaylist( *it );
if (*it == getPlaylistName())
break;
}
}
}
void Page::update(float dt)
{
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)

View File

@ -57,6 +57,7 @@ public:
void nextPlaylist();
void prevPlaylist();
void selectPlaylist(std::string playlist);
void cyclePlaylist(std::vector<std::string> list);
void pushMenu(ScrollingList *s, int index = -1);
bool isMenusFull();
void setLoadSound(Sound *chunk);

View File

@ -1067,6 +1067,16 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page )
page->prevPlaylist( );
state = RETROFE_PLAYLIST_REQUEST;
}
if ( input_.keystate(UserInput::KeyCodeCyclePlaylist) )
{
attract_.reset( );
std::string cycleString;
config_.getProperty( "cyclePlaylist", cycleString );
std::vector<std::string> cycleVector;
Utils::listToVector( cycleString, cycleVector, ',' );
page->cyclePlaylist( cycleVector );
state = RETROFE_PLAYLIST_REQUEST;
}
if ( input_.newKeyPressed(UserInput::KeyCodeRemovePlaylist) )
{
attract_.reset( );

View File

@ -253,3 +253,16 @@ std::string Utils::trimEnds(std::string str)
return str;
}
void Utils::listToVector( std::string str, std::vector<std::string> &vec, char delimiter = ',' )
{
std::size_t current, previous = 0;
current = str.find( delimiter );
while (current != std::string::npos)
{
vec.push_back( Utils::trimEnds( str.substr( previous, current - previous ) ) );
previous = current + 1;
current = str.find( delimiter, previous );
}
vec.push_back( Utils::trimEnds( str.substr( previous, current - previous ) ) );
}

View File

@ -35,6 +35,7 @@ public:
static std::string uppercaseFirst(std::string str);
static std::string filterComments(std::string line);
static std::string trimEnds(std::string str);
static void listToVector( std::string str, std::vector<std::string> &vec, char delimiter );
//todo: there has to be a better way to do this
static std::string combinePath(std::list<std::string> &paths);

View File

@ -21,7 +21,7 @@
std::string retrofe_version_major = "0";
std::string retrofe_version_minor = "9";
std::string retrofe_version_build = "2";
std::string retrofe_version_build = "3";
std::string Version::getString( )