# music_gui.cpp File Reference

GUI for the music playback. More...

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "base_media_base.h"`
`#include "music/music_driver.hpp"`
`#include "window_gui.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "sound_func.h"`
`#include "gfx_func.h"`
`#include "core/random_func.hpp"`
`#include "gui.h"`
`#include "core/geometry_func.hpp"`
`#include "string_func.h"`
`#include "table/strings.h"`
`#include "table/sprites.h"`

Go to the source code of this file.

## Data Structures
struct | MusicTrackSelectionWindow
struct | MusicWindow
## Enumerations
enum | MusicTrackSelectionWidgets { MTSW_LIST_LEFT, MTSW_PLAYLIST, MTSW_LIST_RIGHT, MTSW_ALL, MTSW_OLD, MTSW_NEW, MTSW_EZY, MTSW_CUSTOM1, MTSW_CUSTOM2, MTSW_CLEAR }
enum | MusicWidgets { MW_PREV, MW_NEXT, MW_STOP, MW_PLAY, MW_SLIDERS, MW_MUSIC_VOL, MW_GAUGE, MW_EFFECT_VOL, MW_BACKGROUND, MW_TRACK, MW_TRACK_NR, MW_TRACK_TITLE, MW_TRACK_NAME, MW_SHUFFLE, MW_PROGRAMME, MW_ALL, MW_OLD, MW_NEW, MW_EZY, MW_CUSTOM1, MW_CUSTOM2 }
## Functions
static const char * | GetSongName (int index)
| Get the name of the song.
static int | GetTrackNumber (int index)
| Get the track number of the song.
| assert_compile (lengthof(msf.custom_1)==NUM_SONGS_PLAYLIST+1)
| assert_compile (lengthof(msf.custom_2)==NUM_SONGS_PLAYLIST+1)
void | ValidatePlaylist (byte *playlist)
| Validate a playlist.
void | InitializeMusic ()
| Initialize the playlists.
static void | SkipToPrevSong ()
static void | SkipToNextSong ()
static void | MusicVolumeChanged (byte new_vol)
static void | DoPlaySong ()
static void | DoStopMusic ()
static void | SelectSongToPlay ()
static void | StopMusic ()
static void | PlayPlaylistSong ()
void | ResetMusic ()
void | MusicLoop ()
static void | SelectPlaylist (byte list)
static void | ShowMusicTrackSelection ()
void | ShowMusicWindow ()
## Variables
static byte | _music_wnd_cursong = 1
| The currently played song.
static bool | _song_is_active = false
| Whether a song is currently played.
static byte | _cur_playlist [NUM_SONGS_PLAYLIST+1]
| Indices of the songs in the current playlist.
static byte | _playlist_all [NUM_SONGS_AVAILABLE+1]
| Indices of all songs.
static byte | _playlist_old_style [NUM_SONGS_CLASS+1]
| Indices of all old style songs.
static byte | _playlist_new_style [NUM_SONGS_CLASS+1]
| Indices of all new style songs.
static byte | _playlist_ezy_street [NUM_SONGS_CLASS+1]
| Indices of all ezy street songs.
static byte *const | _playlists []
| The different playlists that can be played.
static const NWidgetPart | _nested_music_track_selection_widgets []
static const WindowDesc | _music_track_selection_desc (WDP_AUTO, 0, 0, WC_MUSIC_TRACK_SELECTION, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_music_track_selection_widgets, lengthof(_nested_music_track_selection_widgets))
static const NWidgetPart | _nested_music_window_widgets []
static const WindowDesc | _music_window_desc (WDP_AUTO, 0, 0, WC_MUSIC_WINDOW, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_music_window_widgets, lengthof(_nested_music_window_widgets))

## Detailed Description

GUI for the music playback.

Definition in file music_gui.cpp.

## Function Documentation

static const char* GetSongName | ( | int | index | ) | `[static]`

Get the name of the song.

Parameters:

  | index | of the song.

Returns:
  the name of the song.

Definition at line 34 of file music_gui.cpp.

References BaseMedia< MusicSet >::GetUsedSet(), and MusicSet::song_name.

Referenced by MusicWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), InitializeMusic(), MusicWindow::UpdateWidgetSize(), and MusicTrackSelectionWindow::UpdateWidgetSize().

static int GetTrackNumber | ( | int | index | ) | `[static]`

Get the track number of the song.

Parameters:

  | index | of the song.

Returns:
  the track number of the song.

Definition at line 44 of file music_gui.cpp.

References BaseMedia< MusicSet >::GetUsedSet().

Referenced by MusicWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), MusicTrackSelectionWindow::OnClick(), and MusicTrackSelectionWindow::UpdateWidgetSize().

void ValidatePlaylist | ( | byte * | playlist | ) |

Validate a playlist.

Parameters:

  | playlist | the playlist to validate

Definition at line 83 of file music_gui.cpp.

References BaseMedia< MusicSet >::GetUsedSet().

Referenced by InitializeMusic().

## Variable Documentation

byte* const _playlists[]`[static]`

Initial value:

     {
      _playlist_all,
      _playlist_old_style,
      _playlist_new_style,
      _playlist_ezy_street,
      msf.custom_1,
      msf.custom_2,
    }

The different playlists that can be played.

Definition at line 70 of file music_gui.cpp.