diff options
author | Aleksoid <aleksoid@users.sourceforge.net> | 2008-08-08 10:48:17 +0400 |
---|---|---|
committer | Aleksoid <aleksoid@users.sourceforge.net> | 2008-08-08 10:48:17 +0400 |
commit | 2d9c28d8f7e6f2e13a2b2644922257ffde3367ba (patch) | |
tree | ccc1545b88be9547eca85ac29ccb1e7db631b9f8 /src/apps/mplayerc | |
parent | 84ec48dc986329966267e581f29a2f4f3d7b51f5 (diff) |
FIX : Problems with SHUFFLE function (bug #2030723)
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@721 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/apps/mplayerc')
-rw-r--r-- | src/apps/mplayerc/Playlist.cpp | 33 | ||||
-rw-r--r-- | src/apps/mplayerc/Playlist.h | 2 | ||||
-rw-r--r-- | src/apps/mplayerc/mplayerc.ru.rc | bin | 288874 -> 288892 bytes |
3 files changed, 27 insertions, 8 deletions
diff --git a/src/apps/mplayerc/Playlist.cpp b/src/apps/mplayerc/Playlist.cpp index dea354112..e8cd66220 100644 --- a/src/apps/mplayerc/Playlist.cpp +++ b/src/apps/mplayerc/Playlist.cpp @@ -250,17 +250,34 @@ void CPlaylist::SetPos(POSITION pos) m_pos = pos;
}
-CPlaylistItem& CPlaylist::GetNextWrap(POSITION& pos)
+#define Rand(a, b) rand()%(b-a+1)+a
+
+POSITION CPlaylist::Shuffle()
{
- GetNext(pos);
+ CAtlArray<plsort2_t> a;
+ a.SetCount(GetCount());
+ srand((unsigned)time(NULL));
+ POSITION pos = GetHeadPosition();
+ for(int i = 0; pos; i++, GetNext(pos))
+ a[i].pos = pos;
+
+ pos = GetPos();
+ int rnd = Rand(0, a.GetCount()-1);
+ while(pos == a[rnd].pos) rnd = Rand(0, a.GetCount()-1);
- if(!pos)
- {
- // FIXME: add param: , bool fShuffle
- if(GetCount() > 2 && AfxGetApp()->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("ShufflePlaylistItems"), FALSE))
- Randomize();
+ return a[rnd].pos;
+}
- pos = GetHeadPosition();
+CPlaylistItem& CPlaylist::GetNextWrap(POSITION& pos)
+{
+ if(AfxGetApp()->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("ShufflePlaylistItems"), FALSE) && GetCount() > 2)
+ {
+ pos = Shuffle();
+ }
+ else
+ {
+ GetNext(pos);
+ if(!pos) pos = GetHeadPosition();
}
return(GetAt(pos));
diff --git a/src/apps/mplayerc/Playlist.h b/src/apps/mplayerc/Playlist.h index dde17a459..901a264e1 100644 --- a/src/apps/mplayerc/Playlist.h +++ b/src/apps/mplayerc/Playlist.h @@ -73,4 +73,6 @@ public: void SetPos(POSITION pos);
CPlaylistItem& GetNextWrap(POSITION& pos);
CPlaylistItem& GetPrevWrap(POSITION& pos);
+
+ POSITION Shuffle();
};
diff --git a/src/apps/mplayerc/mplayerc.ru.rc b/src/apps/mplayerc/mplayerc.ru.rc Binary files differindex 13d4889af..3d68c261a 100644 --- a/src/apps/mplayerc/mplayerc.ru.rc +++ b/src/apps/mplayerc/mplayerc.ru.rc |