Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5465 | leency | 1 | //flac |
2 | //do not open multiple threads |
||
3 | //edit list manually |
||
4 | |||
5793 | leency | 5 | #define MEMSIZE 0xFFFFF |
5465 | leency | 6 | |
5793 | leency | 7 | #include "..\lib\obj\proc_lib.h" |
8 | #include "..\lib\patterns\simple_open_dialog.h" |
||
9 | char default_dir[] = "/rd/1"; |
||
10 | od_filter filter2 = { "MP3", 0 }; |
||
11 | |||
5465 | leency | 12 | #include "..\lib\file_system.h" |
13 | #include "..\lib\list_box.h" |
||
5499 | leency | 14 | #include "..\lib\gui.h" |
5465 | leency | 15 | |
5499 | leency | 16 | #include "..\lib\obj\box_lib.h" |
17 | #include "..\lib\obj\libio_lib.h" |
||
18 | #include "..\lib\obj\libimg_lib.h" |
||
19 | #include "..\lib\obj\libini.h" |
||
5465 | leency | 20 | |
21 | #include "..\lib\patterns\libimg_load_skin.h" |
||
22 | |||
5798 | leency | 23 | #define ABOUT_MESSAGE "'Pixies Player v1.33\n\nOpen file: O key\nChange skin: F1/F2 |
5795 | leency | 24 | Play/Stop: Space or P key\nStart playing selected file: Enter |
25 | Goto next/previous track: Ctrl + Left/Right |
||
26 | Change sound volume: Left/Right key\nMute: M key' -St\n" |
||
27 | |||
5465 | leency | 28 | scroll_bar scroll1 = { 5,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
5825 | leency | 29 | |
30 | proc_info Form; |
||
5465 | leency | 31 | llist list; |
32 | |||
33 | char pixie_ini_path[4096]; |
||
34 | |||
35 | enum { |
||
36 | BUTTON_WINDOW_CLOSE = 1, |
||
37 | BUTTON_WINDOW_MINIMIZE, |
||
38 | BUTTON_WINDOW_REDUCE, |
||
39 | BUTTON_PLAYBACK_PLAY_PAUSE = 10, |
||
40 | BUTTON_PLAYBACK_PREV, |
||
41 | BUTTON_PLAYBACK_NEXT |
||
42 | }; |
||
43 | |||
44 | int player_run_id, |
||
45 | notify_run_id; |
||
46 | |||
5793 | leency | 47 | int current_playing_file_n=0; |
5465 | leency | 48 | |
5509 | leency | 49 | word win_x_normal, win_y_normal; |
50 | word win_x_small, win_y_small; |
||
5465 | leency | 51 | |
52 | byte window_mode; |
||
53 | enum { |
||
54 | WINDOW_MODE_NORMAL, |
||
55 | WINDOW_MODE_SMALL |
||
56 | }; |
||
57 | |||
58 | |||
59 | byte playback_mode; |
||
60 | enum { |
||
61 | PLAYBACK_MODE_STOPED, |
||
62 | PLAYBACK_MODE_PLAYING |
||
63 | }; |
||
64 | |||
5548 | leency | 65 | char work_folder[4096], |
66 | current_filename[256]; |
||
5465 | leency | 67 | |
5548 | leency | 68 | |
5465 | leency | 69 | #include "get_files_list.h" |
70 | #include "settings.h" |
||
71 | #include "check_default_player.h" |
||
72 | |||
73 | |||
5793 | leency | 74 | void OpenFolder(dword path111) |
75 | { |
||
76 | if (ESBYTE[path111]) |
||
77 | { |
||
78 | strcpy(#work_folder, path111); |
||
79 | work_folder[strrchr(#work_folder, '/')-1]='\0'; |
||
80 | OpenDirectory(#work_folder); |
||
81 | SetOpenedFileFirst(path111); |
||
82 | } |
||
83 | list.SetFont(6, 9, 10000000b); |
||
84 | list.SetSizes(1, skin.h, skin.w-1, 198, 18); |
||
85 | if (list.count <= list.visible) |
||
86 | { |
||
5825 | leency | 87 | list.h = list.count * list.item_h; |
5793 | leency | 88 | list.visible = list.count; |
89 | } |
||
90 | else |
||
91 | { |
||
92 | list.w -= scroll1.size_x; |
||
93 | } |
||
94 | MoveSize(OLD, OLD, OLD, skin.h + list.h); |
||
95 | list.KeyHome(); |
||
96 | current_playing_file_n=0; |
||
97 | StopPlayingMp3(); |
||
98 | StartPlayingMp3(); |
||
99 | } |
||
100 | |||
5465 | leency | 101 | void main() |
102 | { |
||
5705 | punk_joker | 103 | int id; |
104 | |||
5640 | pavelyakov | 105 | byte mouse_clicked; |
106 | dword tmp_x,tmp_y; |
||
107 | dword z1,z2; |
||
108 | |||
5465 | leency | 109 | mem_Init(); |
5626 | leency | 110 | load_dll(boxlib, #box_lib_init,0); |
5627 | leency | 111 | load_dll(libio, #libio_init,1); |
5626 | leency | 112 | load_dll(libimg, #libimg_init,1); |
113 | load_dll(libini, #lib_init,1); |
||
5793 | leency | 114 | load_dll(Proc_lib, #OpenDialog_init,0); |
115 | OpenDialog_init stdcall (#o_dialog); |
||
5465 | leency | 116 | |
117 | id = abspath("pixie.ini"); |
||
118 | strcpy(#pixie_ini_path, id); |
||
119 | LoadIniConfig(); |
||
120 | CheckDefaultForTheFirstStart(); |
||
5793 | leency | 121 | OpenFolder(#param); |
5789 | leency | 122 | SetEventMask(0100111b); |
5465 | leency | 123 | loop() |
124 | { |
||
5640 | pavelyakov | 125 | WaitEventTimeout(10); |
5465 | leency | 126 | switch(EAX & 0xFF) { |
127 | case evMouse: |
||
128 | if (!CheckActiveProcess(Form.ID)) break; |
||
5640 | pavelyakov | 129 | mouse.get(); |
5465 | leency | 130 | scrollbar_v_mouse (#scroll1); |
5640 | pavelyakov | 131 | if (list.first != scroll1.position) |
5465 | leency | 132 | { |
133 | list.first = scroll1.position; |
||
134 | DrawPlayList(); |
||
135 | break; |
||
136 | } |
||
5789 | leency | 137 | if (list.MouseOver(mouse.x, mouse.y)) |
5465 | leency | 138 | { |
5789 | leency | 139 | if (mouse.vert) if (list.MouseScroll(mouse.vert)) DrawPlayList(); |
5825 | leency | 140 | if (mouse.dblclick) {current_playing_file_n=list.cur_y; StartPlayingMp3();} |
5793 | leency | 141 | if (mouse.down) && (mouse.key&MOUSE_LEFT) if (list.ProcessMouse(mouse.x, mouse.y)) DrawPlayList(); |
5795 | leency | 142 | if (mouse.down) && (mouse.key&MOUSE_RIGHT) NotifyAndBackFocus(ABOUT_MESSAGE); |
5789 | leency | 143 | } |
144 | //drag window - emulate windows header |
||
145 | if(mouse.key&MOUSE_LEFT) && (mouse.y |
||
146 | { |
||
147 | tmp_x = mouse.x; |
||
148 | tmp_y = mouse.y; |
||
149 | do { |
||
150 | mouse.get(); |
||
151 | if (tmp_x!=mouse.x) || (tmp_y!=mouse.y) |
||
5465 | leency | 152 | { |
5789 | leency | 153 | z1 = Form.left + mouse.x - tmp_x; |
154 | z2 = Form.top + mouse.y - tmp_y; |
||
5796 | leency | 155 | if(z1<=10) || (z1>20000) z1=0; else if(z1>screen.width-Form.width-10)z1=screen.width-Form.width; |
156 | if(z2<=10) || (z2>20000) z2=0; else if(z2>screen.height-Form.height-10)z2=screen.height-Form.height; |
||
5789 | leency | 157 | MoveSize(z1 , z2, OLD, OLD); |
5793 | leency | 158 | draw_window(); |
5465 | leency | 159 | } |
5789 | leency | 160 | pause(1); |
161 | } while (mouse.lkm); |
||
5465 | leency | 162 | } |
5789 | leency | 163 | break; |
5465 | leency | 164 | case evButton: |
165 | id=GetButtonID(); |
||
166 | switch(id) { |
||
167 | case BUTTON_WINDOW_CLOSE: |
||
168 | StopPlayingMp3(); |
||
169 | SaveIniConfig(); |
||
170 | ExitProcess(); |
||
171 | break; |
||
172 | case BUTTON_WINDOW_MINIMIZE: |
||
173 | MinimizeWindow(); |
||
174 | break; |
||
175 | case BUTTON_WINDOW_REDUCE: |
||
176 | if (window_mode == WINDOW_MODE_NORMAL) |
||
177 | { |
||
178 | window_mode = WINDOW_MODE_SMALL; |
||
5509 | leency | 179 | win_x_normal = Form.left; |
180 | win_y_normal = Form.top; |
||
5465 | leency | 181 | MoveSize(OLD, OLD, 99, skin.h - 1); |
5509 | leency | 182 | MoveSize(OLD, win_y_small, OLD, OLD); |
183 | MoveSize(win_x_small, OLD, OLD, OLD); |
||
5465 | leency | 184 | } |
185 | else |
||
186 | { |
||
187 | window_mode = WINDOW_MODE_NORMAL; |
||
5509 | leency | 188 | win_x_small = Form.left; |
189 | win_y_small = Form.top; |
||
190 | MoveSize(win_x_normal, win_y_normal, skin.w -1 ,skin.h + list.h); |
||
5465 | leency | 191 | } |
192 | break; |
||
5795 | leency | 193 | case BUTTON_PLAYBACK_PREV: _PLAY_PREVIOUS: |
5793 | leency | 194 | current_playing_file_n--; |
195 | StartPlayingMp3(); |
||
5465 | leency | 196 | break; |
5795 | leency | 197 | case BUTTON_PLAYBACK_NEXT: _PLAY_NEXT: |
5793 | leency | 198 | current_playing_file_n++; |
199 | StartPlayingMp3(); |
||
5465 | leency | 200 | break; |
201 | case BUTTON_PLAYBACK_PLAY_PAUSE: |
||
5793 | leency | 202 | PlayAndPauseClick(); |
5465 | leency | 203 | break; |
204 | } |
||
5793 | leency | 205 | break; |
5465 | leency | 206 | case evKey: |
5795 | leency | 207 | GetKeys(); |
208 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
||
209 | if (key_scancode==SCAN_CODE_LEFT) goto _PLAY_PREVIOUS; |
||
210 | if (key_scancode==SCAN_CODE_RIGHT) goto _PLAY_NEXT; |
||
211 | break; |
||
212 | } |
||
5793 | leency | 213 | if (key_scancode==024) { OpenDialog_start stdcall (#o_dialog); if (o_dialog.status==1) OpenFolder(#openfile_path); } |
5789 | leency | 214 | if (key_scancode==059) SetColorThemeLight(); |
215 | if (key_scancode==060) SetColorThemeDark(); |
||
5705 | punk_joker | 216 | if (key_scancode==SCAN_CODE_LEFT) RunProgram("@VOLUME", "-"); |
217 | if (key_scancode==SCAN_CODE_RIGHT) RunProgram("@VOLUME", "+"); |
||
218 | if (key_scancode==050) RunProgram("@VOLUME", "m"); |
||
5825 | leency | 219 | if (key_scancode==SCAN_CODE_ENTER) { current_playing_file_n=list.cur_y; StartPlayingMp3(); } |
5793 | leency | 220 | if (key_scancode==025) || (key_scancode==SCAN_CODE_SPACE) PlayAndPauseClick(); |
5705 | punk_joker | 221 | if (list.ProcessKey(key_scancode)) DrawPlayList(); |
5465 | leency | 222 | break; |
223 | case evReDraw: |
||
5640 | pavelyakov | 224 | if (window_mode == WINDOW_MODE_NORMAL) DefineAndDrawWindow(win_x_normal, win_y_normal, skin.w - 1, skin.h + list.h, 0x41,0,0,0); |
225 | if (window_mode == WINDOW_MODE_SMALL) DefineAndDrawWindow(win_x_small, win_y_small, 99, skin.h - 1, 0x41,0,0,0); |
||
5793 | leency | 226 | draw_window(); |
5465 | leency | 227 | break; |
228 | default: |
||
5793 | leency | 229 | if (playback_mode == PLAYBACK_MODE_PLAYING) && (!GetProcessSlot(player_run_id)) |
5465 | leency | 230 | { |
5793 | leency | 231 | current_playing_file_n++; |
232 | StartPlayingMp3(); |
||
5465 | leency | 233 | } |
234 | } |
||
235 | } |
||
236 | } |
||
237 | |||
5793 | leency | 238 | void PlayAndPauseClick() |
239 | { |
||
240 | if (playback_mode == PLAYBACK_MODE_PLAYING) |
||
241 | { |
||
242 | playback_mode = PLAYBACK_MODE_STOPED; |
||
243 | StopPlayingMp3(); |
||
244 | } |
||
245 | else |
||
246 | { |
||
247 | playback_mode = PLAYBACK_MODE_PLAYING; |
||
248 | StartPlayingMp3(); |
||
249 | } |
||
250 | } |
||
5465 | leency | 251 | |
5793 | leency | 252 | |
5465 | leency | 253 | void DrawPlayList() |
254 | { |
||
255 | int i; |
||
256 | int yyy; |
||
5548 | leency | 257 | char temp_filename[4096]; |
5465 | leency | 258 | for (i=0; i |
259 | { |
||
260 | strcpy(#temp_filename, files_mas[i + list.first] * 304 + buf + 72); |
||
261 | temp_filename[strlen(#temp_filename)-4] = '\0'; |
||
262 | if (strlen(#temp_filename)>47) strcpy(#temp_filename+44, "..."); |
||
263 | |||
5825 | leency | 264 | yyy = i*list.item_h+list.y; |
5465 | leency | 265 | |
266 | //this is selected file |
||
5825 | leency | 267 | if (list.cur_y - list.first == i) |
5465 | leency | 268 | { |
269 | if (i>=list.count) continue; |
||
5825 | leency | 270 | DrawBar(list.x, yyy, list.w, list.item_h, theme.color_list_active_bg); |
5465 | leency | 271 | WriteText(12,yyy+list.text_y,0x80, theme.color_list_active_text, #temp_filename); |
272 | } |
||
273 | //this is not selected file |
||
274 | else |
||
275 | { |
||
276 | if (i>=list.count) continue; |
||
5825 | leency | 277 | DrawBar(list.x,yyy,list.w, list.item_h, theme.color_list_bg); |
5465 | leency | 278 | WriteText(12,yyy+list.text_y,0x80, theme.color_list_text, #temp_filename); |
279 | } |
||
5825 | leency | 280 | //this is cur_y playing file |
5465 | leency | 281 | if (i + list.first == current_playing_file_n) && (playback_mode == PLAYBACK_MODE_PLAYING) |
282 | { |
||
283 | WriteText(3, yyy+list.text_y,0x80, theme.color_list_active_pointer, "\x10"); |
||
284 | WriteText(12,yyy+list.text_y,0x80, theme.color_list_active_text, #temp_filename); |
||
285 | } |
||
286 | } |
||
5825 | leency | 287 | DrawBar(list.x,list.visible * list.item_h + list.y, list.w, -list.visible * list.item_h + list.h, theme.color_list_bg); |
5465 | leency | 288 | DrawScroller(); |
289 | } |
||
290 | |||
291 | |||
292 | void StopPlayingMp3() |
||
293 | { |
||
294 | if (player_run_id) player_run_id = KillProcess(player_run_id); |
||
295 | if (notify_run_id) notify_run_id = KillProcess(notify_run_id); |
||
296 | playback_mode = PLAYBACK_MODE_STOPED; |
||
5789 | leency | 297 | DrawTopPanel(); |
298 | DrawPlayList(); |
||
5465 | leency | 299 | } |
300 | |||
301 | |||
5793 | leency | 302 | int NotifyAndBackFocus(dword msg) |
303 | { |
||
304 | int nid; |
||
305 | nid = notify(msg); |
||
306 | pause(5); |
||
307 | Form.num_slot = GetProcessSlot(Form.ID); |
||
308 | if (Form.ID) ActivateWindow(Form.num_slot); |
||
309 | return nid; |
||
310 | } |
||
311 | |||
312 | |||
5465 | leency | 313 | void StartPlayingMp3() |
314 | { |
||
315 | word i; |
||
5793 | leency | 316 | char item_path[4096]; |
317 | char notify_message[512]; |
||
5465 | leency | 318 | StopPlayingMp3(); |
6152 | leency | 319 | if (!list.count) { NotifyAndBackFocus("'Pixie Player\nPress O key to open MP3 file' -St"); return; } |
5793 | leency | 320 | if (current_playing_file_n > list.count) { current_playing_file_n = list.count; return; } |
321 | if (current_playing_file_n < 0) { current_playing_file_n = 0; return; } |
||
5465 | leency | 322 | playback_mode = PLAYBACK_MODE_PLAYING; |
5825 | leency | 323 | strlcpy(#current_filename, Getcur_yItemName(), sizeof(current_filename)); |
5793 | leency | 324 | sprintf(#item_path,"\"%s/%s\"",#work_folder,#current_filename); |
5465 | leency | 325 | DrawPlayList(); |
326 | DrawTopPanel(); |
||
5793 | leency | 327 | if (strcmpi(#item_path+strlen(#item_path)-4,".mp3")) player_run_id = RunProgram(abspath("minimp3"), #item_path); |
328 | sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename); |
||
329 | for (i=2; i |
||
330 | notify_run_id = NotifyAndBackFocus(#notify_message); |
||
5465 | leency | 331 | } |
332 | |||
333 | |||
5793 | leency | 334 | void draw_window() { |
5465 | leency | 335 | GetProcessInfo(#Form, SelfInfo); |
336 | DrawTopPanel(); |
||
337 | IF (Form.status_window>=2) return; |
||
338 | if (window_mode == WINDOW_MODE_NORMAL) |
||
339 | { |
||
340 | DrawListBorder(0, skin.h-1, skin.w-1, list.h+1, theme.color_list_border); |
||
341 | DrawPlayList(); |
||
342 | } |
||
343 | } |
||
344 | |||
345 | void DrawTopPanel() |
||
346 | { |
||
5825 | leency | 347 | char cur_y_playing_title[245]; |
5465 | leency | 348 | img_draw stdcall(skin.image, 0, 0, Form.width - 14, skin.h, 0, 0); |
349 | img_draw stdcall(skin.image, Form.width - 14, 0, 15, skin.h, skin.w - 15, 0); |
||
5793 | leency | 350 | if (playback_mode == PLAYBACK_MODE_STOPED) img_draw stdcall(skin.image, 13, 0, 22, skin.h, 300, 0); |
5465 | leency | 351 | //Playing control buttons |
352 | DefineButton(13, 1, 21, 21, BUTTON_PLAYBACK_PLAY_PAUSE + BT_HIDE, 0); |
||
353 | DefineButton(36, 1, 21, 21, BUTTON_PLAYBACK_PREV + BT_HIDE, 0); |
||
354 | DefineButton(60, 1, 21, 21, BUTTON_PLAYBACK_NEXT + BT_HIDE, 0); |
||
355 | //Window control buttons |
||
356 | DefineButton(Form.width - 14, 1, 11, 11, BUTTON_WINDOW_CLOSE + BT_HIDE, 0); |
||
357 | DefineButton(Form.width - 14, 12, 12, 11, BUTTON_WINDOW_REDUCE + BT_HIDE, 0); |
||
358 | //Mode depended |
||
359 | if (window_mode == WINDOW_MODE_NORMAL) |
||
360 | { |
||
361 | DefineButton(Form.width - 26, 1, 12, 11, BUTTON_WINDOW_MINIMIZE + BT_HIDE, 0); |
||
5825 | leency | 362 | strcpy(#cur_y_playing_title, #current_filename); |
363 | cur_y_playing_title[strlen(#cur_y_playing_title)-4] = '\0'; |
||
364 | if (strlen(#cur_y_playing_title) > 29) strcpy(#cur_y_playing_title + 26, "..."); |
||
365 | WriteText(90, 9, 0x80, theme.color_top_panel_text, #cur_y_playing_title); |
||
5465 | leency | 366 | } |
367 | else |
||
368 | { |
||
369 | DefineButton(0, 0, 12, skin.h, 99 + BT_HIDE + BT_NOFRAME, 0); |
||
370 | } |
||
371 | } |
||
372 | |||
373 | |||
374 | void DrawScroller() |
||
375 | { |
||
376 | scroll1.max_area = list.count; |
||
377 | scroll1.cur_area = list.visible; |
||
378 | scroll1.position = list.first; |
||
379 | scroll1.all_redraw = 0; |
||
380 | scroll1.start_x = skin.w - scroll1.size_x - 1; |
||
381 | scroll1.start_y = list.y-1; |
||
382 | scroll1.size_y = list.h+2; |
||
383 | if (list.count > list.visible) scrollbar_v_draw(#scroll1); |
||
384 | } |
||
385 | |||
386 | void DrawListBorder(dword x,y,w,h,color1) |
||
387 | { |
||
388 | DrawBar(x,y+h,w,1,color1); |
||
389 | DrawBar(x,y,1,h,color1); |
||
390 | DrawBar(x+w,y,1,h+1,color1); |
||
391 | } |
||
392 | |||
393 | |||
394 | stop: |
||
395 | |||
396 | char menu_stak[4096];>=10)>=10)>>=> |