OpenTTD Source  1.11.0-beta2
MusicSystem Struct Reference

Data Structures

struct  PlaylistEntry
 

Public Types

enum  PlaylistChoices {
  PLCH_ALLMUSIC, PLCH_OLDSTYLE, PLCH_NEWSTYLE, PLCH_EZYSTREET,
  PLCH_CUSTOM1, PLCH_CUSTOM2, PLCH_THEMEONLY, PLCH_MAX
}
 
typedef std::vector< PlaylistEntryPlaylist
 

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. More...
 
void ChangeMusicSet (const std::string &set_name)
 Change to named music set, and reset playback. More...
 
void Shuffle ()
 Enable shuffle mode and restart playback.
 
void Unshuffle ()
 Disable shuffle and restart playback.
 
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. More...
 
void PlaylistRemove (size_t song_index)
 Remove a song from a custom playlist. More...
 
void PlaylistClear ()
 Remove all songs from the current custom playlist. More...
 

Data Fields

Playlist active_playlist
 current play order of songs, including any shuffle
 
Playlist displayed_playlist
 current playlist as displayed in GUI, never in shuffled order
 
Playlist music_set
 all songs in current music set, in set order
 
PlaylistChoices selected_playlist
 

Private Member Functions

void ChangePlaylistPosition (int ofs)
 Change playlist position pointer by the given offset, making sure to keep it within valid range. More...
 
void SaveCustomPlaylist (PlaylistChoices pl)
 Save a custom playlist to settings after modification. More...
 

Private Attributes

int playlist_position
 
Playlist standard_playlists [PLCH_MAX]
 

Detailed Description

Definition at line 38 of file music_gui.cpp.

Member Function Documentation

◆ ChangeMusicSet()

void MusicSystem::ChangeMusicSet ( const std::string &  set_name)

Change to named music set, and reset playback.

Parameters
set_nameName of music set to select

Definition at line 170 of file music_gui.cpp.

References BuildPlaylists(), ChangePlaylist(), BaseMedia< MusicSet >::ini_set, InvalidateWindowData(), BaseMedia< MusicSet >::SetSet(), WC_GAME_OPTIONS, and WN_GAME_OPTIONS_GAME_OPTIONS.

◆ ChangePlaylist()

void MusicSystem::ChangePlaylist ( PlaylistChoices  pl)

Switch to another playlist, or reload the current one.

Parameters
plPlaylist to select

Definition at line 144 of file music_gui.cpp.

References _settings_client, active_playlist, displayed_playlist, InvalidateWindowData(), ClientSettings::music, Play(), MusicSettings::playing, MusicSettings::playlist, Shuffle(), MusicSettings::shuffle, WC_MUSIC_TRACK_SELECTION, and WC_MUSIC_WINDOW.

Referenced by ChangeMusicSet(), and PlaylistClear().

◆ ChangePlaylistPosition()

void MusicSystem::ChangePlaylistPosition ( int  ofs)
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.

Parameters
ofsAmount to move playlist position by.

Definition at line 382 of file music_gui.cpp.

References active_playlist.

Referenced by Next(), Play(), and Prev().

◆ PlaylistAdd()

void MusicSystem::PlaylistAdd ( size_t  song_index)

Append a song to a custom playlist.

Always adds to the currently active playlist.

Parameters
song_indexIndex of song in the current music set to add

Definition at line 296 of file music_gui.cpp.

References active_playlist, displayed_playlist, IsCustomPlaylist(), IsPlaying(), IsShuffle(), music_set, NUM_SONGS_PLAYLIST, and Play().

◆ PlaylistClear()

void MusicSystem::PlaylistClear ( )

Remove all songs from the current custom playlist.

Effectively stops playback too.

Definition at line 367 of file music_gui.cpp.

References ChangePlaylist(), IsCustomPlaylist(), and SaveCustomPlaylist().

◆ PlaylistRemove()

void MusicSystem::PlaylistRemove ( size_t  song_index)

Remove a song from a custom playlist.

Parameters
song_indexIndex in the custom playlist to remove.

Definition at line 335 of file music_gui.cpp.

References active_playlist, MusicSongInfo::cat_index, displayed_playlist, MusicSongInfo::filename, InvalidateWindowData(), IsCustomPlaylist(), IsPlaying(), Play(), SaveCustomPlaylist(), and WC_MUSIC_TRACK_SELECTION.

◆ SaveCustomPlaylist()

void MusicSystem::SaveCustomPlaylist ( PlaylistChoices  pl)
private

Save a custom playlist to settings after modification.

Parameters
plPlaylist to store back

Definition at line 397 of file music_gui.cpp.

References _settings_client, MusicSettings::custom_1, MusicSettings::custom_2, MemSetT(), ClientSettings::music, and NUM_SONGS_PLAYLIST.

Referenced by PlaylistClear(), and PlaylistRemove().


The documentation for this struct was generated from the following file: