summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2018-03-19 20:13:09 +0100
committerfrosch <github@elsenhans.name>2018-04-29 19:26:05 +0200
commit76cccc64c9eacf0fb7bc43b226466a14a7d142f7 (patch)
tree217b3b9653aeb881108d54d7a9af1a4cd46aee0c
parent0165fe128339733822cf56c6d230de4778bbad39 (diff)
downloadopenttd-76cccc64c9eacf0fb7bc43b226466a14a7d142f7.tar.xz
Codechange: Music GUI comments and function naming
-rw-r--r--src/music_gui.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index 279f37652..c9b99030c 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -103,7 +103,7 @@ void ValidatePlaylist(byte *playlist, byte *last)
*last = 0;
}
-/** Initialize the playlists */
+/** Prepare the playlists */
void InitializeMusic()
{
uint j = 0;
@@ -195,7 +195,8 @@ static void DoStopMusic()
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 j = 0;
@@ -241,10 +242,11 @@ static void StopMusic()
SetWindowWidgetDirty(WC_MUSIC_WINDOW, 0, 9);
}
+/** Begin playing the next song on the playlist */
static void PlayPlaylistSong()
{
if (_cur_playlist[0] == 0) {
- SelectSongToPlay();
+ ResetPlaylist();
/* if there is not songs in the playlist, it may indicate
* no file on the gm folder, or even no gm folder.
* Stop the playback, then */
@@ -268,6 +270,10 @@ void ResetMusic()
DoPlaySong();
}
+/**
+ * Check music playback status and start/stop/song-finished.
+ * Called from main loop.
+ */
void MusicLoop()
{
if (!_settings_client.music.playing && _song_is_active) {
@@ -426,7 +432,7 @@ struct MusicTrackSelectionWindow : public Window {
}
p[i + 1] = 0;
this->SetDirty();
- SelectSongToPlay();
+ ResetPlaylist();
break;
}
}
@@ -445,7 +451,7 @@ struct MusicTrackSelectionWindow : public Window {
}
this->SetDirty();
- SelectSongToPlay();
+ ResetPlaylist();
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;
this->SetDirty();
StopMusic();
- SelectSongToPlay();
+ ResetPlaylist();
break;
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
SelectPlaylist(widget - WID_MTS_ALL);
StopMusic();
- SelectSongToPlay();
+ ResetPlaylist();
break;
}
}
@@ -666,7 +672,7 @@ struct MusicWindow : public Window {
this->SetWidgetLoweredState(WID_M_SHUFFLE, _settings_client.music.shuffle);
this->SetWidgetDirty(WID_M_SHUFFLE);
StopMusic();
- SelectSongToPlay();
+ ResetPlaylist();
this->SetDirty();
break;
@@ -678,7 +684,7 @@ struct MusicWindow : public Window {
case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist
SelectPlaylist(widget - WID_M_ALL);
StopMusic();
- SelectSongToPlay();
+ ResetPlaylist();
this->SetDirty();
break;
}