mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Music GUI comments and function naming
parent
0165fe1283
commit
76cccc64c9
|
@ -103,7 +103,7 @@ void ValidatePlaylist(byte *playlist, byte *last)
|
||||||
*last = 0;
|
*last = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize the playlists */
|
/** Prepare the playlists */
|
||||||
void InitializeMusic()
|
void InitializeMusic()
|
||||||
{
|
{
|
||||||
uint j = 0;
|
uint j = 0;
|
||||||
|
@ -195,7 +195,8 @@ static void DoStopMusic()
|
||||||
SetWindowDirty(WC_MUSIC_WINDOW, 0);
|
SetWindowDirty(WC_MUSIC_WINDOW, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SelectSongToPlay()
|
/** Reload the active playlist data from playlist selection and shuffle setting */
|
||||||
|
static void ResetPlaylist()
|
||||||
{
|
{
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
uint j = 0;
|
uint j = 0;
|
||||||
|
@ -241,10 +242,11 @@ static void StopMusic()
|
||||||
SetWindowWidgetDirty(WC_MUSIC_WINDOW, 0, 9);
|
SetWindowWidgetDirty(WC_MUSIC_WINDOW, 0, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Begin playing the next song on the playlist */
|
||||||
static void PlayPlaylistSong()
|
static void PlayPlaylistSong()
|
||||||
{
|
{
|
||||||
if (_cur_playlist[0] == 0) {
|
if (_cur_playlist[0] == 0) {
|
||||||
SelectSongToPlay();
|
ResetPlaylist();
|
||||||
/* if there is not songs in the playlist, it may indicate
|
/* if there is not songs in the playlist, it may indicate
|
||||||
* no file on the gm folder, or even no gm folder.
|
* no file on the gm folder, or even no gm folder.
|
||||||
* Stop the playback, then */
|
* Stop the playback, then */
|
||||||
|
@ -268,6 +270,10 @@ void ResetMusic()
|
||||||
DoPlaySong();
|
DoPlaySong();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check music playback status and start/stop/song-finished.
|
||||||
|
* Called from main loop.
|
||||||
|
*/
|
||||||
void MusicLoop()
|
void MusicLoop()
|
||||||
{
|
{
|
||||||
if (!_settings_client.music.playing && _song_is_active) {
|
if (!_settings_client.music.playing && _song_is_active) {
|
||||||
|
@ -426,7 +432,7 @@ struct MusicTrackSelectionWindow : public Window {
|
||||||
}
|
}
|
||||||
p[i + 1] = 0;
|
p[i + 1] = 0;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
SelectSongToPlay();
|
ResetPlaylist();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -445,7 +451,7 @@ struct MusicTrackSelectionWindow : public Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
SelectSongToPlay();
|
ResetPlaylist();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,14 +459,14 @@ struct MusicTrackSelectionWindow : public Window {
|
||||||
for (uint i = 0; _playlists[_settings_client.music.playlist][i] != 0; i++) _playlists[_settings_client.music.playlist][i] = 0;
|
for (uint i = 0; _playlists[_settings_client.music.playlist][i] != 0; i++) _playlists[_settings_client.music.playlist][i] = 0;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
StopMusic();
|
StopMusic();
|
||||||
SelectSongToPlay();
|
ResetPlaylist();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_MTS_ALL: case WID_MTS_OLD: case WID_MTS_NEW:
|
case WID_MTS_ALL: case WID_MTS_OLD: case WID_MTS_NEW:
|
||||||
case WID_MTS_EZY: case WID_MTS_CUSTOM1: case WID_MTS_CUSTOM2: // set playlist
|
case WID_MTS_EZY: case WID_MTS_CUSTOM1: case WID_MTS_CUSTOM2: // set playlist
|
||||||
SelectPlaylist(widget - WID_MTS_ALL);
|
SelectPlaylist(widget - WID_MTS_ALL);
|
||||||
StopMusic();
|
StopMusic();
|
||||||
SelectSongToPlay();
|
ResetPlaylist();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,7 +672,7 @@ struct MusicWindow : public Window {
|
||||||
this->SetWidgetLoweredState(WID_M_SHUFFLE, _settings_client.music.shuffle);
|
this->SetWidgetLoweredState(WID_M_SHUFFLE, _settings_client.music.shuffle);
|
||||||
this->SetWidgetDirty(WID_M_SHUFFLE);
|
this->SetWidgetDirty(WID_M_SHUFFLE);
|
||||||
StopMusic();
|
StopMusic();
|
||||||
SelectSongToPlay();
|
ResetPlaylist();
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -678,7 +684,7 @@ struct MusicWindow : public Window {
|
||||||
case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist
|
case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist
|
||||||
SelectPlaylist(widget - WID_M_ALL);
|
SelectPlaylist(widget - WID_M_ALL);
|
||||||
StopMusic();
|
StopMusic();
|
||||||
SelectSongToPlay();
|
ResetPlaylist();
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue