author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1093 | 4fdc46eaf423 |
child 1608 | 70a3c1a6576d |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
341
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
#include "window.h" |
5 |
#include "gui.h" |
|
6 |
#include "gfx.h" |
|
7 |
#include "sound.h" |
|
8 |
#include "hal.h" |
|
9 |
||
10 |
#define NUM_SONGS_AVAILABLE 22 |
|
11 |
||
12 |
||
13 |
static byte _playlist_all[] = { |
|
14 |
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,0, |
|
15 |
}; |
|
16 |
||
17 |
static byte _playlist_old_style[] = { |
|
18 |
1, 8, 2, 9, 14, 15, 19, 13, 0, |
|
19 |
}; |
|
20 |
||
21 |
static byte _playlist_new_style[] = { |
|
22 |
6, 11, 10, 17, 21, 18, 5, 0 |
|
23 |
}; |
|
24 |
||
25 |
static byte _playlist_ezy_street[] = { |
|
26 |
12, 7, 16, 3, 20, 4, 0 |
|
27 |
}; |
|
28 |
||
29 |
static byte * const _playlists[] = { |
|
30 |
_playlist_all, |
|
31 |
_playlist_old_style, |
|
32 |
_playlist_new_style, |
|
33 |
_playlist_ezy_street, |
|
34 |
msf.custom_1, |
|
35 |
msf.custom_2, |
|
36 |
}; |
|
37 |
||
341
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
38 |
// Map the order of the song names to the numbers of the midi filenames |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
39 |
static const int midi_idx[] = { |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
40 |
0, // Tycoon DELUXE Theme |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
41 |
2, // Easy Driver |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
42 |
3, // Little Red Diesel |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
43 |
17, // Cruise Control |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
44 |
7, // Don't Walk! |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
45 |
9, // Fell Apart On Me |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
46 |
4, // City Groove |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
47 |
19, // Funk Central |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
48 |
6, // Stoke It |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
49 |
12, // Road Hog |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
50 |
5, // Aliens Ate My Railway |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
51 |
1, // Snarl Up |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
52 |
18, // Stroll On |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
53 |
10, // Can't Get There From Here |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
54 |
8, // Sawyer's Tune |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
55 |
13, // Hold That Train! |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
56 |
21, // Movin' On |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
57 |
15, // Goss Groove |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
58 |
16, // Small Town |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
59 |
14, // Broomer's Oil Rag |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
60 |
20, // Jammit |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
61 |
11 // Hard Drivin' |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
62 |
}; |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
63 |
|
0 | 64 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
65 |
static void SkipToPrevSong(void) |
0 | 66 |
{ |
67 |
byte *b = _cur_playlist; |
|
68 |
byte *p = b; |
|
69 |
byte t; |
|
70 |
||
71 |
// empty playlist |
|
72 |
if (b[0] == 0) |
|
73 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
74 |
|
0 | 75 |
// find the end |
76 |
do p++; while (p[0] != 0); |
|
77 |
||
78 |
// and copy the bytes |
|
79 |
t = *--p; |
|
80 |
while (p != b) { |
|
81 |
p--; |
|
82 |
p[1] = p[0]; |
|
83 |
} |
|
84 |
*b = t; |
|
85 |
||
86 |
_song_is_active = false; |
|
87 |
} |
|
88 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
89 |
static void SkipToNextSong(void) |
0 | 90 |
{ |
91 |
byte *b = _cur_playlist, t; |
|
92 |
||
93 |
if ((t=b[0]) != 0) { |
|
94 |
while (b[1]) { |
|
95 |
b[0] = b[1]; |
|
96 |
b++; |
|
97 |
} |
|
98 |
b[0] = t; |
|
99 |
} |
|
100 |
||
101 |
_song_is_active = false; |
|
102 |
} |
|
103 |
||
104 |
static void MusicVolumeChanged(byte new_vol) |
|
105 |
{ |
|
106 |
_music_driver->set_volume(new_vol); |
|
107 |
} |
|
108 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
109 |
static void DoPlaySong(void) |
0 | 110 |
{ |
111 |
char filename[256]; |
|
341
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
112 |
snprintf(filename, sizeof(filename), "%sgm_tt%.2d.gm", |
e41bddf39d9a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
113 |
_path.gm_dir, midi_idx[_music_wnd_cursong - 1]); |
0 | 114 |
_music_driver->play_song(filename); |
115 |
} |
|
116 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
117 |
static void DoStopMusic(void) |
0 | 118 |
{ |
119 |
_music_driver->stop_song(); |
|
120 |
} |
|
121 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
122 |
static void SelectSongToPlay(void) |
0 | 123 |
{ |
124 |
int i; |
|
125 |
||
126 |
memset(_cur_playlist, 0, 33); |
|
127 |
strcpy(_cur_playlist, _playlists[msf.playlist]); |
|
128 |
||
129 |
if (msf.shuffle) { |
|
130 |
i = 500; |
|
131 |
do { |
|
132 |
uint32 r = InteractiveRandom(); |
|
133 |
byte *a = &_cur_playlist[r & 0x1F]; |
|
134 |
byte *b = &_cur_playlist[(r >> 8)&0x1F]; |
|
135 |
||
136 |
if (*a != 0 && *b != 0) { |
|
137 |
byte t = *a; |
|
138 |
*a = *b; |
|
139 |
*b = t; |
|
140 |
} |
|
141 |
} while (--i); |
|
142 |
} |
|
143 |
} |
|
144 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
145 |
static void StopMusic(void) |
0 | 146 |
{ |
147 |
_music_wnd_cursong = 0; |
|
148 |
DoStopMusic(); |
|
149 |
_song_is_active = false; |
|
150 |
InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9); |
|
151 |
} |
|
152 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
153 |
static void PlayPlaylistSong(void) |
0 | 154 |
{ |
155 |
if (_cur_playlist[0] == 0) { |
|
156 |
SelectSongToPlay(); |
|
157 |
if (_cur_playlist[0] == 0) |
|
158 |
return; |
|
159 |
} |
|
160 |
_music_wnd_cursong = _cur_playlist[0]; |
|
161 |
DoPlaySong(); |
|
162 |
_song_is_active = true; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
163 |
|
0 | 164 |
InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9); |
165 |
} |
|
166 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
167 |
void ResetMusic(void) |
0 | 168 |
{ |
169 |
_music_wnd_cursong = 1; |
|
170 |
DoPlaySong(); |
|
171 |
} |
|
172 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
173 |
void MusicLoop(void) |
0 | 174 |
{ |
175 |
if (!msf.btn_down && _song_is_active) { |
|
176 |
StopMusic(); |
|
177 |
} else if (msf.btn_down && !_song_is_active) { |
|
178 |
PlayPlaylistSong(); |
|
179 |
} |
|
180 |
||
181 |
if (_song_is_active == false) |
|
182 |
return; |
|
183 |
||
184 |
if (!_music_driver->is_song_playing()) { |
|
185 |
StopMusic(); |
|
186 |
SkipToNextSong(); |
|
187 |
PlayPlaylistSong(); |
|
188 |
} |
|
189 |
} |
|
190 |
||
191 |
static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e) |
|
192 |
{ |
|
193 |
switch(e->event) { |
|
194 |
case WE_PAINT: { |
|
195 |
int y,i; |
|
196 |
byte *p; |
|
197 |
||
198 |
w->disabled_state = (msf.playlist <= 3) ? (1 << 11) : 0; |
|
199 |
w->click_state |= 0x18; |
|
200 |
DrawWindowWidgets(w); |
|
201 |
||
202 |
GfxFillRect(3, 23, 3+177,23+191,0); |
|
203 |
GfxFillRect(251, 23, 251+177,23+191,0); |
|
204 |
||
205 |
DrawStringCentered(92, 15, STR_01EE_TRACK_INDEX, 0); |
|
206 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
207 |
SetDParam(0, STR_01D5_ALL + msf.playlist); |
0 | 208 |
DrawStringCentered(340, 15, STR_01EF_PROGRAM, 0); |
209 |
||
210 |
for(i=1; (uint)i <= NUM_SONGS_AVAILABLE; i++) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
211 |
SetDParam(0, i); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
212 |
SetDParam(2, i); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
213 |
SetDParam(1, SPECSTR_SONGNAME); |
0 | 214 |
DrawString(4, 23+(i-1)*6, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
215 |
} |
|
216 |
||
217 |
for(i=0; i!=6; i++) { |
|
218 |
DrawStringCentered(216, 45 + i*8, STR_01D5_ALL + i, (i==msf.playlist) ? 0xC : 0x10); |
|
219 |
} |
|
220 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
221 |
DrawStringCentered(216, 45+8*6+16, STR_01F0_CLEAR, 0); |
0 | 222 |
DrawStringCentered(216, 45+8*6+16*2, STR_01F1_SAVE, 0); |
223 |
||
224 |
y = 23; |
|
225 |
for(p = _playlists[msf.playlist],i=0; (i=*p) != 0; p++) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
226 |
SetDParam(0, i); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
227 |
SetDParam(2, i); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
228 |
SetDParam(1, SPECSTR_SONGNAME); |
0 | 229 |
DrawString(252, y, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
230 |
y += 6; |
|
231 |
} |
|
232 |
break; |
|
233 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
234 |
|
0 | 235 |
case WE_CLICK: |
236 |
switch(e->click.widget) { |
|
237 |
case 3: { /* add to playlist */ |
|
238 |
int y = (e->click.pt.y - 23) / 6; |
|
239 |
int i; |
|
240 |
byte *p; |
|
241 |
if (msf.playlist < 4) return; |
|
242 |
if ((uint)y >= NUM_SONGS_AVAILABLE) return; |
|
243 |
||
244 |
p = _playlists[msf.playlist]; |
|
245 |
for(i=0; i!=32; i++) { |
|
246 |
if (p[i] == 0) { |
|
247 |
p[i] = (byte)(y + 1); |
|
248 |
p[i+1] = 0; |
|
249 |
SetWindowDirty(w); |
|
250 |
SelectSongToPlay(); |
|
251 |
break; |
|
252 |
} |
|
253 |
} |
|
254 |
||
255 |
} break; |
|
256 |
case 11: /* clear */ |
|
257 |
_playlists[msf.playlist][0] = 0; |
|
258 |
SetWindowDirty(w); |
|
259 |
StopMusic(); |
|
260 |
SelectSongToPlay(); |
|
261 |
break; |
|
262 |
case 12: /* save */ |
|
263 |
ShowInfo("MusicTrackSelectionWndProc:save not implemented\n"); |
|
264 |
break; |
|
265 |
case 5: case 6: case 7: case 8: case 9: case 10: /* set playlist */ |
|
266 |
msf.playlist = e->click.widget - 5; |
|
267 |
SetWindowDirty(w); |
|
268 |
InvalidateWindow(WC_MUSIC_WINDOW, 0); |
|
269 |
StopMusic(); |
|
270 |
SelectSongToPlay(); |
|
271 |
break; |
|
272 |
} |
|
273 |
break; |
|
274 |
} |
|
275 |
} |
|
276 |
||
277 |
static const Widget _music_track_selection_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
278 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
279 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 431, 0, 13, STR_01EB_MUSIC_PROGRAM_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
280 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 431, 14, 217, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
281 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 181, 22, 215, 0x0, STR_01FA_CLICK_ON_MUSIC_TRACK_TO}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
282 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 250, 429, 22, 215, 0x0, STR_01F2_CURRENT_PROGRAM_OF_MUSIC}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
283 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 44, 51, 0x0, STR_01F3_SELECT_ALL_TRACKS_PROGRAM}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
284 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 52, 59, 0x0, STR_01F4_SELECT_OLD_STYLE_MUSIC}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
285 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 60, 67, 0x0, STR_01F5_SELECT_NEW_STYLE_MUSIC}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
286 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 68, 75, 0x0, STR_0330_SELECT_EZY_STREET_STYLE}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
287 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 76, 83, 0x0, STR_01F6_SELECT_CUSTOM_1_USER_DEFINED}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
288 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 84, 91, 0x0, STR_01F7_SELECT_CUSTOM_2_USER_DEFINED}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
289 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 108, 115, 0x0, STR_01F8_CLEAR_CURRENT_PROGRAM_CUSTOM1}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
290 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 124, 131, 0x0, STR_01F9_SAVE_MUSIC_SETTINGS}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
291 |
{ WIDGETS_END}, |
0 | 292 |
}; |
293 |
||
294 |
static const WindowDesc _music_track_selection_desc = { |
|
295 |
104, 131, 432, 218, |
|
296 |
WC_MUSIC_TRACK_SELECTION,0, |
|
297 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
298 |
_music_track_selection_widgets, |
|
299 |
MusicTrackSelectionWndProc |
|
300 |
}; |
|
301 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
302 |
static void ShowMusicTrackSelection(void) |
0 | 303 |
{ |
304 |
AllocateWindowDescFront(&_music_track_selection_desc, 0); |
|
305 |
} |
|
306 |
||
307 |
static void MusicWindowWndProc(Window *w, WindowEvent *e) |
|
308 |
{ |
|
309 |
switch(e->event) { |
|
310 |
case WE_PAINT: { |
|
311 |
int i,num; |
|
312 |
StringID str; |
|
313 |
||
314 |
w->click_state |= 0x280; |
|
315 |
DrawWindowWidgets(w); |
|
316 |
||
317 |
GfxFillRect(187, 16, 200, 33, 0); |
|
318 |
||
319 |
num = 8; |
|
320 |
for (i=0; i!=num; i++) { |
|
321 |
int color = 0xD0; |
|
322 |
if (i > 4) { |
|
323 |
color = 0xBF; |
|
324 |
if (i > 6) { |
|
325 |
color = 0xB8; |
|
326 |
} |
|
327 |
} |
|
328 |
GfxFillRect(187, 33 - i*2, 200, 33 - i*2, color); |
|
329 |
} |
|
330 |
||
331 |
GfxFillRect(60, 46, 239, 52, 0); |
|
332 |
||
333 |
str = STR_01E3; |
|
334 |
if (_song_is_active != 0 && _music_wnd_cursong != 0) { |
|
335 |
str = STR_01E4_0; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
336 |
SetDParam(0, _music_wnd_cursong); |
0 | 337 |
if (_music_wnd_cursong >= 10) |
338 |
str = STR_01E5; |
|
339 |
} |
|
340 |
DrawString(62, 46, str, 0); |
|
341 |
||
342 |
str = STR_01E6; |
|
343 |
if (_song_is_active != 0 && _music_wnd_cursong != 0) { |
|
344 |
str = STR_01E7; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
345 |
SetDParam(0, SPECSTR_SONGNAME); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
346 |
SetDParam(1, _music_wnd_cursong); |
0 | 347 |
} |
348 |
DrawStringCentered(155, 46, str, 0); |
|
349 |
||
350 |
||
351 |
DrawString(60, 38, STR_01E8_TRACK_XTITLE, 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
352 |
|
0 | 353 |
for(i=0; i!=6; i++) { |
354 |
DrawStringCentered(25+i*50, 59, STR_01D5_ALL+i, msf.playlist == i ? 0xC : 0x10); |
|
355 |
} |
|
356 |
||
357 |
DrawStringCentered(31, 43, STR_01E9_SHUFFLE, (msf.shuffle ? 0xC : 0x10)); |
|
358 |
DrawStringCentered(269, 43, STR_01EA_PROGRAM, 0); |
|
359 |
DrawStringCentered(141, 15, STR_01DB_MUSIC_VOLUME, 0); |
|
360 |
DrawStringCentered(141, 29, STR_01DD_MIN_MAX, 0); |
|
361 |
DrawStringCentered(247, 15, STR_01DC_EFFECTS_VOLUME, 0); |
|
362 |
DrawStringCentered(247, 29, STR_01DD_MIN_MAX, 0); |
|
363 |
||
364 |
DrawFrameRect(108, 23, 174, 26, 14, 0x20); |
|
365 |
DrawFrameRect(214, 23, 280, 26, 14, 0x20); |
|
366 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
367 |
DrawFrameRect(108 + (msf.music_vol>>1), |
0 | 368 |
22, |
369 |
111 + (msf.music_vol>>1), |
|
370 |
28, |
|
371 |
14, |
|
372 |
0); |
|
373 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
374 |
DrawFrameRect(214 + (msf.effect_vol>>1), |
0 | 375 |
22, |
376 |
217 + (msf.effect_vol>>1), |
|
377 |
28, |
|
378 |
14, |
|
379 |
0); |
|
380 |
} break; |
|
381 |
||
382 |
case WE_CLICK: |
|
383 |
switch(e->click.widget) { |
|
384 |
case 2: // skip to prev |
|
385 |
if (!_song_is_active) |
|
386 |
return; |
|
387 |
SkipToPrevSong(); |
|
388 |
break; |
|
389 |
case 3: // skip to next |
|
390 |
if (!_song_is_active) |
|
391 |
return; |
|
392 |
SkipToNextSong(); |
|
393 |
break; |
|
394 |
case 4: // stop playing |
|
395 |
msf.btn_down = false; |
|
396 |
break; |
|
397 |
case 5: // start playing |
|
398 |
msf.btn_down = true; |
|
399 |
break; |
|
400 |
case 6:{ // volume sliders |
|
401 |
byte *vol,new_vol; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
402 |
int x = e->click.pt.x - 88; |
0 | 403 |
|
404 |
if (x < 0) |
|
405 |
return; |
|
406 |
||
407 |
vol = &msf.music_vol; |
|
408 |
if (x >= 106) { |
|
409 |
vol = &msf.effect_vol; |
|
410 |
x -= 106; |
|
411 |
} |
|
412 |
||
413 |
new_vol = min(max(x-21,0)*2,127); |
|
414 |
if (new_vol != *vol) { |
|
415 |
*vol = new_vol; |
|
416 |
if (vol == &msf.music_vol) |
|
417 |
MusicVolumeChanged(new_vol); |
|
418 |
SetWindowDirty(w); |
|
419 |
} |
|
420 |
||
421 |
_left_button_clicked = false; |
|
422 |
} break; |
|
423 |
case 10: //toggle shuffle |
|
424 |
msf.shuffle ^= 1; |
|
425 |
StopMusic(); |
|
426 |
SelectSongToPlay(); |
|
427 |
break; |
|
428 |
case 11: //show track selection |
|
429 |
ShowMusicTrackSelection(); |
|
430 |
break; |
|
431 |
case 12: case 13: case 14: case 15: case 16: case 17: // playlist |
|
432 |
msf.playlist = e->click.widget - 12; |
|
433 |
SetWindowDirty(w); |
|
434 |
InvalidateWindow(WC_MUSIC_TRACK_SELECTION, 0); |
|
435 |
StopMusic(); |
|
436 |
SelectSongToPlay(); |
|
437 |
break; |
|
438 |
} |
|
439 |
break; |
|
440 |
||
441 |
case WE_MOUSELOOP: |
|
442 |
InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 7); |
|
443 |
break; |
|
444 |
} |
|
445 |
||
446 |
} |
|
447 |
||
448 |
static const Widget _music_window_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
449 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
450 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 299, 0, 13, STR_01D2_JAZZ_JUKEBOX, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
451 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 0, 21, 14, 35, 0x2C5, STR_01DE_SKIP_TO_PREVIOUS_TRACK}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
452 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 22, 43, 14, 35, 0x2C6, STR_01DF_SKIP_TO_NEXT_TRACK_IN_SELECTION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
453 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, 0x2C7, STR_01E0_STOP_PLAYING_MUSIC}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
454 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, 0x2C8, STR_01E1_START_PLAYING_MUSIC}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
455 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 88, 299, 14, 35, 0x0, STR_01E2_DRAG_SLIDERS_TO_SET_MUSIC}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
456 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 186, 201, 15, 34, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
457 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 299, 36, 57, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
458 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 59, 240, 45, 53, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
459 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 6, 55, 42, 49, 0x0, STR_01FB_TOGGLE_PROGRAM_SHUFFLE}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
460 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 244, 293, 42, 49, 0x0, STR_01FC_SHOW_MUSIC_TRACK_SELECTION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
461 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 0, 49, 58, 65, 0x0, STR_01F3_SELECT_ALL_TRACKS_PROGRAM}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
462 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 50, 99, 58, 65, 0x0, STR_01F4_SELECT_OLD_STYLE_MUSIC}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
463 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 100, 149, 58, 65, 0x0, STR_01F5_SELECT_NEW_STYLE_MUSIC}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
464 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 150, 199, 58, 65, 0x0, STR_0330_SELECT_EZY_STREET_STYLE}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
465 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 200, 249, 58, 65, 0x0, STR_01F6_SELECT_CUSTOM_1_USER_DEFINED}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
466 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 250, 299, 58, 65, 0x0, STR_01F7_SELECT_CUSTOM_2_USER_DEFINED}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
467 |
{ WIDGETS_END}, |
0 | 468 |
}; |
469 |
||
470 |
static const WindowDesc _music_window_desc = { |
|
471 |
0, 22, 300, 66, |
|
472 |
WC_MUSIC_WINDOW,0, |
|
473 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
474 |
_music_window_widgets, |
|
475 |
MusicWindowWndProc |
|
476 |
}; |
|
477 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
478 |
void ShowMusicWindow(void) |
0 | 479 |
{ |
480 |
AllocateWindowDescFront(&_music_window_desc, 0); |
|
481 |
} |