MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawWidget

Method DrawWidget

src/music_gui.cpp:739–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737 }
738
739 void DrawWidget(const Rect &r, WidgetID widget) const override
740 {
741 switch (widget) {
742 case WID_M_TRACK_NR: {
743 GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
744 if (BaseMusic::GetUsedSet()->num_available == 0) {
745 break;
746 }
747 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
748 if (_music.IsPlaying()) {
749 DrawString(ir, GetString(STR_MUSIC_TRACK_DIGIT, _music.GetCurrentSong().tracknr, 2), TC_FROMSTRING, SA_HOR_CENTER);
750 } else {
751 DrawString(ir, STR_MUSIC_TRACK_NONE, TC_FROMSTRING, SA_HOR_CENTER);
752 }
753 break;
754 }
755
756 case WID_M_TRACK_NAME: {
757 GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
758 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
759
760 MusicSystem::PlaylistEntry entry(_music.GetCurrentSong());
761 if (BaseMusic::GetUsedSet()->num_available == 0) {
762 DrawString(ir, STR_MUSIC_TITLE_NOMUSIC, TC_FROMSTRING, SA_HOR_CENTER);
763 } else if (_music.IsPlaying()) {
764 DrawString(ir, GetString(STR_MUSIC_TITLE_NAME, entry.songname), TC_FROMSTRING, SA_HOR_CENTER);
765 } else {
766 DrawString(ir, STR_MUSIC_TITLE_NONE, TC_FROMSTRING, SA_HOR_CENTER);
767 }
768
769 break;
770 }
771
772 case WID_M_MUSIC_VOL:
773 DrawSliderWidget(r, COLOUR_GREY, COLOUR_GREY, TC_BLACK, 0, INT8_MAX, 0, _settings_client.music.music_vol, nullptr);
774 break;
775
776 case WID_M_EFFECT_VOL:
777 DrawSliderWidget(r, COLOUR_GREY, COLOUR_GREY, TC_BLACK, 0, INT8_MAX, 0, _settings_client.music.effect_vol, nullptr);
778 break;
779 }
780 }
781
782 /**
783 * Some data on this window has become invalid.

Callers

nothing calls this directly

Calls 7

DrawSliderWidgetFunction · 0.85
ShrinkMethod · 0.80
IsPlayingMethod · 0.80
GetCurrentSongMethod · 0.80
GfxFillRectFunction · 0.70
DrawStringFunction · 0.70
GetStringFunction · 0.70

Tested by

no test coverage detected