| 801 | } |
| 802 | |
| 803 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 804 | { |
| 805 | switch (widget) { |
| 806 | case WID_M_PREV: // skip to prev |
| 807 | _music.Prev(); |
| 808 | break; |
| 809 | |
| 810 | case WID_M_NEXT: // skip to next |
| 811 | _music.Next(); |
| 812 | break; |
| 813 | |
| 814 | case WID_M_STOP: // stop playing |
| 815 | _music.Stop(); |
| 816 | break; |
| 817 | |
| 818 | case WID_M_PLAY: // start playing |
| 819 | _music.Play(); |
| 820 | break; |
| 821 | |
| 822 | case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: { // volume sliders |
| 823 | uint8_t &vol = (widget == WID_M_MUSIC_VOL) ? _settings_client.music.music_vol : _settings_client.music.effect_vol; |
| 824 | if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, 0, INT8_MAX, 0, vol)) { |
| 825 | if (widget == WID_M_MUSIC_VOL) { |
| 826 | MusicDriver::GetInstance()->SetVolume(vol); |
| 827 | } else { |
| 828 | SetEffectVolume(vol); |
| 829 | } |
| 830 | this->SetWidgetDirty(widget); |
| 831 | SetWindowClassesDirty(WC_GAME_OPTIONS); |
| 832 | } |
| 833 | |
| 834 | if (click_count > 0) this->mouse_capture_widget = widget; |
| 835 | break; |
| 836 | } |
| 837 | |
| 838 | case WID_M_SHUFFLE: // toggle shuffle |
| 839 | if (_music.IsShuffle()) { |
| 840 | _music.Unshuffle(); |
| 841 | } else { |
| 842 | _music.Shuffle(); |
| 843 | } |
| 844 | this->SetWidgetLoweredState(WID_M_SHUFFLE, _music.IsShuffle()); |
| 845 | this->SetWidgetDirty(WID_M_SHUFFLE); |
| 846 | break; |
| 847 | |
| 848 | case WID_M_PROGRAMME: // show track selection |
| 849 | ShowMusicTrackSelection(); |
| 850 | break; |
| 851 | |
| 852 | case WID_M_ALL: case WID_M_OLD: case WID_M_NEW: |
| 853 | case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist |
| 854 | _music.ChangePlaylist((MusicSystem::PlaylistChoices)(widget - WID_M_ALL)); |
| 855 | break; |
| 856 | } |
| 857 | } |
| 858 | }; |
| 859 | |
| 860 | static constexpr std::initializer_list<NWidgetPart> _nested_music_window_widgets = { |
nothing calls this directly
no test coverage detected