| 
    OpenTTD Source 20251104-master-g3befbdd52f
    
   | 
 
Data Structures | |
| struct | PlaylistEntry | 
Public Types | |
| enum | PlaylistChoices : uint8_t {  PLCH_ALLMUSIC , PLCH_OLDSTYLE , PLCH_NEWSTYLE , PLCH_EZYSTREET , PLCH_CUSTOM1 , PLCH_CUSTOM2 , PLCH_THEMEONLY , PLCH_MAX }  | 
| typedef std::vector< PlaylistEntry > | Playlist | 
Public Member Functions | |
| void | BuildPlaylists () | 
| Rebuild all playlists for the current music set.   | |
| void | ChangePlaylist (PlaylistChoices pl) | 
| Switch to another playlist, or reload the current one.   | |
| void | ChangeMusicSet (const std::string &set_name) | 
| Change to named music set, and reset playback.   | |
| void | Shuffle () | 
| Enable shuffle mode.   | |
| void | Unshuffle () | 
| Disable shuffle mode.   | |
| void | Play () | 
| Start/restart playback at current song.   | |
| void | Stop () | 
| Stop playback and set flag that we don't intend to play music.   | |
| void | Next () | 
| Skip to next track.   | |
| void | Prev () | 
| Skip to previous track.   | |
| void | CheckStatus () | 
| Check that music is playing if it should, and that appropriate playlist is active for game/main menu.   | |
| bool | IsPlaying () const | 
| Is the player getting music right now?   | |
| bool | IsShuffle () const | 
| Is shuffle mode enabled?   | |
| PlaylistEntry | GetCurrentSong () const | 
| Return the current song, or a dummy if none.   | |
| bool | IsCustomPlaylist () const | 
| Is one of the custom playlists selected?   | |
| void | PlaylistAdd (size_t song_index) | 
| Append a song to a custom playlist.   | |
| void | PlaylistRemove (size_t song_index) | 
| Remove a song from a custom playlist.   | |
| void | PlaylistClear () | 
| Remove all songs from the current custom playlist.   | |
Data Fields | |
| Playlist | active_playlist {} | 
| current play order of songs, including any shuffle   | |
| Playlist | music_set {} | 
| all songs in current music set, in set order   | |
| PlaylistChoices | selected_playlist {} | 
Private Member Functions | |
| uint | GetSetIndex () | 
| Get set index from current playlist position.   | |
| void | SetPositionBySetIndex (uint set_index) | 
| Set playlist position by set index.   | |
| void | ChangePlaylistPosition (int ofs) | 
| Change playlist position pointer by the given offset, making sure to keep it within valid range.   | |
| void | SaveCustomPlaylist (PlaylistChoices pl) | 
| Save a custom playlist to settings after modification.   | |
Private Attributes | |
| int | playlist_position = 0 | 
| std::array< Playlist, PLCH_MAX > | standard_playlists {} | 
Definition at line 40 of file music_gui.cpp.
| typedef std::vector<PlaylistEntry> MusicSystem::Playlist | 
Definition at line 48 of file music_gui.cpp.
| enum MusicSystem::PlaylistChoices : uint8_t | 
Definition at line 50 of file music_gui.cpp.
| void MusicSystem::BuildPlaylists | ( | ) | 
Rebuild all playlists for the current music set.
Definition at line 103 of file music_gui.cpp.
References _settings_client, MusicSettings::custom_1, MusicSettings::custom_2, BaseMedia< MusicSet >::GetUsedSet(), ClientSettings::music, music_set, NUM_SONGS_AVAILABLE, NUM_SONGS_CLASS, and NUM_SONGS_PLAYLIST.
Referenced by ChangeMusicSet(), and InitializeMusic().
| void MusicSystem::ChangeMusicSet | ( | const std::string & | set_name | ) | 
Change to named music set, and reset playback.
| set_name | Name of music set to select | 
Definition at line 170 of file music_gui.cpp.
References BuildPlaylists(), ChangePlaylist(), BaseMusic::ini_set, InvalidateWindowData(), BaseMedia< MusicSet >::SetSetByName(), WC_GAME_OPTIONS, WC_MUSIC_TRACK_SELECTION, WC_MUSIC_WINDOW, and WN_GAME_OPTIONS_GAME_OPTIONS.
Referenced by ChangeMusicSet().
| void MusicSystem::ChangePlaylist | ( | PlaylistChoices | pl | ) | 
Switch to another playlist, or reload the current one.
| pl | Playlist to select | 
Definition at line 147 of file music_gui.cpp.
References _settings_client, active_playlist, InvalidateWindowData(), ClientSettings::music, Play(), MusicSettings::playing, MusicSettings::playlist, Shuffle(), MusicSettings::shuffle, WC_MUSIC_TRACK_SELECTION, and WC_MUSIC_WINDOW.
Referenced by ChangeMusicSet(), CheckStatus(), MusicTrackSelectionWindow::OnClick(), MusicWindow::OnClick(), and PlaylistClear().
      
  | 
  private | 
Change playlist position pointer by the given offset, making sure to keep it within valid range.
If the playlist is empty, position is always set to 0.
| ofs | Amount to move playlist position by. | 
Definition at line 413 of file music_gui.cpp.
References active_playlist.
| void MusicSystem::CheckStatus | ( | ) | 
Check that music is playing if it should, and that appropriate playlist is active for game/main menu.
Definition at line 285 of file music_gui.cpp.
References _settings_client, active_playlist, ChangePlaylist(), MusicDriver::GetInstance(), IsPlaying(), ClientSettings::music, Next(), and MusicSettings::playlist.
Referenced by MusicLoop().
| MusicSystem::PlaylistEntry MusicSystem::GetCurrentSong | ( | ) | const | 
Return the current song, or a dummy if none.
Definition at line 309 of file music_gui.cpp.
References active_playlist, BaseMedia< MusicSet >::GetUsedSet(), and IsPlaying().
Referenced by MusicWindow::DrawWidget().
      
  | 
  private | 
Get set index from current playlist position.
Definition at line 197 of file music_gui.cpp.
References active_playlist.
Referenced by Shuffle(), and Unshuffle().
| bool MusicSystem::IsCustomPlaylist | ( | ) | const | 
Is one of the custom playlists selected?
Definition at line 316 of file music_gui.cpp.
Referenced by PlaylistAdd(), PlaylistClear(), and PlaylistRemove().
| bool MusicSystem::IsPlaying | ( | ) | const | 
Is the player getting music right now?
Definition at line 297 of file music_gui.cpp.
References _settings_client, active_playlist, ClientSettings::music, and MusicSettings::playing.
Referenced by CheckStatus(), MusicWindow::DrawWidget(), GetCurrentSong(), PlaylistAdd(), and PlaylistRemove().
| bool MusicSystem::IsShuffle | ( | ) | const | 
Is shuffle mode enabled?
Definition at line 303 of file music_gui.cpp.
References _settings_client, ClientSettings::music, and MusicSettings::shuffle.
Referenced by MusicWindow::OnClick(), PlaylistAdd(), and PlaylistRemove().
| void MusicSystem::Next | ( | ) | 
Skip to next track.
Definition at line 267 of file music_gui.cpp.
References _settings_client, ChangePlaylistPosition(), InvalidateWindowData(), ClientSettings::music, Play(), MusicSettings::playing, and WC_MUSIC_WINDOW.
Referenced by CheckStatus(), and MusicWindow::OnClick().
| void MusicSystem::Play | ( | ) | 
Start/restart playback at current song.
Definition at line 239 of file music_gui.cpp.
References _settings_client, active_playlist, ChangePlaylistPosition(), MusicDriver::GetInstance(), InvalidateWindowData(), MusicSongInfo::loop, ClientSettings::music, MusicSettings::playing, MusicDriver::PlaySong(), MusicDriver::StopSong(), and WC_MUSIC_WINDOW.
Referenced by ChangePlaylist(), Next(), MusicWindow::OnClick(), PlaylistAdd(), PlaylistRemove(), and Prev().
| void MusicSystem::PlaylistAdd | ( | size_t | song_index | ) | 
Append a song to a custom playlist.
Always adds to the currently active playlist.
| song_index | Index of song in the current music set to add | 
Definition at line 326 of file music_gui.cpp.
References active_playlist, InvalidateWindowData(), IsCustomPlaylist(), IsPlaying(), IsShuffle(), music_set, NUM_SONGS_PLAYLIST, Play(), SaveCustomPlaylist(), and WC_MUSIC_TRACK_SELECTION.
Referenced by MusicTrackSelectionWindow::OnClick().
| void MusicSystem::PlaylistClear | ( | ) | 
Remove all songs from the current custom playlist.
Effectively stops playback too.
Definition at line 398 of file music_gui.cpp.
References ChangePlaylist(), IsCustomPlaylist(), and SaveCustomPlaylist().
Referenced by MusicTrackSelectionWindow::OnClick().
| void MusicSystem::PlaylistRemove | ( | size_t | song_index | ) | 
Remove a song from a custom playlist.
| song_index | Index in the custom playlist to remove. | 
Definition at line 364 of file music_gui.cpp.
References active_playlist, MusicSongInfo::cat_index, MusicSongInfo::filename, InvalidateWindowData(), IsCustomPlaylist(), IsPlaying(), IsShuffle(), Play(), SaveCustomPlaylist(), and WC_MUSIC_TRACK_SELECTION.
Referenced by MusicTrackSelectionWindow::OnClick().
| void MusicSystem::Prev | ( | ) | 
Skip to previous track.
Definition at line 276 of file music_gui.cpp.
References _settings_client, ChangePlaylistPosition(), InvalidateWindowData(), ClientSettings::music, Play(), MusicSettings::playing, and WC_MUSIC_WINDOW.
Referenced by MusicWindow::OnClick().
      
  | 
  private | 
Save a custom playlist to settings after modification.
| pl | Playlist to store back | 
Definition at line 428 of file music_gui.cpp.
References _settings_client, MusicSettings::custom_1, MusicSettings::custom_2, ClientSettings::music, and NUM_SONGS_PLAYLIST.
Referenced by PlaylistAdd(), PlaylistClear(), and PlaylistRemove().
      
  | 
  private | 
Set playlist position by set index.
| set_index | Set index to select. | 
Definition at line 187 of file music_gui.cpp.
References active_playlist, and MusicSystem::PlaylistEntry::set_index.
Referenced by Shuffle(), and Unshuffle().
| void MusicSystem::Shuffle | ( | ) | 
Enable shuffle mode.
Definition at line 207 of file music_gui.cpp.
References _settings_client, active_playlist, GetSetIndex(), InvalidateWindowData(), ClientSettings::music, SetPositionBySetIndex(), MusicSettings::shuffle, WC_MUSIC_TRACK_SELECTION, and WC_MUSIC_WINDOW.
Referenced by ChangePlaylist(), and MusicWindow::OnClick().
| void MusicSystem::Stop | ( | ) | 
Stop playback and set flag that we don't intend to play music.
Definition at line 258 of file music_gui.cpp.
References _settings_client, MusicDriver::GetInstance(), InvalidateWindowData(), ClientSettings::music, MusicSettings::playing, MusicDriver::StopSong(), and WC_MUSIC_WINDOW.
Referenced by MusicWindow::OnClick().
| void MusicSystem::Unshuffle | ( | ) | 
Disable shuffle mode.
Definition at line 226 of file music_gui.cpp.
References _settings_client, active_playlist, GetSetIndex(), InvalidateWindowData(), ClientSettings::music, SetPositionBySetIndex(), MusicSettings::shuffle, WC_MUSIC_TRACK_SELECTION, and WC_MUSIC_WINDOW.
Referenced by MusicWindow::OnClick().
| Playlist MusicSystem::active_playlist {} | 
current play order of songs, including any shuffle
Definition at line 61 of file music_gui.cpp.
Referenced by ChangePlaylist(), ChangePlaylistPosition(), CheckStatus(), MusicTrackSelectionWindow::DrawWidget(), GetCurrentSong(), GetSetIndex(), IsPlaying(), Play(), PlaylistAdd(), PlaylistRemove(), SetPositionBySetIndex(), Shuffle(), and Unshuffle().
| Playlist MusicSystem::music_set {} | 
all songs in current music set, in set order
Definition at line 62 of file music_gui.cpp.
Referenced by BuildPlaylists(), MusicTrackSelectionWindow::DrawWidget(), PlaylistAdd(), MusicTrackSelectionWindow::UpdateWidgetSize(), and MusicWindow::UpdateWidgetSize().
      
  | 
  private | 
Definition at line 92 of file music_gui.cpp.
| PlaylistChoices MusicSystem::selected_playlist {} | 
Definition at line 64 of file music_gui.cpp.
      
  | 
  private | 
Definition at line 96 of file music_gui.cpp.