Change: Less intrusive "no music" message from Music window

This commit is contained in:
Niels Martin Hansen 2018-03-19 20:26:13 +01:00 committed by frosch
parent e172794947
commit bb809e35ce
2 changed files with 7 additions and 2 deletions

View File

@ -650,6 +650,7 @@ STR_MUSIC_RULER_MARKER :{TINY_FONT}{BLA
STR_MUSIC_TRACK_NONE :{TINY_FONT}{DKGREEN}--
STR_MUSIC_TRACK_DIGIT :{TINY_FONT}{DKGREEN}{ZEROFILL_NUM}
STR_MUSIC_TITLE_NONE :{TINY_FONT}{DKGREEN}------
STR_MUSIC_TITLE_NOMUSIC :{TINY_FONT}{DKGREEN}No music available
STR_MUSIC_TITLE_NAME :{TINY_FONT}{DKGREEN}"{RAW_STRING}"
STR_MUSIC_TRACK :{TINY_FONT}{BLACK}Track
STR_MUSIC_XTITLE :{TINY_FONT}{BLACK}Title

View File

@ -591,6 +591,9 @@ struct MusicWindow : public Window {
switch (widget) {
case WID_M_TRACK_NR: {
GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, PC_BLACK);
if (BaseMusic::GetUsedSet()->num_available == 0) {
break;
}
StringID str = STR_MUSIC_TRACK_NONE;
if (_song_is_active != 0 && _music_wnd_cursong != 0) {
SetDParam(0, GetTrackNumber(_music_wnd_cursong - 1));
@ -604,7 +607,9 @@ struct MusicWindow : public Window {
case WID_M_TRACK_NAME: {
GfxFillRect(r.left, r.top + 1, r.right - 1, r.bottom, PC_BLACK);
StringID str = STR_MUSIC_TITLE_NONE;
if (_song_is_active != 0 && _music_wnd_cursong != 0) {
if (BaseMusic::GetUsedSet()->num_available == 0) {
str = STR_MUSIC_TITLE_NOMUSIC;
} else if (_song_is_active != 0 && _music_wnd_cursong != 0) {
str = STR_MUSIC_TITLE_NAME;
SetDParamStr(0, GetSongName(_music_wnd_cursong - 1));
}
@ -799,6 +804,5 @@ static WindowDesc _music_window_desc(
void ShowMusicWindow()
{
if (BaseMusic::GetUsedSet()->num_available == 0) ShowErrorMessage(STR_ERROR_NO_SONGS, INVALID_STRING_ID, WL_WARNING);
AllocateWindowDescFront<MusicWindow>(&_music_window_desc, 0);
}