author | tron |
Fri, 22 Jul 2005 07:02:20 +0000 | |
changeset 2163 | 637ec3c361f5 |
parent 2159 | 3b634157c3b2 |
child 2186 | 461a2aff3486 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1884
diff
changeset
|
2 |
#include "openttd.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" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
4 |
#include "functions.h" |
0 | 5 |
#include "window.h" |
6 |
#include "gui.h" |
|
7 |
#include "gfx.h" |
|
8 |
#include "sound.h" |
|
9 |
#include "hal.h" |
|
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2155
diff
changeset
|
10 |
#include "macros.h" |
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2155
diff
changeset
|
11 |
#include "variables.h" |
0 | 12 |
|
2155
aa88ed6fe2e3
(svn r2665) Move some variables, which are only used by music_gui.c, there
tron
parents:
2140
diff
changeset
|
13 |
static byte _music_wnd_cursong; |
aa88ed6fe2e3
(svn r2665) Move some variables, which are only used by music_gui.c, there
tron
parents:
2140
diff
changeset
|
14 |
static bool _song_is_active; |
aa88ed6fe2e3
(svn r2665) Move some variables, which are only used by music_gui.c, there
tron
parents:
2140
diff
changeset
|
15 |
static byte _cur_playlist[33]; |
aa88ed6fe2e3
(svn r2665) Move some variables, which are only used by music_gui.c, there
tron
parents:
2140
diff
changeset
|
16 |
|
0 | 17 |
#define NUM_SONGS_AVAILABLE 22 |
18 |
||
19 |
||
20 |
static byte _playlist_all[] = { |
|
21 |
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,0, |
|
22 |
}; |
|
23 |
||
24 |
static byte _playlist_old_style[] = { |
|
25 |
1, 8, 2, 9, 14, 15, 19, 13, 0, |
|
26 |
}; |
|
27 |
||
28 |
static byte _playlist_new_style[] = { |
|
29 |
6, 11, 10, 17, 21, 18, 5, 0 |
|
30 |
}; |
|
31 |
||
32 |
static byte _playlist_ezy_street[] = { |
|
33 |
12, 7, 16, 3, 20, 4, 0 |
|
34 |
}; |
|
35 |
||
36 |
static byte * const _playlists[] = { |
|
37 |
_playlist_all, |
|
38 |
_playlist_old_style, |
|
39 |
_playlist_new_style, |
|
40 |
_playlist_ezy_street, |
|
41 |
msf.custom_1, |
|
42 |
msf.custom_2, |
|
43 |
}; |
|
44 |
||
341
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
45 |
// 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
|
46 |
static const int midi_idx[] = { |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
47 |
0, // Tycoon DELUXE Theme |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
48 |
2, // Easy Driver |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
49 |
3, // Little Red Diesel |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
50 |
17, // Cruise Control |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
51 |
7, // Don't Walk! |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
52 |
9, // Fell Apart On Me |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
53 |
4, // City Groove |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
54 |
19, // Funk Central |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
55 |
6, // Stoke It |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
56 |
12, // Road Hog |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
57 |
5, // Aliens Ate My Railway |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
58 |
1, // Snarl Up |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
59 |
18, // Stroll On |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
60 |
10, // Can't Get There From Here |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
61 |
8, // Sawyer's Tune |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
62 |
13, // Hold That Train! |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
63 |
21, // Movin' On |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
64 |
15, // Goss Groove |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
65 |
16, // Small Town |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
66 |
14, // Broomer's Oil Rag |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
67 |
20, // Jammit |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
68 |
11 // Hard Drivin' |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
69 |
}; |
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
70 |
|
0 | 71 |
|
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
|
72 |
static void SkipToPrevSong(void) |
0 | 73 |
{ |
74 |
byte *b = _cur_playlist; |
|
75 |
byte *p = b; |
|
76 |
byte t; |
|
77 |
||
78 |
// empty playlist |
|
79 |
if (b[0] == 0) |
|
80 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
81 |
|
0 | 82 |
// find the end |
83 |
do p++; while (p[0] != 0); |
|
84 |
||
85 |
// and copy the bytes |
|
86 |
t = *--p; |
|
87 |
while (p != b) { |
|
88 |
p--; |
|
89 |
p[1] = p[0]; |
|
90 |
} |
|
91 |
*b = t; |
|
92 |
||
93 |
_song_is_active = false; |
|
94 |
} |
|
95 |
||
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
|
96 |
static void SkipToNextSong(void) |
0 | 97 |
{ |
98 |
byte *b = _cur_playlist, t; |
|
99 |
||
100 |
if ((t=b[0]) != 0) { |
|
101 |
while (b[1]) { |
|
102 |
b[0] = b[1]; |
|
103 |
b++; |
|
104 |
} |
|
105 |
b[0] = t; |
|
106 |
} |
|
107 |
||
108 |
_song_is_active = false; |
|
109 |
} |
|
110 |
||
111 |
static void MusicVolumeChanged(byte new_vol) |
|
112 |
{ |
|
113 |
_music_driver->set_volume(new_vol); |
|
114 |
} |
|
115 |
||
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
|
116 |
static void DoPlaySong(void) |
0 | 117 |
{ |
118 |
char filename[256]; |
|
341
9d0ac356488a
(svn r517) -Fix: [1033947] Wrong mapping between music titles and songs
tron
parents:
193
diff
changeset
|
119 |
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
|
120 |
_path.gm_dir, midi_idx[_music_wnd_cursong - 1]); |
0 | 121 |
_music_driver->play_song(filename); |
122 |
} |
|
123 |
||
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
|
124 |
static void DoStopMusic(void) |
0 | 125 |
{ |
126 |
_music_driver->stop_song(); |
|
127 |
} |
|
128 |
||
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
|
129 |
static void SelectSongToPlay(void) |
0 | 130 |
{ |
1884
ae1d6213c6dd
(svn r2390) - Codechange: Fix some warnings on GCC 4.0.0
hackykid
parents:
1724
diff
changeset
|
131 |
int i = 0; |
0 | 132 |
|
1884
ae1d6213c6dd
(svn r2390) - Codechange: Fix some warnings on GCC 4.0.0
hackykid
parents:
1724
diff
changeset
|
133 |
do { |
ae1d6213c6dd
(svn r2390) - Codechange: Fix some warnings on GCC 4.0.0
hackykid
parents:
1724
diff
changeset
|
134 |
_cur_playlist[i] = _playlists[msf.playlist][i]; |
ae1d6213c6dd
(svn r2390) - Codechange: Fix some warnings on GCC 4.0.0
hackykid
parents:
1724
diff
changeset
|
135 |
} while ( _cur_playlist[i++] != 0); |
ae1d6213c6dd
(svn r2390) - Codechange: Fix some warnings on GCC 4.0.0
hackykid
parents:
1724
diff
changeset
|
136 |
memset(_cur_playlist + i, 0, 33 - i); |
0 | 137 |
|
138 |
if (msf.shuffle) { |
|
139 |
i = 500; |
|
140 |
do { |
|
141 |
uint32 r = InteractiveRandom(); |
|
2140
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
2133
diff
changeset
|
142 |
byte *a = &_cur_playlist[GB(r, 0, 5)]; |
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
2133
diff
changeset
|
143 |
byte *b = &_cur_playlist[GB(r, 8, 5)]; |
0 | 144 |
|
145 |
if (*a != 0 && *b != 0) { |
|
146 |
byte t = *a; |
|
147 |
*a = *b; |
|
148 |
*b = t; |
|
149 |
} |
|
150 |
} while (--i); |
|
151 |
} |
|
152 |
} |
|
153 |
||
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
|
154 |
static void StopMusic(void) |
0 | 155 |
{ |
156 |
_music_wnd_cursong = 0; |
|
157 |
DoStopMusic(); |
|
158 |
_song_is_active = false; |
|
159 |
InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9); |
|
160 |
} |
|
161 |
||
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
|
162 |
static void PlayPlaylistSong(void) |
0 | 163 |
{ |
164 |
if (_cur_playlist[0] == 0) { |
|
165 |
SelectSongToPlay(); |
|
166 |
if (_cur_playlist[0] == 0) |
|
167 |
return; |
|
168 |
} |
|
169 |
_music_wnd_cursong = _cur_playlist[0]; |
|
170 |
DoPlaySong(); |
|
171 |
_song_is_active = true; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
172 |
|
0 | 173 |
InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9); |
174 |
} |
|
175 |
||
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
|
176 |
void ResetMusic(void) |
0 | 177 |
{ |
178 |
_music_wnd_cursong = 1; |
|
179 |
DoPlaySong(); |
|
180 |
} |
|
181 |
||
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
|
182 |
void MusicLoop(void) |
0 | 183 |
{ |
184 |
if (!msf.btn_down && _song_is_active) { |
|
185 |
StopMusic(); |
|
186 |
} else if (msf.btn_down && !_song_is_active) { |
|
187 |
PlayPlaylistSong(); |
|
188 |
} |
|
189 |
||
190 |
if (_song_is_active == false) |
|
191 |
return; |
|
192 |
||
1724
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
193 |
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
|
194 |
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
|
195 |
StopMusic(); |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
196 |
SkipToNextSong(); |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
197 |
PlayPlaylistSong(); |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
198 |
} else |
f2df13e9b628
(svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents:
1608
diff
changeset
|
199 |
ResetMusic(); |
0 | 200 |
} |
201 |
} |
|
202 |
||
203 |
static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e) |
|
204 |
{ |
|
205 |
switch(e->event) { |
|
206 |
case WE_PAINT: { |
|
2133 | 207 |
uint i; |
208 |
int y; |
|
0 | 209 |
byte *p; |
210 |
||
211 |
w->disabled_state = (msf.playlist <= 3) ? (1 << 11) : 0; |
|
212 |
w->click_state |= 0x18; |
|
213 |
DrawWindowWidgets(w); |
|
214 |
||
215 |
GfxFillRect(3, 23, 3+177,23+191,0); |
|
216 |
GfxFillRect(251, 23, 251+177,23+191,0); |
|
217 |
||
218 |
DrawStringCentered(92, 15, STR_01EE_TRACK_INDEX, 0); |
|
219 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
220 |
SetDParam(0, STR_01D5_ALL + msf.playlist); |
0 | 221 |
DrawStringCentered(340, 15, STR_01EF_PROGRAM, 0); |
222 |
||
2133 | 223 |
for (i = 1; 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
|
224 |
SetDParam(0, i); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
225 |
SetDParam(2, i); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
226 |
SetDParam(1, SPECSTR_SONGNAME); |
0 | 227 |
DrawString(4, 23+(i-1)*6, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
228 |
} |
|
229 |
||
230 |
for(i=0; i!=6; i++) { |
|
231 |
DrawStringCentered(216, 45 + i*8, STR_01D5_ALL + i, (i==msf.playlist) ? 0xC : 0x10); |
|
232 |
} |
|
233 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
234 |
DrawStringCentered(216, 45+8*6+16, STR_01F0_CLEAR, 0); |
0 | 235 |
DrawStringCentered(216, 45+8*6+16*2, STR_01F1_SAVE, 0); |
236 |
||
237 |
y = 23; |
|
238 |
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
|
239 |
SetDParam(0, i); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
240 |
SetDParam(2, i); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
241 |
SetDParam(1, SPECSTR_SONGNAME); |
0 | 242 |
DrawString(252, y, (i < 10) ? STR_01EC_0 : STR_01ED, 0); |
243 |
y += 6; |
|
244 |
} |
|
245 |
break; |
|
246 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
247 |
|
0 | 248 |
case WE_CLICK: |
249 |
switch(e->click.widget) { |
|
250 |
case 3: { /* add to playlist */ |
|
251 |
int y = (e->click.pt.y - 23) / 6; |
|
252 |
int i; |
|
253 |
byte *p; |
|
254 |
if (msf.playlist < 4) return; |
|
255 |
if ((uint)y >= NUM_SONGS_AVAILABLE) return; |
|
256 |
||
257 |
p = _playlists[msf.playlist]; |
|
258 |
for(i=0; i!=32; i++) { |
|
259 |
if (p[i] == 0) { |
|
260 |
p[i] = (byte)(y + 1); |
|
261 |
p[i+1] = 0; |
|
262 |
SetWindowDirty(w); |
|
263 |
SelectSongToPlay(); |
|
264 |
break; |
|
265 |
} |
|
266 |
} |
|
267 |
||
268 |
} break; |
|
269 |
case 11: /* clear */ |
|
270 |
_playlists[msf.playlist][0] = 0; |
|
271 |
SetWindowDirty(w); |
|
272 |
StopMusic(); |
|
273 |
SelectSongToPlay(); |
|
274 |
break; |
|
275 |
case 12: /* save */ |
|
276 |
ShowInfo("MusicTrackSelectionWndProc:save not implemented\n"); |
|
277 |
break; |
|
278 |
case 5: case 6: case 7: case 8: case 9: case 10: /* set playlist */ |
|
279 |
msf.playlist = e->click.widget - 5; |
|
280 |
SetWindowDirty(w); |
|
281 |
InvalidateWindow(WC_MUSIC_WINDOW, 0); |
|
282 |
StopMusic(); |
|
283 |
SelectSongToPlay(); |
|
284 |
break; |
|
285 |
} |
|
286 |
break; |
|
287 |
} |
|
288 |
} |
|
289 |
||
290 |
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
|
291 |
{ 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
|
292 |
{ 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
|
293 |
{ 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
|
294 |
{ 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
|
295 |
{ 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
|
296 |
{ 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
|
297 |
{ 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
|
298 |
{ 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
|
299 |
{ 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
|
300 |
{ 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
|
301 |
{ 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
|
302 |
{ 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
|
303 |
{ 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
|
304 |
{ WIDGETS_END}, |
0 | 305 |
}; |
306 |
||
307 |
static const WindowDesc _music_track_selection_desc = { |
|
308 |
104, 131, 432, 218, |
|
309 |
WC_MUSIC_TRACK_SELECTION,0, |
|
310 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
311 |
_music_track_selection_widgets, |
|
312 |
MusicTrackSelectionWndProc |
|
313 |
}; |
|
314 |
||
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
|
315 |
static void ShowMusicTrackSelection(void) |
0 | 316 |
{ |
317 |
AllocateWindowDescFront(&_music_track_selection_desc, 0); |
|
318 |
} |
|
319 |
||
320 |
static void MusicWindowWndProc(Window *w, WindowEvent *e) |
|
321 |
{ |
|
322 |
switch(e->event) { |
|
323 |
case WE_PAINT: { |
|
324 |
int i,num; |
|
325 |
StringID str; |
|
326 |
||
327 |
w->click_state |= 0x280; |
|
328 |
DrawWindowWidgets(w); |
|
329 |
||
330 |
GfxFillRect(187, 16, 200, 33, 0); |
|
331 |
||
332 |
num = 8; |
|
333 |
for (i=0; i!=num; i++) { |
|
334 |
int color = 0xD0; |
|
335 |
if (i > 4) { |
|
336 |
color = 0xBF; |
|
337 |
if (i > 6) { |
|
338 |
color = 0xB8; |
|
339 |
} |
|
340 |
} |
|
341 |
GfxFillRect(187, 33 - i*2, 200, 33 - i*2, color); |
|
342 |
} |
|
343 |
||
344 |
GfxFillRect(60, 46, 239, 52, 0); |
|
345 |
||
346 |
str = STR_01E3; |
|
347 |
if (_song_is_active != 0 && _music_wnd_cursong != 0) { |
|
348 |
str = STR_01E4_0; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
349 |
SetDParam(0, _music_wnd_cursong); |
0 | 350 |
if (_music_wnd_cursong >= 10) |
351 |
str = STR_01E5; |
|
352 |
} |
|
353 |
DrawString(62, 46, str, 0); |
|
354 |
||
355 |
str = STR_01E6; |
|
356 |
if (_song_is_active != 0 && _music_wnd_cursong != 0) { |
|
357 |
str = STR_01E7; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
358 |
SetDParam(0, SPECSTR_SONGNAME); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
359 |
SetDParam(1, _music_wnd_cursong); |
0 | 360 |
} |
361 |
DrawStringCentered(155, 46, str, 0); |
|
362 |
||
363 |
||
364 |
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
|
365 |
|
0 | 366 |
for(i=0; i!=6; i++) { |
367 |
DrawStringCentered(25+i*50, 59, STR_01D5_ALL+i, msf.playlist == i ? 0xC : 0x10); |
|
368 |
} |
|
369 |
||
370 |
DrawStringCentered(31, 43, STR_01E9_SHUFFLE, (msf.shuffle ? 0xC : 0x10)); |
|
371 |
DrawStringCentered(269, 43, STR_01EA_PROGRAM, 0); |
|
372 |
DrawStringCentered(141, 15, STR_01DB_MUSIC_VOLUME, 0); |
|
373 |
DrawStringCentered(141, 29, STR_01DD_MIN_MAX, 0); |
|
374 |
DrawStringCentered(247, 15, STR_01DC_EFFECTS_VOLUME, 0); |
|
375 |
DrawStringCentered(247, 29, STR_01DD_MIN_MAX, 0); |
|
376 |
||
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
377 |
DrawFrameRect(108, 23, 174, 26, 14, FR_LOWERED); |
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
378 |
DrawFrameRect(214, 23, 280, 26, 14, FR_LOWERED); |
0 | 379 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
380 |
DrawFrameRect(108 + (msf.music_vol>>1), |
0 | 381 |
22, |
382 |
111 + (msf.music_vol>>1), |
|
383 |
28, |
|
384 |
14, |
|
385 |
0); |
|
386 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
387 |
DrawFrameRect(214 + (msf.effect_vol>>1), |
0 | 388 |
22, |
389 |
217 + (msf.effect_vol>>1), |
|
390 |
28, |
|
391 |
14, |
|
392 |
0); |
|
393 |
} break; |
|
394 |
||
395 |
case WE_CLICK: |
|
396 |
switch(e->click.widget) { |
|
397 |
case 2: // skip to prev |
|
398 |
if (!_song_is_active) |
|
399 |
return; |
|
400 |
SkipToPrevSong(); |
|
401 |
break; |
|
402 |
case 3: // skip to next |
|
403 |
if (!_song_is_active) |
|
404 |
return; |
|
405 |
SkipToNextSong(); |
|
406 |
break; |
|
407 |
case 4: // stop playing |
|
408 |
msf.btn_down = false; |
|
409 |
break; |
|
410 |
case 5: // start playing |
|
411 |
msf.btn_down = true; |
|
412 |
break; |
|
413 |
case 6:{ // volume sliders |
|
414 |
byte *vol,new_vol; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
415 |
int x = e->click.pt.x - 88; |
0 | 416 |
|
417 |
if (x < 0) |
|
418 |
return; |
|
419 |
||
420 |
vol = &msf.music_vol; |
|
421 |
if (x >= 106) { |
|
422 |
vol = &msf.effect_vol; |
|
423 |
x -= 106; |
|
424 |
} |
|
425 |
||
426 |
new_vol = min(max(x-21,0)*2,127); |
|
427 |
if (new_vol != *vol) { |
|
428 |
*vol = new_vol; |
|
429 |
if (vol == &msf.music_vol) |
|
430 |
MusicVolumeChanged(new_vol); |
|
431 |
SetWindowDirty(w); |
|
432 |
} |
|
433 |
||
434 |
_left_button_clicked = false; |
|
435 |
} break; |
|
436 |
case 10: //toggle shuffle |
|
437 |
msf.shuffle ^= 1; |
|
438 |
StopMusic(); |
|
439 |
SelectSongToPlay(); |
|
440 |
break; |
|
441 |
case 11: //show track selection |
|
442 |
ShowMusicTrackSelection(); |
|
443 |
break; |
|
444 |
case 12: case 13: case 14: case 15: case 16: case 17: // playlist |
|
445 |
msf.playlist = e->click.widget - 12; |
|
446 |
SetWindowDirty(w); |
|
447 |
InvalidateWindow(WC_MUSIC_TRACK_SELECTION, 0); |
|
448 |
StopMusic(); |
|
449 |
SelectSongToPlay(); |
|
450 |
break; |
|
451 |
} |
|
452 |
break; |
|
453 |
||
454 |
case WE_MOUSELOOP: |
|
455 |
InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 7); |
|
456 |
break; |
|
457 |
} |
|
458 |
||
459 |
} |
|
460 |
||
461 |
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
|
462 |
{ 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
|
463 |
{ 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
|
464 |
{ 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
|
465 |
{ 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
|
466 |
{ 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
|
467 |
{ 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
|
468 |
{ 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
|
469 |
{ 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
|
470 |
{ 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
|
471 |
{ 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
|
472 |
{ 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
|
473 |
{ 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
|
474 |
{ 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
|
475 |
{ 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
|
476 |
{ 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
|
477 |
{ 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
|
478 |
{ 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
|
479 |
{ 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
|
480 |
{ WIDGETS_END}, |
0 | 481 |
}; |
482 |
||
483 |
static const WindowDesc _music_window_desc = { |
|
484 |
0, 22, 300, 66, |
|
485 |
WC_MUSIC_WINDOW,0, |
|
486 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
487 |
_music_window_widgets, |
|
488 |
MusicWindowWndProc |
|
489 |
}; |
|
490 |
||
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
|
491 |
void ShowMusicWindow(void) |
0 | 492 |
{ |
493 |
AllocateWindowDescFront(&_music_window_desc, 0); |
|
494 |
} |