Exemplo n.º 1
0
	virtual void OnClick(Point pt, int widget, int click_count)
	{
		switch (widget) {
			case MTSW_LIST_LEFT: { // add to playlist
				int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL);

				if (_msf.playlist < 4) return;
				if (!IsInsideMM(y, 0, BaseMusic::GetUsedSet()->num_available)) return;

				byte *p = _playlists[_msf.playlist];
				for (uint i = 0; i != NUM_SONGS_PLAYLIST - 1; i++) {
					if (p[i] == 0) {
						/* Find the actual song number */
						for (uint j = 0; j < NUM_SONGS_AVAILABLE; j++) {
							if (GetTrackNumber(j) == y + 1) {
								p[i] = j + 1;
								break;
							}
						}
						p[i + 1] = 0;
						this->SetDirty();
						SelectSongToPlay();
						break;
					}
				}
				break;
			}

			case MTSW_LIST_RIGHT: { // remove from playlist
				int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL);

				if (_msf.playlist < 4) return;
				if (!IsInsideMM(y, 0, NUM_SONGS_PLAYLIST)) return;

				byte *p = _playlists[_msf.playlist];
				for (uint i = y; i != NUM_SONGS_PLAYLIST - 1; i++) {
					p[i] = p[i + 1];
				}

				this->SetDirty();
				SelectSongToPlay();
				break;
			}

			case MTSW_CLEAR: // clear
				for (uint i = 0; _playlists[_msf.playlist][i] != 0; i++) _playlists[_msf.playlist][i] = 0;
				this->SetDirty();
				StopMusic();
				SelectSongToPlay();
				break;

			case MTSW_ALL: case MTSW_OLD: case MTSW_NEW:
			case MTSW_EZY: case MTSW_CUSTOM1: case MTSW_CUSTOM2: // set playlist
				SelectPlaylist(widget - MTSW_ALL);
				StopMusic();
				SelectSongToPlay();
				break;
		}
	}
Exemplo n.º 2
0
static void PlayPlaylistSong()
{
	if (_cur_playlist[0] == 0) {
		SelectSongToPlay();
		/* if there is not songs in the playlist, it may indicate
		 * no file on the gm folder, or even no gm folder.
		 * Stop the playback, then */
		if (_cur_playlist[0] == 0) {
			_song_is_active = false;
			_music_wnd_cursong = 0;
			_settings_client.music.playing = false;
			return;
		}
	}
	_music_wnd_cursong = _cur_playlist[0];
	DoPlaySong();
	_song_is_active = true;

	SetWindowWidgetDirty(WC_MUSIC_WINDOW, 0, 9);
}
Exemplo n.º 3
0
	virtual void OnClick(Point pt, int widget, int click_count)
	{
		switch (widget) {
			case WID_M_PREV: // skip to prev
				if (!_song_is_active) return;
				SkipToPrevSong();
				this->SetDirty();
				break;

			case WID_M_NEXT: // skip to next
				if (!_song_is_active) return;
				SkipToNextSong();
				this->SetDirty();
				break;

			case WID_M_STOP: // stop playing
				_settings_client.music.playing = false;
				break;

			case WID_M_PLAY: // start playing
				_settings_client.music.playing = true;
				break;

			case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: { // volume sliders
				int x = pt.x - this->GetWidget<NWidgetBase>(widget)->pos_x;

				byte *vol = (widget == WID_M_MUSIC_VOL) ? &_settings_client.music.music_vol : &_settings_client.music.effect_vol;

				byte new_vol = x * 127 / this->GetWidget<NWidgetBase>(widget)->current_x;
				if (_current_text_dir == TD_RTL) new_vol = 127 - new_vol;
				if (new_vol != *vol) {
					*vol = new_vol;
					if (widget == WID_M_MUSIC_VOL) MusicVolumeChanged((new_vol * new_vol) / 127); // Kinda logarithmic scale
					this->SetDirty();
				}

				_left_button_clicked = false;
				break;
			}

			case WID_M_SHUFFLE: // toggle shuffle
				_settings_client.music.shuffle ^= 1;
				this->SetWidgetLoweredState(WID_M_SHUFFLE, _settings_client.music.shuffle);
				this->SetWidgetDirty(WID_M_SHUFFLE);
				StopMusic();
				SelectSongToPlay();
				this->SetDirty();
				break;

			case WID_M_PROGRAMME: // show track selection
				ShowMusicTrackSelection();
				break;

			case WID_M_ALL: case WID_M_OLD: case WID_M_NEW:
			case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist
				SelectPlaylist(widget - WID_M_ALL);
				StopMusic();
				SelectSongToPlay();
				break;
		}
	}
Exemplo n.º 4
0
	virtual void OnClick(Point pt, int widget, int click_count)
	{
		switch (widget) {
			case WID_MTS_LIST_LEFT: { // add to playlist
				if (_settings_client.music.playlist < 4) return;
				int id_m = this->left_sb->GetScrolledRowFromWidget(pt.y, this, WID_MTS_LIST_LEFT, WD_FRAMERECT_TOP, this->resize.step_height);
				if (!IsInsideMM(id_m, 0, BaseMusic::GetUsedSet()->num_available)) return;

				byte *p = _playlists[_settings_client.music.playlist];
				for (uint i = 0; i != NUM_SONGS_PLAYLIST - 1; i++) {
					if (p[i] == 0) {
						/* Find the actual song number */
						for (uint j = 0; j < NUM_SONGS_AVAILABLE; j++) {
							if (GetTrackNumber(j) == id_m + 1) {
								p[i] = j + 1;
								break;
							}
						}
						p[i + 1] = 0;
						this->right_sb->SetCount(GetNumberOfTracksOfTracklist());
						this->SetDirty();
						SelectSongToPlay();
						break;
					}
				}
				break;
			}

			case WID_MTS_LIST_RIGHT: { // remove from playlist
				if (_settings_client.music.playlist < 4) return;
				int id_m = this->right_sb->GetScrolledRowFromWidget(pt.y, this, WID_MTS_LIST_RIGHT, WD_FRAMERECT_TOP, this->resize.step_height);
				if (!IsInsideMM(id_m, 0, NUM_SONGS_PLAYLIST)) return;

				byte *p = _playlists[_settings_client.music.playlist];
				for (uint i = id_m; i != NUM_SONGS_PLAYLIST - 1; i++) {
					p[i] = p[i + 1];
				}

				this->right_sb->SetCount(GetNumberOfTracksOfTracklist());
				this->SetDirty();
				SelectSongToPlay();
				break;
			}

			case WID_MTS_CLEAR: // clear
				for (uint i = 0; _playlists[_settings_client.music.playlist][i] != 0; i++) _playlists[_settings_client.music.playlist][i] = 0;
				this->right_sb->SetCount(GetNumberOfTracksOfTracklist());
				this->SetDirty();
				StopMusic();
				SelectSongToPlay();
				break;

			case WID_MTS_ALL:
			case WID_MTS_OLD:
			case WID_MTS_NEW:
			case WID_MTS_EZY:
			case WID_MTS_CUSTOM1:
			case WID_MTS_CUSTOM2: // set playlist
				SelectPlaylist(widget - WID_MTS_ALL);
				this->right_sb->SetCount(GetNumberOfTracksOfTracklist());
				this->SetDirty();
				StopMusic();
				SelectSongToPlay();
				break;
		}
	}