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

Method OnClick

src/music_gui.cpp:580–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

578 }
579
580 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
581 {
582 switch (widget) {
583 case WID_MTS_LIST_LEFT: { // add to playlist
584 int y = this->GetRowFromWidget(pt.y, widget, WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FS_SMALL));
585 _music.PlaylistAdd(y);
586 break;
587 }
588
589 case WID_MTS_LIST_RIGHT: { // remove from playlist
590 int y = this->GetRowFromWidget(pt.y, widget, WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FS_SMALL));
591 _music.PlaylistRemove(y);
592 break;
593 }
594
595 case WID_MTS_MUSICSET: {
596 int selected = 0;
597 ShowDropDownList(this, BuildSetDropDownList<BaseMusic>(&selected), selected, widget);
598 break;
599 }
600
601 case WID_MTS_CLEAR: // clear
602 _music.PlaylistClear();
603 break;
604
605 case WID_MTS_ALL: case WID_MTS_OLD: case WID_MTS_NEW:
606 case WID_MTS_EZY: case WID_MTS_CUSTOM1: case WID_MTS_CUSTOM2: // set playlist
607 _music.ChangePlaylist((MusicSystem::PlaylistChoices)(widget - WID_MTS_ALL));
608 break;
609 }
610 }
611
612 void OnDropdownSelect(WidgetID widget, int index, int) override
613 {

Callers

nothing calls this directly

Calls 7

GetCharacterHeightFunction · 0.85
ShowDropDownListFunction · 0.85
GetRowFromWidgetMethod · 0.80
PlaylistAddMethod · 0.80
PlaylistRemoveMethod · 0.80
PlaylistClearMethod · 0.80
ChangePlaylistMethod · 0.80

Tested by

no test coverage detected