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