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