changeset 2639 | eeaefdabfdfd |
parent 2630 | 7206058a7e82 |
child 2725 | 775e3e14ca46 |
2638:0811adaec525 | 2639:eeaefdabfdfd |
---|---|
18 |
18 |
19 #define NUM_SONGS_AVAILABLE 22 |
19 #define NUM_SONGS_AVAILABLE 22 |
20 |
20 |
21 |
21 |
22 static byte _playlist_all[] = { |
22 static byte _playlist_all[] = { |
23 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,0, |
23 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 0 |
24 }; |
24 }; |
25 |
25 |
26 static byte _playlist_old_style[] = { |
26 static byte _playlist_old_style[] = { |
27 1, 8, 2, 9, 14, 15, 19, 13, 0, |
27 1, 8, 2, 9, 14, 15, 19, 13, 0 |
28 }; |
28 }; |
29 |
29 |
30 static byte _playlist_new_style[] = { |
30 static byte _playlist_new_style[] = { |
31 6, 11, 10, 17, 21, 18, 5, 0 |
31 6, 11, 10, 17, 21, 18, 5, 0 |
32 }; |
32 }; |
43 msf.custom_1, |
43 msf.custom_1, |
44 msf.custom_2, |
44 msf.custom_2, |
45 }; |
45 }; |
46 |
46 |
47 // Map the order of the song names to the numbers of the midi filenames |
47 // Map the order of the song names to the numbers of the midi filenames |
48 static const int midi_idx[] = { |
48 static const byte midi_idx[] = { |
49 0, // Tycoon DELUXE Theme |
49 0, // Tycoon DELUXE Theme |
50 2, // Easy Driver |
50 2, // Easy Driver |
51 3, // Little Red Diesel |
51 3, // Little Red Diesel |
52 17, // Cruise Control |
52 17, // Cruise Control |
53 7, // Don't Walk! |
53 7, // Don't Walk! |
76 byte *b = _cur_playlist; |
76 byte *b = _cur_playlist; |
77 byte *p = b; |
77 byte *p = b; |
78 byte t; |
78 byte t; |
79 |
79 |
80 // empty playlist |
80 // empty playlist |
81 if (b[0] == 0) |
81 if (b[0] == 0) return; |
82 return; |
|
83 |
82 |
84 // find the end |
83 // find the end |
85 do p++; while (p[0] != 0); |
84 do p++; while (p[0] != 0); |
86 |
85 |
87 // and copy the bytes |
86 // and copy the bytes |
95 _song_is_active = false; |
94 _song_is_active = false; |
96 } |
95 } |
97 |
96 |
98 static void SkipToNextSong(void) |
97 static void SkipToNextSong(void) |
99 { |
98 { |
100 byte *b = _cur_playlist, t; |
99 byte* b = _cur_playlist; |
101 |
100 byte t; |
102 if ((t=b[0]) != 0) { |
101 |
103 while (b[1]) { |
102 t = b[0]; |
103 if (t != 0) { |
|
104 while (b[1] != 0) { |
|
104 b[0] = b[1]; |
105 b[0] = b[1]; |
105 b++; |
106 b++; |
106 } |
107 } |
107 b[0] = t; |
108 b[0] = t; |
108 } |
109 } |
163 |
164 |
164 static void PlayPlaylistSong(void) |
165 static void PlayPlaylistSong(void) |
165 { |
166 { |
166 if (_cur_playlist[0] == 0) { |
167 if (_cur_playlist[0] == 0) { |
167 SelectSongToPlay(); |
168 SelectSongToPlay(); |
168 if (_cur_playlist[0] == 0) |
169 if (_cur_playlist[0] == 0) return; |
169 return; |
|
170 } |
170 } |
171 _music_wnd_cursong = _cur_playlist[0]; |
171 _music_wnd_cursong = _cur_playlist[0]; |
172 DoPlaySong(); |
172 DoPlaySong(); |
173 _song_is_active = true; |
173 _song_is_active = true; |
174 |
174 |
187 StopMusic(); |
187 StopMusic(); |
188 } else if (msf.btn_down && !_song_is_active) { |
188 } else if (msf.btn_down && !_song_is_active) { |
189 PlayPlaylistSong(); |
189 PlayPlaylistSong(); |
190 } |
190 } |
191 |
191 |
192 if (_song_is_active == false) |
192 if (_song_is_active == false) return; |
193 return; |
|
194 |
193 |
195 if (!_music_driver->is_song_playing()) { |
194 if (!_music_driver->is_song_playing()) { |
196 if (_game_mode != GM_MENU) { |
195 if (_game_mode != GM_MENU) { |
197 StopMusic(); |
196 StopMusic(); |
198 SkipToNextSong(); |
197 SkipToNextSong(); |
199 PlayPlaylistSong(); |
198 PlayPlaylistSong(); |
200 } else |
199 } else { |
201 ResetMusic(); |
200 ResetMusic(); |
201 } |
|
202 } |
202 } |
203 } |
203 } |
204 |
204 |
205 static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e) |
205 static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e) |
206 { |
206 { |
227 SetDParam(2, i); |
227 SetDParam(2, i); |
228 SetDParam(1, SPECSTR_SONGNAME); |
228 SetDParam(1, SPECSTR_SONGNAME); |
229 DrawString(4, 23+(i-1)*6, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
229 DrawString(4, 23+(i-1)*6, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
230 } |
230 } |
231 |
231 |
232 for(i=0; i!=6; i++) { |
232 for (i = 0; i != 6; i++) { |
233 DrawStringCentered(216, 45 + i*8, STR_01D5_ALL + i, (i==msf.playlist) ? 0xC : 0x10); |
233 DrawStringCentered(216, 45 + i * 8, STR_01D5_ALL + i, (i == msf.playlist) ? 0xC : 0x10); |
234 } |
234 } |
235 |
235 |
236 DrawStringCentered(216, 45+8*6+16, STR_01F0_CLEAR, 0); |
236 DrawStringCentered(216, 45+8*6+16, STR_01F0_CLEAR, 0); |
237 DrawStringCentered(216, 45+8*6+16*2, STR_01F1_SAVE, 0); |
237 DrawStringCentered(216, 45+8*6+16*2, STR_01F1_SAVE, 0); |
238 |
238 |
239 y = 23; |
239 y = 23; |
240 for(p = _playlists[msf.playlist],i=0; (i=*p) != 0; p++) { |
240 for (p = _playlists[msf.playlist], i = 0; (i = *p) != 0; p++) { |
241 SetDParam(0, i); |
241 SetDParam(0, i); |
242 SetDParam(1, SPECSTR_SONGNAME); |
|
242 SetDParam(2, i); |
243 SetDParam(2, i); |
243 SetDParam(1, SPECSTR_SONGNAME); |
|
244 DrawString(252, y, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
244 DrawString(252, y, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
245 y += 6; |
245 y += 6; |
246 } |
246 } |
247 break; |
247 break; |
248 } |
248 } |
249 |
249 |
250 case WE_CLICK: |
250 case WE_CLICK: |
251 switch(e->click.widget) { |
251 switch (e->click.widget) { |
252 case 3: { /* add to playlist */ |
252 case 3: { /* add to playlist */ |
253 int y = (e->click.pt.y - 23) / 6; |
253 int y = (e->click.pt.y - 23) / 6; |
254 int i; |
254 uint i; |
255 byte *p; |
255 byte *p; |
256 |
|
256 if (msf.playlist < 4) return; |
257 if (msf.playlist < 4) return; |
257 if ((uint)y >= NUM_SONGS_AVAILABLE) return; |
258 if (!IS_INT_INSIDE(y, 0, NUM_SONGS_AVAILABLE)) return; |
258 |
259 |
259 p = _playlists[msf.playlist]; |
260 p = _playlists[msf.playlist]; |
260 for(i=0; i!=32; i++) { |
261 for (i = 0; i != 32; i++) { |
261 if (p[i] == 0) { |
262 if (p[i] == 0) { |
262 p[i] = (byte)(y + 1); |
263 p[i] = y + 1; |
263 p[i+1] = 0; |
264 p[i + 1] = 0; |
264 SetWindowDirty(w); |
265 SetWindowDirty(w); |
265 SelectSongToPlay(); |
266 SelectSongToPlay(); |
266 break; |
267 break; |
267 } |
268 } |
268 } |
269 } |
321 |
322 |
322 static void MusicWindowWndProc(Window *w, WindowEvent *e) |
323 static void MusicWindowWndProc(Window *w, WindowEvent *e) |
323 { |
324 { |
324 switch(e->event) { |
325 switch(e->event) { |
325 case WE_PAINT: { |
326 case WE_PAINT: { |
326 int i,num; |
327 uint i; |
327 StringID str; |
328 StringID str; |
328 |
329 |
329 w->click_state |= 0x280; |
330 w->click_state |= 0x280; |
330 DrawWindowWidgets(w); |
331 DrawWindowWidgets(w); |
331 |
332 |
332 GfxFillRect(187, 16, 200, 33, 0); |
333 GfxFillRect(187, 16, 200, 33, 0); |
333 |
334 |
334 num = 8; |
335 for (i = 0; i != 8; i++) { |
335 for (i=0; i!=num; i++) { |
|
336 int color = 0xD0; |
336 int color = 0xD0; |
337 if (i > 4) { |
337 if (i > 4) { |
338 color = 0xBF; |
338 color = 0xBF; |
339 if (i > 6) { |
339 if (i > 6) { |
340 color = 0xB8; |
340 color = 0xB8; |
341 } |
341 } |
342 } |
342 } |
343 GfxFillRect(187, 33 - i*2, 200, 33 - i*2, color); |
343 GfxFillRect(187, 33 - i * 2, 200, 33 - i * 2, color); |
344 } |
344 } |
345 |
345 |
346 GfxFillRect(60, 46, 239, 52, 0); |
346 GfxFillRect(60, 46, 239, 52, 0); |
347 |
347 |
348 str = STR_01E3; |
348 if (_song_is_active == 0 || _music_wnd_cursong == 0) { |
349 if (_song_is_active != 0 && _music_wnd_cursong != 0) { |
349 str = STR_01E3; |
350 str = STR_01E4_0; |
350 } else { |
351 SetDParam(0, _music_wnd_cursong); |
351 SetDParam(0, _music_wnd_cursong); |
352 if (_music_wnd_cursong >= 10) |
352 str = (_music_wnd_cursong < 10) ? STR_01E4_0 : STR_01E5; |
353 str = STR_01E5; |
|
354 } |
353 } |
355 DrawString(62, 46, str, 0); |
354 DrawString(62, 46, str, 0); |
356 |
355 |
357 str = STR_01E6; |
356 str = STR_01E6; |
358 if (_song_is_active != 0 && _music_wnd_cursong != 0) { |
357 if (_song_is_active != 0 && _music_wnd_cursong != 0) { |
363 DrawStringCentered(155, 46, str, 0); |
362 DrawStringCentered(155, 46, str, 0); |
364 |
363 |
365 |
364 |
366 DrawString(60, 38, STR_01E8_TRACK_XTITLE, 0); |
365 DrawString(60, 38, STR_01E8_TRACK_XTITLE, 0); |
367 |
366 |
368 for(i=0; i!=6; i++) { |
367 for (i = 0; i != 6; i++) { |
369 DrawStringCentered(25+i*50, 59, STR_01D5_ALL+i, msf.playlist == i ? 0xC : 0x10); |
368 DrawStringCentered(25 + i * 50, 59, STR_01D5_ALL + i, msf.playlist == i ? 0xC : 0x10); |
370 } |
369 } |
371 |
370 |
372 DrawStringCentered(31, 43, STR_01E9_SHUFFLE, (msf.shuffle ? 0xC : 0x10)); |
371 DrawStringCentered(31, 43, STR_01E9_SHUFFLE, (msf.shuffle ? 0xC : 0x10)); |
373 DrawStringCentered(269, 43, STR_01EA_PROGRAM, 0); |
372 DrawStringCentered(269, 43, STR_01EA_PROGRAM, 0); |
374 DrawStringCentered(141, 15, STR_01DB_MUSIC_VOLUME, 0); |
373 DrawStringCentered(141, 15, STR_01DB_MUSIC_VOLUME, 0); |