src/music_gui.cpp
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6527 f584ab6d87f8
child 6719 4cc327ad39d5
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
    44 	_playlist_ezy_street,
    44 	_playlist_ezy_street,
    45 	msf.custom_1,
    45 	msf.custom_1,
    46 	msf.custom_2,
    46 	msf.custom_2,
    47 };
    47 };
    48 
    48 
    49 static void SkipToPrevSong(void)
    49 static void SkipToPrevSong()
    50 {
    50 {
    51 	byte *b = _cur_playlist;
    51 	byte *b = _cur_playlist;
    52 	byte *p = b;
    52 	byte *p = b;
    53 	byte t;
    53 	byte t;
    54 
    54 
    64 	*b = t;
    64 	*b = t;
    65 
    65 
    66 	_song_is_active = false;
    66 	_song_is_active = false;
    67 }
    67 }
    68 
    68 
    69 static void SkipToNextSong(void)
    69 static void SkipToNextSong()
    70 {
    70 {
    71 	byte* b = _cur_playlist;
    71 	byte* b = _cur_playlist;
    72 	byte t;
    72 	byte t;
    73 
    73 
    74 	t = b[0];
    74 	t = b[0];
    86 static void MusicVolumeChanged(byte new_vol)
    86 static void MusicVolumeChanged(byte new_vol)
    87 {
    87 {
    88 	_music_driver->set_volume(new_vol);
    88 	_music_driver->set_volume(new_vol);
    89 }
    89 }
    90 
    90 
    91 static void DoPlaySong(void)
    91 static void DoPlaySong()
    92 {
    92 {
    93 	char filename[256];
    93 	char filename[256];
    94 	snprintf(filename, sizeof(filename), "%s%s",
    94 	snprintf(filename, sizeof(filename), "%s%s",
    95 		_paths.gm_dir, origin_songs_specs[_music_wnd_cursong - 1].filename);
    95 		_paths.gm_dir, origin_songs_specs[_music_wnd_cursong - 1].filename);
    96 	_music_driver->play_song(filename);
    96 	_music_driver->play_song(filename);
    97 }
    97 }
    98 
    98 
    99 static void DoStopMusic(void)
    99 static void DoStopMusic()
   100 {
   100 {
   101 	_music_driver->stop_song();
   101 	_music_driver->stop_song();
   102 }
   102 }
   103 
   103 
   104 static void SelectSongToPlay(void)
   104 static void SelectSongToPlay()
   105 {
   105 {
   106 	uint i = 0;
   106 	uint i = 0;
   107 	uint j = 0;
   107 	uint j = 0;
   108 	char filename[256];
   108 	char filename[256];
   109 
   109 
   136 			}
   136 			}
   137 		} while (--i);
   137 		} while (--i);
   138 	}
   138 	}
   139 }
   139 }
   140 
   140 
   141 static void StopMusic(void)
   141 static void StopMusic()
   142 {
   142 {
   143 	_music_wnd_cursong = 0;
   143 	_music_wnd_cursong = 0;
   144 	DoStopMusic();
   144 	DoStopMusic();
   145 	_song_is_active = false;
   145 	_song_is_active = false;
   146 	InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9);
   146 	InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9);
   147 }
   147 }
   148 
   148 
   149 static void PlayPlaylistSong(void)
   149 static void PlayPlaylistSong()
   150 {
   150 {
   151 	if (_cur_playlist[0] == 0) {
   151 	if (_cur_playlist[0] == 0) {
   152 		SelectSongToPlay();
   152 		SelectSongToPlay();
   153 		/* if there is not songs in the playlist, it may indicate
   153 		/* if there is not songs in the playlist, it may indicate
   154 		 * no file on the gm folder, or even no gm folder.
   154 		 * no file on the gm folder, or even no gm folder.
   165 	_song_is_active = true;
   165 	_song_is_active = true;
   166 
   166 
   167 	InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9);
   167 	InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9);
   168 }
   168 }
   169 
   169 
   170 void ResetMusic(void)
   170 void ResetMusic()
   171 {
   171 {
   172 	_music_wnd_cursong = 1;
   172 	_music_wnd_cursong = 1;
   173 	DoPlaySong();
   173 	DoPlaySong();
   174 }
   174 }
   175 
   175 
   176 void MusicLoop(void)
   176 void MusicLoop()
   177 {
   177 {
   178 	if (!msf.playing && _song_is_active) {
   178 	if (!msf.playing && _song_is_active) {
   179 		StopMusic();
   179 		StopMusic();
   180 	} else if (msf.playing && !_song_is_active) {
   180 	} else if (msf.playing && !_song_is_active) {
   181 		PlayPlaylistSong();
   181 		PlayPlaylistSong();
   331 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
   331 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
   332 	_music_track_selection_widgets,
   332 	_music_track_selection_widgets,
   333 	MusicTrackSelectionWndProc
   333 	MusicTrackSelectionWndProc
   334 };
   334 };
   335 
   335 
   336 static void ShowMusicTrackSelection(void)
   336 static void ShowMusicTrackSelection()
   337 {
   337 {
   338 	AllocateWindowDescFront(&_music_track_selection_desc, 0);
   338 	AllocateWindowDescFront(&_music_track_selection_desc, 0);
   339 }
   339 }
   340 
   340 
   341 static void MusicWindowWndProc(Window *w, WindowEvent *e)
   341 static void MusicWindowWndProc(Window *w, WindowEvent *e)
   499 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
   499 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
   500 	_music_window_widgets,
   500 	_music_window_widgets,
   501 	MusicWindowWndProc
   501 	MusicWindowWndProc
   502 };
   502 };
   503 
   503 
   504 void ShowMusicWindow(void)
   504 void ShowMusicWindow()
   505 {
   505 {
   506 	AllocateWindowDescFront(&_music_window_desc, 0);
   506 	AllocateWindowDescFront(&_music_window_desc, 0);
   507 }
   507 }