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