* Enable shuffle mode. */
| 205 | * Enable shuffle mode. |
| 206 | */ |
| 207 | void MusicSystem::Shuffle() |
| 208 | { |
| 209 | _settings_client.music.shuffle = true; |
| 210 | |
| 211 | uint set_index = this->GetSetIndex(); |
| 212 | this->active_playlist = this->standard_playlists[this->selected_playlist]; |
| 213 | for (size_t i = 0; i < this->active_playlist.size(); i++) { |
| 214 | size_t shuffle_index = InteractiveRandom() % (this->active_playlist.size() - i); |
| 215 | std::swap(this->active_playlist[i], this->active_playlist[i + shuffle_index]); |
| 216 | } |
| 217 | this->SetPositionBySetIndex(set_index); |
| 218 | |
| 219 | InvalidateWindowData(WC_MUSIC_TRACK_SELECTION, 0); |
| 220 | InvalidateWindowData(WC_MUSIC_WINDOW, 0); |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Disable shuffle mode. |
no test coverage detected