OpenTTD
Data Structures | Functions | Variables
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 "error.h"
#include "core/geometry_func.hpp"
#include "string_func.h"
#include "settings_type.h"
#include "widgets/music_widget.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  MusicTrackSelectionWindow
 
struct  MusicWindow
 

Functions

static const char * GetSongName (int index)
 Get the name of the song. More...
 
static int GetTrackNumber (int index)
 Get the track number of the song. More...
 
 assert_compile (lengthof(_settings_client.music.custom_1)==NUM_SONGS_PLAYLIST+1)
 
 assert_compile (lengthof(_settings_client.music.custom_2)==NUM_SONGS_PLAYLIST+1)
 
void ValidatePlaylist (byte *playlist, byte *last)
 Validate a playlist. More...
 
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. More...
 
static const NWidgetPart _nested_music_track_selection_widgets []
 
static WindowDesc _music_track_selection_desc (WDP_AUTO, "music_track", 0, 0, WC_MUSIC_TRACK_SELECTION, WC_NONE, 0, _nested_music_track_selection_widgets, lengthof(_nested_music_track_selection_widgets))
 
static const NWidgetPart _nested_music_window_widgets []
 
static WindowDesc _music_window_desc (WDP_AUTO, "music", 0, 0, WC_MUSIC_WINDOW, WC_NONE, 0, _nested_music_window_widgets, lengthof(_nested_music_window_widgets))
 

Detailed Description

GUI for the music playback.

Definition in file music_gui.cpp.

Function Documentation

◆ GetSongName()

static const char* GetSongName ( int  index)
static

Get the name of the song.

Parameters
indexof the song.
Returns
the name of the song.

Definition at line 39 of file music_gui.cpp.

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

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

◆ GetTrackNumber()

static int GetTrackNumber ( int  index)
static

Get the track number of the song.

Parameters
indexof the song.
Returns
the track number of the song.

Definition at line 49 of file music_gui.cpp.

References BaseMedia< MusicSet >::GetUsedSet().

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

◆ ValidatePlaylist()

void ValidatePlaylist ( byte *  playlist,
byte *  last 
)

Validate a playlist.

Parameters
playlistThe playlist to validate.
lastThe last location in the list.

Definition at line 89 of file music_gui.cpp.

References GetSongName(), NUM_SONGS_AVAILABLE, and StrEmpty().

Referenced by InitializeMusic().

Variable Documentation

◆ _playlists

byte* const _playlists[]
static
Initial value:
= {
}
static byte _playlist_old_style[NUM_SONGS_CLASS+1]
Indices of all old style songs.
Definition: music_gui.cpp:65
static byte _playlist_ezy_street[NUM_SONGS_CLASS+1]
Indices of all ezy street songs.
Definition: music_gui.cpp:69
static byte _playlist_new_style[NUM_SONGS_CLASS+1]
Indices of all new style songs.
Definition: music_gui.cpp:67
MusicSettings music
settings related to music/sound
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:76
byte custom_1[33]
The order of the first custom playlist.
static byte _playlist_all[NUM_SONGS_AVAILABLE+1]
Indices of all songs.
Definition: music_gui.cpp:63
byte custom_2[33]
The order of the second custom playlist.

The different playlists that can be played.

Definition at line 75 of file music_gui.cpp.