author | Darkvater |
Sun, 24 Apr 2005 19:04:56 +0000 | |
changeset 1724 | f2df13e9b628 |
parent 1608 | 074dff2e4890 |
child 1884 | ae1d6213c6dd |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(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
9d0ac356488a
(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 |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
39 |
static const int midi_idx[] = { |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
40 |
0, // Tycoon DELUXE Theme |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
41 |
2, // Easy Driver |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
42 |
3, // Little Red Diesel |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
43 |
17, // Cruise Control |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
44 |
7, // Don't Walk! |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
45 |
9, // Fell Apart On Me |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
46 |
4, // City Groove |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
47 |
19, // Funk Central |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
48 |
6, // Stoke It |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
49 |
12, // Road Hog |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
50 |
5, // Aliens Ate My Railway |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
51 |
1, // Snarl Up |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
52 |
18, // Stroll On |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
53 |
10, // Can't Get There From Here |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
54 |
8, // Sawyer's Tune |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
55 |
13, // Hold That Train! |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
56 |
21, // Movin' On |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
57 |
15, // Goss Groove |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
58 |
16, // Small Town |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
59 |
14, // Broomer's Oil Rag |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
60 |
20, // Jammit |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
61 |
11 // Hard Drivin' |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
62 |
}; |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
63 |
|
0 | 64 |
|
1093
e8d26c7dc42f
(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
e8d26c7dc42f
(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
e8d26c7dc42f
(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
9d0ac356488a
(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", |
9d0ac356488a
(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
e8d26c7dc42f
(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
e8d26c7dc42f
(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
e8d26c7dc42f
(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
e8d26c7dc42f
(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
e8d26c7dc42f
(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
e8d26c7dc42f
(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 |
||
1724
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
184 |
if (!_music_driver->is_song_playing()) { |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
185 |
if (_game_mode != GM_MENU) { |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
186 |
StopMusic(); |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
187 |
SkipToNextSong(); |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
188 |
PlayPlaylistSong(); |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
189 |
} else |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
190 |
ResetMusic(); |
0 | 191 |
} |
192 |
} |
|
193 |
||
194 |
static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e) |
|
195 |
{ |
|
196 |
switch(e->event) { |
|
197 |
case WE_PAINT: { |
|
198 |
int y,i; |
|
199 |
byte *p; |
|
200 |
||
201 |
w->disabled_state = (msf.playlist <= 3) ? (1 << 11) : 0; |
|
202 |
w->click_state |= 0x18; |
|
203 |
DrawWindowWidgets(w); |
|
204 |
||
205 |
GfxFillRect(3, 23, 3+177,23+191,0); |
|
206 |
GfxFillRect(251, 23, 251+177,23+191,0); |
|
207 |
||
208 |
DrawStringCentered(92, 15, STR_01EE_TRACK_INDEX, 0); |
|
209 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
210 |
SetDParam(0, STR_01D5_ALL + msf.playlist); |
0 | 211 |
DrawStringCentered(340, 15, STR_01EF_PROGRAM, 0); |
212 |
||
213 |
for(i=1; (uint)i <= NUM_SONGS_AVAILABLE; i++) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
214 |
SetDParam(0, i); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
215 |
SetDParam(2, i); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
216 |
SetDParam(1, SPECSTR_SONGNAME); |
0 | 217 |
DrawString(4, 23+(i-1)*6, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
218 |
} |
|
219 |
||
220 |
for(i=0; i!=6; i++) { |
|
221 |
DrawStringCentered(216, 45 + i*8, STR_01D5_ALL + i, (i==msf.playlist) ? 0xC : 0x10); |
|
222 |
} |
|
223 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
224 |
DrawStringCentered(216, 45+8*6+16, STR_01F0_CLEAR, 0); |
0 | 225 |
DrawStringCentered(216, 45+8*6+16*2, STR_01F1_SAVE, 0); |
226 |
||
227 |
y = 23; |
|
228 |
for(p = _playlists[msf.playlist],i=0; (i=*p) != 0; p++) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
229 |
SetDParam(0, i); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
230 |
SetDParam(2, i); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
231 |
SetDParam(1, SPECSTR_SONGNAME); |
0 | 232 |
DrawString(252, y, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
233 |
y += 6; |
|
234 |
} |
|
235 |
break; |
|
236 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
237 |
|
0 | 238 |
case WE_CLICK: |
239 |
switch(e->click.widget) { |
|
240 |
case 3: { /* add to playlist */ |
|
241 |
int y = (e->click.pt.y - 23) / 6; |
|
242 |
int i; |
|
243 |
byte *p; |
|
244 |
if (msf.playlist < 4) return; |
|
245 |
if ((uint)y >= NUM_SONGS_AVAILABLE) return; |
|
246 |
||
247 |
p = _playlists[msf.playlist]; |
|
248 |
for(i=0; i!=32; i++) { |
|
249 |
if (p[i] == 0) { |
|
250 |
p[i] = (byte)(y + 1); |
|
251 |
p[i+1] = 0; |
|
252 |
SetWindowDirty(w); |
|
253 |
SelectSongToPlay(); |
|
254 |
break; |
|
255 |
} |
|
256 |
} |
|
257 |
||
258 |
} break; |
|
259 |
case 11: /* clear */ |
|
260 |
_playlists[msf.playlist][0] = 0; |
|
261 |
SetWindowDirty(w); |
|
262 |
StopMusic(); |
|
263 |
SelectSongToPlay(); |
|
264 |
break; |
|
265 |
case 12: /* save */ |
|
266 |
ShowInfo("MusicTrackSelectionWndProc:save not implemented\n"); |
|
267 |
break; |
|
268 |
case 5: case 6: case 7: case 8: case 9: case 10: /* set playlist */ |
|
269 |
msf.playlist = e->click.widget - 5; |
|
270 |
SetWindowDirty(w); |
|
271 |
InvalidateWindow(WC_MUSIC_WINDOW, 0); |
|
272 |
StopMusic(); |
|
273 |
SelectSongToPlay(); |
|
274 |
break; |
|
275 |
} |
|
276 |
break; |
|
277 |
} |
|
278 |
} |
|
279 |
||
280 |
static const Widget _music_track_selection_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
281 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
282 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 431, 0, 13, STR_01EB_MUSIC_PROGRAM_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
283 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 431, 14, 217, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
284 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 181, 22, 215, 0x0, STR_01FA_CLICK_ON_MUSIC_TRACK_TO}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
285 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 250, 429, 22, 215, 0x0, STR_01F2_CURRENT_PROGRAM_OF_MUSIC}, |
581154a08a78
(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, 44, 51, 0x0, STR_01F3_SELECT_ALL_TRACKS_PROGRAM}, |
581154a08a78
(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, 52, 59, 0x0, STR_01F4_SELECT_OLD_STYLE_MUSIC}, |
581154a08a78
(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, 60, 67, 0x0, STR_01F5_SELECT_NEW_STYLE_MUSIC}, |
581154a08a78
(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, 68, 75, 0x0, STR_0330_SELECT_EZY_STREET_STYLE}, |
581154a08a78
(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, 76, 83, 0x0, STR_01F6_SELECT_CUSTOM_1_USER_DEFINED}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
291 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 84, 91, 0x0, STR_01F7_SELECT_CUSTOM_2_USER_DEFINED}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
292 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 186, 245, 108, 115, 0x0, STR_01F8_CLEAR_CURRENT_PROGRAM_CUSTOM1}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
293 |
{ 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
|
294 |
{ WIDGETS_END}, |
0 | 295 |
}; |
296 |
||
297 |
static const WindowDesc _music_track_selection_desc = { |
|
298 |
104, 131, 432, 218, |
|
299 |
WC_MUSIC_TRACK_SELECTION,0, |
|
300 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
301 |
_music_track_selection_widgets, |
|
302 |
MusicTrackSelectionWndProc |
|
303 |
}; |
|
304 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
305 |
static void ShowMusicTrackSelection(void) |
0 | 306 |
{ |
307 |
AllocateWindowDescFront(&_music_track_selection_desc, 0); |
|
308 |
} |
|
309 |
||
310 |
static void MusicWindowWndProc(Window *w, WindowEvent *e) |
|
311 |
{ |
|
312 |
switch(e->event) { |
|
313 |
case WE_PAINT: { |
|
314 |
int i,num; |
|
315 |
StringID str; |
|
316 |
||
317 |
w->click_state |= 0x280; |
|
318 |
DrawWindowWidgets(w); |
|
319 |
||
320 |
GfxFillRect(187, 16, 200, 33, 0); |
|
321 |
||
322 |
num = 8; |
|
323 |
for (i=0; i!=num; i++) { |
|
324 |
int color = 0xD0; |
|
325 |
if (i > 4) { |
|
326 |
color = 0xBF; |
|
327 |
if (i > 6) { |
|
328 |
color = 0xB8; |
|
329 |
} |
|
330 |
} |
|
331 |
GfxFillRect(187, 33 - i*2, 200, 33 - i*2, color); |
|
332 |
} |
|
333 |
||
334 |
GfxFillRect(60, 46, 239, 52, 0); |
|
335 |
||
336 |
str = STR_01E3; |
|
337 |
if (_song_is_active != 0 && _music_wnd_cursong != 0) { |
|
338 |
str = STR_01E4_0; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
339 |
SetDParam(0, _music_wnd_cursong); |
0 | 340 |
if (_music_wnd_cursong >= 10) |
341 |
str = STR_01E5; |
|
342 |
} |
|
343 |
DrawString(62, 46, str, 0); |
|
344 |
||
345 |
str = STR_01E6; |
|
346 |
if (_song_is_active != 0 && _music_wnd_cursong != 0) { |
|
347 |
str = STR_01E7; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
348 |
SetDParam(0, SPECSTR_SONGNAME); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
349 |
SetDParam(1, _music_wnd_cursong); |
0 | 350 |
} |
351 |
DrawStringCentered(155, 46, str, 0); |
|
352 |
||
353 |
||
354 |
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
|
355 |
|
0 | 356 |
for(i=0; i!=6; i++) { |
357 |
DrawStringCentered(25+i*50, 59, STR_01D5_ALL+i, msf.playlist == i ? 0xC : 0x10); |
|
358 |
} |
|
359 |
||
360 |
DrawStringCentered(31, 43, STR_01E9_SHUFFLE, (msf.shuffle ? 0xC : 0x10)); |
|
361 |
DrawStringCentered(269, 43, STR_01EA_PROGRAM, 0); |
|
362 |
DrawStringCentered(141, 15, STR_01DB_MUSIC_VOLUME, 0); |
|
363 |
DrawStringCentered(141, 29, STR_01DD_MIN_MAX, 0); |
|
364 |
DrawStringCentered(247, 15, STR_01DC_EFFECTS_VOLUME, 0); |
|
365 |
DrawStringCentered(247, 29, STR_01DD_MIN_MAX, 0); |
|
366 |
||
367 |
DrawFrameRect(108, 23, 174, 26, 14, 0x20); |
|
368 |
DrawFrameRect(214, 23, 280, 26, 14, 0x20); |
|
369 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
370 |
DrawFrameRect(108 + (msf.music_vol>>1), |
0 | 371 |
22, |
372 |
111 + (msf.music_vol>>1), |
|
373 |
28, |
|
374 |
14, |
|
375 |
0); |
|
376 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
377 |
DrawFrameRect(214 + (msf.effect_vol>>1), |
0 | 378 |
22, |
379 |
217 + (msf.effect_vol>>1), |
|
380 |
28, |
|
381 |
14, |
|
382 |
0); |
|
383 |
} break; |
|
384 |
||
385 |
case WE_CLICK: |
|
386 |
switch(e->click.widget) { |
|
387 |
case 2: // skip to prev |
|
388 |
if (!_song_is_active) |
|
389 |
return; |
|
390 |
SkipToPrevSong(); |
|
391 |
break; |
|
392 |
case 3: // skip to next |
|
393 |
if (!_song_is_active) |
|
394 |
return; |
|
395 |
SkipToNextSong(); |
|
396 |
break; |
|
397 |
case 4: // stop playing |
|
398 |
msf.btn_down = false; |
|
399 |
break; |
|
400 |
case 5: // start playing |
|
401 |
msf.btn_down = true; |
|
402 |
break; |
|
403 |
case 6:{ // volume sliders |
|
404 |
byte *vol,new_vol; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
405 |
int x = e->click.pt.x - 88; |
0 | 406 |
|
407 |
if (x < 0) |
|
408 |
return; |
|
409 |
||
410 |
vol = &msf.music_vol; |
|
411 |
if (x >= 106) { |
|
412 |
vol = &msf.effect_vol; |
|
413 |
x -= 106; |
|
414 |
} |
|
415 |
||
416 |
new_vol = min(max(x-21,0)*2,127); |
|
417 |
if (new_vol != *vol) { |
|
418 |
*vol = new_vol; |
|
419 |
if (vol == &msf.music_vol) |
|
420 |
MusicVolumeChanged(new_vol); |
|
421 |
SetWindowDirty(w); |
|
422 |
} |
|
423 |
||
424 |
_left_button_clicked = false; |
|
425 |
} break; |
|
426 |
case 10: //toggle shuffle |
|
427 |
msf.shuffle ^= 1; |
|
428 |
StopMusic(); |
|
429 |
SelectSongToPlay(); |
|
430 |
break; |
|
431 |
case 11: //show track selection |
|
432 |
ShowMusicTrackSelection(); |
|
433 |
break; |
|
434 |
case 12: case 13: case 14: case 15: case 16: case 17: // playlist |
|
435 |
msf.playlist = e->click.widget - 12; |
|
436 |
SetWindowDirty(w); |
|
437 |
InvalidateWindow(WC_MUSIC_TRACK_SELECTION, 0); |
|
438 |
StopMusic(); |
|
439 |
SelectSongToPlay(); |
|
440 |
break; |
|
441 |
} |
|
442 |
break; |
|
443 |
||
444 |
case WE_MOUSELOOP: |
|
445 |
InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 7); |
|
446 |
break; |
|
447 |
} |
|
448 |
||
449 |
} |
|
450 |
||
451 |
static const Widget _music_window_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
452 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
453 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 299, 0, 13, STR_01D2_JAZZ_JUKEBOX, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(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, 0, 21, 14, 35, 0x2C5, STR_01DE_SKIP_TO_PREVIOUS_TRACK}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
455 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 22, 43, 14, 35, 0x2C6, STR_01DF_SKIP_TO_NEXT_TRACK_IN_SELECTION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
456 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, 0x2C7, STR_01E0_STOP_PLAYING_MUSIC}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
457 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, 0x2C8, STR_01E1_START_PLAYING_MUSIC}, |
581154a08a78
(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, 88, 299, 14, 35, 0x0, STR_01E2_DRAG_SLIDERS_TO_SET_MUSIC}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
459 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 186, 201, 15, 34, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
460 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 299, 36, 57, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
461 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 59, 240, 45, 53, 0x0, STR_NULL}, |
581154a08a78
(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, 6, 55, 42, 49, 0x0, STR_01FB_TOGGLE_PROGRAM_SHUFFLE}, |
581154a08a78
(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, 244, 293, 42, 49, 0x0, STR_01FC_SHOW_MUSIC_TRACK_SELECTION}, |
581154a08a78
(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, 0, 49, 58, 65, 0x0, STR_01F3_SELECT_ALL_TRACKS_PROGRAM}, |
581154a08a78
(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, 50, 99, 58, 65, 0x0, STR_01F4_SELECT_OLD_STYLE_MUSIC}, |
581154a08a78
(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, 100, 149, 58, 65, 0x0, STR_01F5_SELECT_NEW_STYLE_MUSIC}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
467 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 150, 199, 58, 65, 0x0, STR_0330_SELECT_EZY_STREET_STYLE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
468 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 200, 249, 58, 65, 0x0, STR_01F6_SELECT_CUSTOM_1_USER_DEFINED}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
654
diff
changeset
|
469 |
{ 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
|
470 |
{ WIDGETS_END}, |
0 | 471 |
}; |
472 |
||
473 |
static const WindowDesc _music_window_desc = { |
|
474 |
0, 22, 300, 66, |
|
475 |
WC_MUSIC_WINDOW,0, |
|
476 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
477 |
_music_window_widgets, |
|
478 |
MusicWindowWndProc |
|
479 |
}; |
|
480 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
867
diff
changeset
|
481 |
void ShowMusicWindow(void) |
0 | 482 |
{ |
483 |
AllocateWindowDescFront(&_music_window_desc, 0); |
|
484 |
} |