diff options
author | Niels Martin Hansen <nielsm@indvikleren.dk> | 2018-03-19 20:13:25 +0100 |
---|---|---|
committer | frosch <github@elsenhans.name> | 2018-04-29 19:26:05 +0200 |
commit | e1727949479950cbaa41c8a05cc563ce0763c4a8 (patch) | |
tree | f4324d9686219ca90849301f6438a93ae84d334b | |
parent | 76cccc64c9eacf0fb7bc43b226466a14a7d142f7 (diff) | |
download | openttd-e1727949479950cbaa41c8a05cc563ce0763c4a8.tar.xz |
Change: Disable music control buttons when there is no music
-rw-r--r-- | src/music_gui.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/music_gui.cpp b/src/music_gui.cpp index c9b99030c..9b7f2f95d 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -528,6 +528,20 @@ struct MusicWindow : public Window { this->InitNested(number); this->LowerWidget(_settings_client.music.playlist + WID_M_ALL); this->SetWidgetLoweredState(WID_M_SHUFFLE, _settings_client.music.shuffle); + + UpdateDisabledButtons(); + } + + void UpdateDisabledButtons() + { + /* Disable music control widgets if there is no music + * -- except Programme button! So you can still select a music set. */ + this->SetWidgetsDisabledState( + BaseMusic::GetUsedSet()->num_available == 0, + WID_M_PREV, WID_M_NEXT, WID_M_STOP, WID_M_PLAY, WID_M_SHUFFLE, + WID_M_ALL, WID_M_OLD, WID_M_NEW, WID_M_EZY, WID_M_CUSTOM1, WID_M_CUSTOM2, + WIDGET_LIST_END + ); } virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) @@ -624,6 +638,9 @@ struct MusicWindow : public Window { for (int i = 0; i < 6; i++) { this->SetWidgetLoweredState(WID_M_ALL + i, i == _settings_client.music.playlist); } + + UpdateDisabledButtons(); + this->SetDirty(); } |