Rev 7049 | Rev 7177 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7049 | Rev 7051 | ||
---|---|---|---|
1 | //TODO |
1 | //TODO |
2 | //repeat track |
2 | //repeat track |
3 | //edit list manually |
3 | //edit list manually |
4 | 4 | ||
5 | #define MEMSIZE 4096 * 50 |
5 | #define MEMSIZE 4096 * 50 |
6 | 6 | ||
7 | //===================================================// |
7 | //===================================================// |
8 | // // |
8 | // // |
9 | // LIB // |
9 | // LIB // |
10 | // // |
10 | // // |
11 | //===================================================// |
11 | //===================================================// |
12 | 12 | ||
13 | #include "../lib/file_system.h" |
13 | #include "../lib/file_system.h" |
14 | #include "../lib/list_box.h" |
14 | #include "../lib/list_box.h" |
15 | #include "../lib/gui.h" |
15 | #include "../lib/gui.h" |
16 | 16 | ||
17 | #include "../lib/obj/box_lib.h" |
17 | #include "../lib/obj/box_lib.h" |
18 | #include "../lib/obj/libio.h" |
18 | #include "../lib/obj/libio.h" |
19 | #include "../lib/obj/libimg.h" |
19 | #include "../lib/obj/libimg.h" |
20 | #include "../lib/obj/libini.h" |
20 | #include "../lib/obj/libini.h" |
21 | 21 | ||
22 | #include "../lib/patterns/libimg_load_skin.h" |
22 | #include "../lib/patterns/libimg_load_skin.h" |
23 | 23 | ||
24 | #include "../lib/obj/proc_lib.h" |
24 | #include "../lib/obj/proc_lib.h" |
25 | #include "../lib/patterns/simple_open_dialog.h" |
25 | #include "../lib/patterns/simple_open_dialog.h" |
26 | 26 | ||
27 | //===================================================// |
27 | //===================================================// |
28 | // // |
28 | // // |
29 | // DATA // |
29 | // DATA // |
30 | // // |
30 | // // |
31 | //===================================================// |
31 | //===================================================// |
32 | 32 | ||
33 | //simple open dialog data |
33 | //simple open dialog data |
34 | char default_dir[] = "/rd/1"; |
34 | char default_dir[] = "/rd/1"; |
35 | od_filter filter2 = { "MP3", 0 }; |
35 | od_filter filter2 = { 8, "MP3\0\0" }; |
36 | 36 | ||
37 | #define ABOUT_MESSAGE "'Pixies Player v2.0 |
37 | #define ABOUT_MESSAGE "'Pixies Player v2.0 |
38 | A tiny MP3 folder player. |
38 | A tiny MP3 folder player. |
39 | 39 | ||
40 | Controls: |
40 | Controls: |
41 | Open file: O key |
41 | Open file: O key |
42 | Play/Stop: Space or P key |
42 | Play/Stop: Space or P key |
43 | Start playing selected file: Enter |
43 | Start playing selected file: Enter |
44 | Goto next/previous track: Ctrl + Left/Right |
44 | Goto next/previous track: Ctrl + Left/Right |
45 | Change sound volume: Left/Right key |
45 | Change sound volume: Left/Right key |
46 | Mute: M key' -Std" |
46 | Mute: M key' -Std" |
47 | #define WIN_W_SMALL 127 |
47 | #define WIN_W_SMALL 127 |
48 | #define WIN_H_SMALL 39 |
48 | #define WIN_H_SMALL 39 |
49 | 49 | ||
50 | 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}; |
50 | 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}; |
51 | 51 | ||
52 | proc_info Form; |
52 | proc_info Form; |
53 | llist list; |
53 | llist list; |
54 | 54 | ||
55 | char pixie_ini_path[4096]; |
55 | char pixie_ini_path[4096]; |
56 | char work_folder[4096]; |
56 | char work_folder[4096]; |
57 | char current_filename[256]; |
57 | char current_filename[256]; |
58 | 58 | ||
59 | enum { |
59 | enum { |
60 | BUTTON_WINDOW_CLOSE = 1, |
60 | BUTTON_WINDOW_CLOSE = 1, |
61 | BUTTON_WINDOW_MINIMIZE, |
61 | BUTTON_WINDOW_MINIMIZE, |
62 | BUTTON_WINDOW_REDUCE, |
62 | BUTTON_WINDOW_REDUCE, |
63 | BUTTON_PLAYBACK_PLAY_PAUSE = 10, |
63 | BUTTON_PLAYBACK_PLAY_PAUSE = 10, |
64 | BUTTON_PLAYBACK_PREV, |
64 | BUTTON_PLAYBACK_PREV, |
65 | BUTTON_PLAYBACK_NEXT, |
65 | BUTTON_PLAYBACK_NEXT, |
66 | BUTTON_OPEN_DIALOG, |
66 | BUTTON_OPEN_DIALOG, |
67 | BUTTON_SHOW_VOLUME |
67 | BUTTON_SHOW_VOLUME |
68 | }; |
68 | }; |
69 | 69 | ||
70 | int player_run_id; |
70 | int player_run_id; |
71 | int notify_run_id; |
71 | int notify_run_id; |
72 | 72 | ||
73 | int current_playing_file_n=0; |
73 | int current_playing_file_n=0; |
74 | 74 | ||
75 | word win_x_normal, win_y_normal; |
75 | word win_x_normal, win_y_normal; |
76 | word win_x_small, win_y_small; |
76 | word win_x_small, win_y_small; |
77 | 77 | ||
78 | byte window_mode; |
78 | byte window_mode; |
79 | enum { |
79 | enum { |
80 | WINDOW_MODE_NORMAL, |
80 | WINDOW_MODE_NORMAL, |
81 | WINDOW_MODE_SMALL |
81 | WINDOW_MODE_SMALL |
82 | }; |
82 | }; |
83 | 83 | ||
84 | byte playback_mode; |
84 | byte playback_mode; |
85 | enum { |
85 | enum { |
86 | PLAYBACK_MODE_STOPED, |
86 | PLAYBACK_MODE_STOPED, |
87 | PLAYBACK_MODE_PLAYING |
87 | PLAYBACK_MODE_PLAYING |
88 | }; |
88 | }; |
89 | 89 | ||
90 | //===================================================// |
90 | //===================================================// |
91 | // // |
91 | // // |
92 | // CODE // |
92 | // CODE // |
93 | // // |
93 | // // |
94 | //===================================================// |
94 | //===================================================// |
95 | 95 | ||
96 | #include "get_files_list.h" |
96 | #include "get_files_list.h" |
97 | #include "settings.h" |
97 | #include "settings.h" |
98 | 98 | ||
99 | void LoadLibraries() |
99 | void LoadLibraries() |
100 | { |
100 | { |
101 | load_dll(boxlib, #box_lib_init,0); |
101 | load_dll(boxlib, #box_lib_init,0); |
102 | load_dll(libio, #libio_init,1); |
102 | load_dll(libio, #libio_init,1); |
103 | load_dll(libimg, #libimg_init,1); |
103 | load_dll(libimg, #libimg_init,1); |
104 | load_dll(libini, #lib_init,1); |
104 | load_dll(libini, #lib_init,1); |
105 | load_dll(Proc_lib, #OpenDialog_init,0); |
105 | load_dll(Proc_lib, #OpenDialog_init,0); |
106 | OpenDialog_init stdcall (#o_dialog); |
106 | OpenDialog_init stdcall (#o_dialog); |
107 | } |
107 | } |
108 | 108 | ||
109 | void main() |
109 | void main() |
110 | { |
110 | { |
111 | int tempstr; |
111 | int tempstr; |
112 | tempstr = abspath("pixie.ini"); |
112 | tempstr = abspath("pixie.ini"); |
113 | strcpy(#pixie_ini_path, tempstr); |
113 | strcpy(#pixie_ini_path, tempstr); |
114 | list.SetFont(8, 14, 0x90); |
114 | list.SetFont(8, 14, 0x90); |
115 | if (!param) notify("'Pixie Player\nPress O key to open MP3 file' -St"); |
115 | if (!param) notify("'Pixie Player\nPress O key to open MP3 file' -St"); |
116 | LoadLibraries(); |
116 | LoadLibraries(); |
117 | LoadIniConfig(); |
117 | LoadIniConfig(); |
118 | SetEventMask(0100111b); |
118 | SetEventMask(0100111b); |
119 | loop() |
119 | loop() |
120 | { |
120 | { |
121 | WaitEventTimeout(10); |
121 | WaitEventTimeout(10); |
122 | switch(EAX & 0xFF) { |
122 | switch(EAX & 0xFF) { |
123 | case evMouse: |
123 | case evMouse: |
124 | if (!CheckActiveProcess(Form.ID)) break; |
124 | if (!CheckActiveProcess(Form.ID)) break; |
125 | mouse.get(); |
125 | mouse.get(); |
126 | scrollbar_v_mouse (#scroll1); |
126 | scrollbar_v_mouse (#scroll1); |
127 | if (list.first != scroll1.position) |
127 | if (list.first != scroll1.position) |
128 | { |
128 | { |
129 | list.first = scroll1.position; |
129 | list.first = scroll1.position; |
130 | DrawPlayList(); |
130 | DrawPlayList(); |
131 | break; |
131 | break; |
132 | } |
132 | } |
133 | if (list.MouseOver(mouse.x, mouse.y)) |
133 | if (list.MouseOver(mouse.x, mouse.y)) |
134 | { |
134 | { |
135 | if (mouse.vert) && (list.MouseScroll(mouse.vert)) DrawPlayList(); |
135 | if (mouse.vert) && (list.MouseScroll(mouse.vert)) DrawPlayList(); |
136 | if (mouse.dblclick) EventStartPlayingSelectedItem(); |
136 | if (mouse.dblclick) EventStartPlayingSelectedItem(); |
137 | if (mouse.down) && (mouse.key&MOUSE_LEFT) && (list.ProcessMouse(mouse.x, mouse.y)) DrawPlayList(); |
137 | if (mouse.down) && (mouse.key&MOUSE_LEFT) && (list.ProcessMouse(mouse.x, mouse.y)) DrawPlayList(); |
138 | if (mouse.down) && (mouse.key&MOUSE_RIGHT) notify(ABOUT_MESSAGE); |
138 | if (mouse.down) && (mouse.key&MOUSE_RIGHT) notify(ABOUT_MESSAGE); |
139 | } |
139 | } |
140 | if(mouse.key&MOUSE_LEFT) && (mouse.y |
140 | if(mouse.key&MOUSE_LEFT) && (mouse.y |
141 | break; |
141 | break; |
142 | case evButton: |
142 | case evButton: |
143 | switch(GetButtonID()) { |
143 | switch(GetButtonID()) { |
144 | case BUTTON_WINDOW_CLOSE: EventExitApp(); break; |
144 | case BUTTON_WINDOW_CLOSE: EventExitApp(); break; |
145 | case BUTTON_WINDOW_MINIMIZE: MinimizeWindow(); break; |
145 | case BUTTON_WINDOW_MINIMIZE: MinimizeWindow(); break; |
146 | case BUTTON_WINDOW_REDUCE: EventChangeWindowMode(); break; |
146 | case BUTTON_WINDOW_REDUCE: EventChangeWindowMode(); break; |
147 | case BUTTON_PLAYBACK_PREV: EventPlaybackPrevious(); break; |
147 | case BUTTON_PLAYBACK_PREV: EventPlaybackPrevious(); break; |
148 | case BUTTON_PLAYBACK_NEXT: EventPlaybackNext(); break; |
148 | case BUTTON_PLAYBACK_NEXT: EventPlaybackNext(); break; |
149 | case BUTTON_PLAYBACK_PLAY_PAUSE: EventPlayAndPause(); break; |
149 | case BUTTON_PLAYBACK_PLAY_PAUSE: EventPlayAndPause(); break; |
150 | case BUTTON_OPEN_DIALOG: EventFileDialogOpen(); break; |
150 | case BUTTON_OPEN_DIALOG: EventFileDialogOpen(); break; |
151 | case BUTTON_SHOW_VOLUME: RunProgram("/sys/@VOLUME", NULL); break; |
151 | case BUTTON_SHOW_VOLUME: RunProgram("/sys/@VOLUME", NULL); break; |
152 | } |
152 | } |
153 | break; |
153 | break; |
154 | case evKey: |
154 | case evKey: |
155 | GetKeys(); |
155 | GetKeys(); |
156 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
156 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
157 | if (key_scancode==SCAN_CODE_LEFT) EventPlaybackPrevious(); |
157 | if (key_scancode==SCAN_CODE_LEFT) EventPlaybackPrevious(); |
158 | if (key_scancode==SCAN_CODE_RIGHT) EventPlaybackNext(); |
158 | if (key_scancode==SCAN_CODE_RIGHT) EventPlaybackNext(); |
159 | break; |
159 | break; |
160 | } |
160 | } |
161 | if (key_scancode==SCAN_CODE_KEY_O) EventFileDialogOpen(); |
161 | if (key_scancode==SCAN_CODE_KEY_O) EventFileDialogOpen(); |
162 | if (key_scancode==SCAN_CODE_KEY_M) RunProgram("/sys/@VOLUME", "m"); |
162 | if (key_scancode==SCAN_CODE_KEY_M) RunProgram("/sys/@VOLUME", "m"); |
163 | if (key_scancode==SCAN_CODE_RIGHT) RunProgram("/sys/@VOLUME", "+"); |
163 | if (key_scancode==SCAN_CODE_RIGHT) RunProgram("/sys/@VOLUME", "+"); |
164 | if (key_scancode==SCAN_CODE_LEFT) RunProgram("/sys/@VOLUME", "-"); |
164 | if (key_scancode==SCAN_CODE_LEFT) RunProgram("/sys/@VOLUME", "-"); |
165 | if (key_scancode==SCAN_CODE_ENTER) EventStartPlayingSelectedItem(); |
165 | if (key_scancode==SCAN_CODE_ENTER) EventStartPlayingSelectedItem(); |
166 | if (key_scancode==SCAN_CODE_KEY_P) || (key_scancode==SCAN_CODE_SPACE) EventPlayAndPause(); |
166 | if (key_scancode==SCAN_CODE_KEY_P) || (key_scancode==SCAN_CODE_SPACE) EventPlayAndPause(); |
167 | if (list.ProcessKey(key_scancode)) DrawPlayList(); |
167 | if (list.ProcessKey(key_scancode)) DrawPlayList(); |
168 | break; |
168 | break; |
169 | case evReDraw: |
169 | case evReDraw: |
170 | if (window_mode == WINDOW_MODE_NORMAL) DefineDragableWindow(win_x_normal, win_y_normal, skin.w - 1, skin.h + list.h); |
170 | if (window_mode == WINDOW_MODE_NORMAL) DefineDragableWindow(win_x_normal, win_y_normal, skin.w - 1, skin.h + list.h); |
171 | if (window_mode == WINDOW_MODE_SMALL) DefineDragableWindow(win_x_small, win_y_small, WIN_W_SMALL, WIN_H_SMALL); |
171 | if (window_mode == WINDOW_MODE_SMALL) DefineDragableWindow(win_x_small, win_y_small, WIN_W_SMALL, WIN_H_SMALL); |
172 | draw_window(); |
172 | draw_window(); |
173 | if (param[0]) { |
173 | if (param[0]) { |
174 | EventOpenFolder(#param); |
174 | EventOpenFolder(#param); |
175 | param[0] = NULL; |
175 | param[0] = NULL; |
176 | } |
176 | } |
177 | break; |
177 | break; |
178 | default: |
178 | default: |
179 | EventCheckSongFinished(); |
179 | EventCheckSongFinished(); |
180 | } |
180 | } |
181 | } |
181 | } |
182 | } |
182 | } |
183 | 183 | ||
184 | 184 | ||
185 | void DrawPlayList() |
185 | void DrawPlayList() |
186 | { |
186 | { |
187 | int i; |
187 | int i; |
188 | int yyy; |
188 | int yyy; |
189 | char temp_filename[4096]; |
189 | char temp_filename[4096]; |
190 | for (i=0; i |
190 | for (i=0; i |
191 | { |
191 | { |
192 | strcpy(#temp_filename, files_mas[i + list.first] * 304 + buf + 72); |
192 | strcpy(#temp_filename, files_mas[i + list.first] * 304 + buf + 72); |
193 | temp_filename[strlen(#temp_filename)-4] = '\0'; |
193 | temp_filename[strlen(#temp_filename)-4] = '\0'; |
194 | if (strlen(#temp_filename)>47) strcpy(#temp_filename+44, "..."); |
194 | if (strlen(#temp_filename)>47) strcpy(#temp_filename+44, "..."); |
195 | 195 | ||
196 | yyy = i*list.item_h+list.y; |
196 | yyy = i*list.item_h+list.y; |
197 | 197 | ||
198 | //this is selected file |
198 | //this is selected file |
199 | if (list.cur_y - list.first == i) |
199 | if (list.cur_y - list.first == i) |
200 | { |
200 | { |
201 | if (i>=list.count) continue; |
201 | if (i>=list.count) continue; |
202 | DrawBar(list.x, yyy, list.w, list.item_h, theme.color_list_active_bg); |
202 | DrawBar(list.x, yyy, list.w, list.item_h, theme.color_list_active_bg); |
203 | WriteText(12,yyy+list.text_y,list.font_type, theme.color_list_active_text, #temp_filename); |
203 | WriteText(12,yyy+list.text_y,list.font_type, theme.color_list_active_text, #temp_filename); |
204 | } |
204 | } |
205 | //this is not selected file |
205 | //this is not selected file |
206 | else |
206 | else |
207 | { |
207 | { |
208 | if (i>=list.count) continue; |
208 | if (i>=list.count) continue; |
209 | DrawBar(list.x,yyy,list.w, list.item_h, theme.color_list_bg); |
209 | DrawBar(list.x,yyy,list.w, list.item_h, theme.color_list_bg); |
210 | WriteText(12,yyy+list.text_y,list.font_type, theme.color_list_text, #temp_filename); |
210 | WriteText(12,yyy+list.text_y,list.font_type, theme.color_list_text, #temp_filename); |
211 | } |
211 | } |
212 | //this is cur_y playing file |
212 | //this is cur_y playing file |
213 | if (i + list.first == current_playing_file_n) && (playback_mode == PLAYBACK_MODE_PLAYING) |
213 | if (i + list.first == current_playing_file_n) && (playback_mode == PLAYBACK_MODE_PLAYING) |
214 | { |
214 | { |
215 | WriteText(3, yyy+list.text_y+3,0x80, theme.color_list_active_pointer, "\x10"); |
215 | WriteText(3, yyy+list.text_y+3,0x80, theme.color_list_active_pointer, "\x10"); |
216 | WriteText(12,yyy+list.text_y,list.font_type, theme.color_list_active_text, #temp_filename); |
216 | WriteText(12,yyy+list.text_y,list.font_type, theme.color_list_active_text, #temp_filename); |
217 | } |
217 | } |
218 | } |
218 | } |
219 | DrawBar(list.x,list.visible * list.item_h + list.y, list.w, -list.visible * list.item_h + list.h, theme.color_list_bg); |
219 | DrawBar(list.x,list.visible * list.item_h + list.y, list.w, -list.visible * list.item_h + list.h, theme.color_list_bg); |
220 | DrawScroller(); |
220 | DrawScroller(); |
221 | } |
221 | } |
222 | 222 | ||
223 | 223 | ||
224 | void draw_window() { |
224 | void draw_window() { |
225 | GetProcessInfo(#Form, SelfInfo); |
225 | GetProcessInfo(#Form, SelfInfo); |
226 | DrawTopPanel(); |
226 | DrawTopPanel(); |
227 | IF (Form.status_window>=2) return; |
227 | IF (Form.status_window>=2) return; |
228 | if (window_mode == WINDOW_MODE_NORMAL) |
228 | if (window_mode == WINDOW_MODE_NORMAL) |
229 | { |
229 | { |
230 | DrawPlayList(); |
230 | DrawPlayList(); |
231 | DrawRectangle(0, skin.h-1, skin.w-1, list.h+1, theme.color_list_border); |
231 | DrawRectangle(0, skin.h-1, skin.w-1, list.h+1, theme.color_list_border); |
232 | } |
232 | } |
233 | } |
233 | } |
234 | 234 | ||
235 | 235 | ||
236 | void DrawTopPanel() |
236 | void DrawTopPanel() |
237 | { |
237 | { |
238 | char cur_y_playing_title[245]; |
238 | char cur_y_playing_title[245]; |
239 | int button_y; |
239 | int button_y; |
240 | //if (playback_mode == PLAYBACK_MODE_STOPED) img_draw stdcall(skin.image, 13, 0, 22, skin.h, 300, 0); |
240 | //if (playback_mode == PLAYBACK_MODE_STOPED) img_draw stdcall(skin.image, 13, 0, 22, skin.h, 300, 0); |
241 | //Mode depended |
241 | //Mode depended |
242 | if (window_mode == WINDOW_MODE_NORMAL) |
242 | if (window_mode == WINDOW_MODE_NORMAL) |
243 | { |
243 | { |
244 | img_draw stdcall(skin.image, 0, 0, skin.w, skin.h, 0, 0); |
244 | img_draw stdcall(skin.image, 0, 0, skin.w, skin.h, 0, 0); |
245 | strcpy(#cur_y_playing_title, #current_filename); |
245 | strcpy(#cur_y_playing_title, #current_filename); |
246 | cur_y_playing_title[strlen(#cur_y_playing_title)-4] = '\0'; |
246 | cur_y_playing_title[strlen(#cur_y_playing_title)-4] = '\0'; |
247 | if (strlen(#cur_y_playing_title) > 36) strcpy(#cur_y_playing_title + 33, "..."); |
247 | if (strlen(#cur_y_playing_title) > 36) strcpy(#cur_y_playing_title + 33, "..."); |
248 | DrawPixieTitle(#work_folder + strrchr(#work_folder, '/')); |
248 | DrawPixieTitle(#work_folder + strrchr(#work_folder, '/')); |
249 | WriteText(10, 26, list.font_type, theme.color_top_panel_text, #cur_y_playing_title); |
249 | WriteText(10, 26, list.font_type, theme.color_top_panel_text, #cur_y_playing_title); |
250 | button_y = 45; |
250 | button_y = 45; |
251 | DefineHiddenButton(Form.width - 56, button_y, 23, 23, BUTTON_OPEN_DIALOG); |
251 | DefineHiddenButton(Form.width - 56, button_y, 23, 23, BUTTON_OPEN_DIALOG); |
252 | DefineHiddenButton(Form.width - 27, button_y, 23, 23, BUTTON_SHOW_VOLUME); |
252 | DefineHiddenButton(Form.width - 27, button_y, 23, 23, BUTTON_SHOW_VOLUME); |
253 | } |
253 | } |
254 | else if (window_mode == WINDOW_MODE_SMALL) |
254 | else if (window_mode == WINDOW_MODE_SMALL) |
255 | { |
255 | { |
256 | img_draw stdcall(skin.image, 0, 0, WIN_W_SMALL, WIN_H_SMALL, skin.w-1, 0); |
256 | img_draw stdcall(skin.image, 0, 0, WIN_W_SMALL, WIN_H_SMALL, skin.w-1, 0); |
257 | DefineHiddenButton(0, 0, WIN_W_SMALL, WIN_H_SMALL, 99 + BT_NOFRAME); |
257 | DefineHiddenButton(0, 0, WIN_W_SMALL, WIN_H_SMALL, 99 + BT_NOFRAME); |
258 | button_y = 9; |
258 | button_y = 9; |
259 | } |
259 | } |
260 | if (!list.count) DrawPixieTitle("Pixie"); |
260 | if (!list.count) DrawPixieTitle("Pixie"); |
261 | //Playing control buttons |
261 | //Playing control buttons |
262 | DefineHiddenButton(5, button_y, 23, 23, BUTTON_PLAYBACK_PREV); |
262 | DefineHiddenButton(5, button_y, 23, 23, BUTTON_PLAYBACK_PREV); |
263 | DefineHiddenButton(34, button_y-2, 27, 25, BUTTON_PLAYBACK_PLAY_PAUSE); |
263 | DefineHiddenButton(34, button_y-2, 27, 25, BUTTON_PLAYBACK_PLAY_PAUSE); |
264 | DefineHiddenButton(65, button_y, 23, 23, BUTTON_PLAYBACK_NEXT); |
264 | DefineHiddenButton(65, button_y, 23, 23, BUTTON_PLAYBACK_NEXT); |
265 | //Window control buttons |
265 | //Window control buttons |
266 | DefineHiddenButton(Form.width - 18, 1, 15, 15, BUTTON_WINDOW_CLOSE); |
266 | DefineHiddenButton(Form.width - 18, 1, 15, 15, BUTTON_WINDOW_CLOSE); |
267 | DefineHiddenButton(Form.width - 18, 16, 15, 15, BUTTON_WINDOW_REDUCE); |
267 | DefineHiddenButton(Form.width - 18, 16, 15, 15, BUTTON_WINDOW_REDUCE); |
268 | DefineHiddenButton(Form.width - 32, 1, 15, 15, BUTTON_WINDOW_MINIMIZE); |
268 | DefineHiddenButton(Form.width - 32, 1, 15, 15, BUTTON_WINDOW_MINIMIZE); |
269 | } |
269 | } |
270 | 270 | ||
271 | 271 | ||
272 | void DrawScroller() |
272 | void DrawScroller() |
273 | { |
273 | { |
274 | scroll1.max_area = list.count; |
274 | scroll1.max_area = list.count; |
275 | scroll1.cur_area = list.visible; |
275 | scroll1.cur_area = list.visible; |
276 | scroll1.position = list.first; |
276 | scroll1.position = list.first; |
277 | scroll1.all_redraw = 0; |
277 | scroll1.all_redraw = 0; |
278 | scroll1.start_x = skin.w - scroll1.size_x-1; |
278 | scroll1.start_x = skin.w - scroll1.size_x-1; |
279 | scroll1.start_y = list.y-1; |
279 | scroll1.start_y = list.y-1; |
280 | scroll1.size_y = list.h+2; |
280 | scroll1.size_y = list.h+2; |
281 | if (list.count > list.visible) scrollbar_v_draw(#scroll1); |
281 | if (list.count > list.visible) scrollbar_v_draw(#scroll1); |
282 | } |
282 | } |
283 | 283 | ||
284 | void DrawPixieTitle(dword _title) |
284 | void DrawPixieTitle(dword _title) |
285 | { |
285 | { |
286 | WriteTextB(10, 6, list.font_type, theme.color_top_panel_text, _title); |
286 | WriteTextB(10, 6, list.font_type, theme.color_top_panel_text, _title); |
287 | } |
287 | } |
288 | 288 | ||
289 | //===================================================// |
289 | //===================================================// |
290 | // // |
290 | // // |
291 | // EVENTS // |
291 | // EVENTS // |
292 | // // |
292 | // // |
293 | //===================================================// |
293 | //===================================================// |
294 | 294 | ||
295 | 295 | ||
296 | void EventOpenFolder(dword _open_path) |
296 | void EventOpenFolder(dword _open_path) |
297 | { |
297 | { |
298 | if (ESBYTE[_open_path]) |
298 | if (ESBYTE[_open_path]) |
299 | { |
299 | { |
300 | strcpy(#work_folder, _open_path); |
300 | strcpy(#work_folder, _open_path); |
301 | work_folder[strrchr(#work_folder, '/')-1]='\0'; |
301 | work_folder[strrchr(#work_folder, '/')-1]='\0'; |
302 | OpenDirectory(#work_folder); |
302 | OpenDirectory(#work_folder); |
303 | SetOpenedFileFirst(_open_path); |
303 | SetOpenedFileFirst(_open_path); |
304 | } |
304 | } |
305 | list.SetSizes(1, skin.h, skin.w-1, 22*15, 22); |
305 | list.SetSizes(1, skin.h, skin.w-1, 22*15, 22); |
306 | if (list.count <= list.visible) |
306 | if (list.count <= list.visible) |
307 | { |
307 | { |
308 | list.h = list.count * list.item_h; |
308 | list.h = list.count * list.item_h; |
309 | list.visible = list.count; |
309 | list.visible = list.count; |
310 | list.w -= 1; |
310 | list.w -= 1; |
311 | } |
311 | } |
312 | else |
312 | else |
313 | { |
313 | { |
314 | list.w -= scroll1.size_x; |
314 | list.w -= scroll1.size_x; |
315 | } |
315 | } |
316 | MoveSize(OLD, OLD, OLD, skin.h + list.h); |
316 | MoveSize(OLD, OLD, OLD, skin.h + list.h); |
317 | list.KeyHome(); |
317 | list.KeyHome(); |
318 | current_playing_file_n=0; |
318 | current_playing_file_n=0; |
319 | EventStopPlayingMp3(); |
319 | EventStopPlayingMp3(); |
320 | EventStartPlayingMp3(); |
320 | EventStartPlayingMp3(); |
321 | } |
321 | } |
322 | 322 | ||
323 | 323 | ||
324 | void EventStopPlayingMp3() |
324 | void EventStopPlayingMp3() |
325 | { |
325 | { |
326 | if (player_run_id) player_run_id = KillProcess(player_run_id); |
326 | if (player_run_id) player_run_id = KillProcess(player_run_id); |
327 | if (notify_run_id) notify_run_id = KillProcess(notify_run_id); |
327 | if (notify_run_id) notify_run_id = KillProcess(notify_run_id); |
328 | playback_mode = PLAYBACK_MODE_STOPED; |
328 | playback_mode = PLAYBACK_MODE_STOPED; |
329 | DrawTopPanel(); |
329 | DrawTopPanel(); |
330 | DrawPlayList(); |
330 | DrawPlayList(); |
331 | } |
331 | } |
332 | 332 | ||
333 | 333 | ||
334 | void EventStartPlayingMp3() |
334 | void EventStartPlayingMp3() |
335 | { |
335 | { |
336 | word i; |
336 | word i; |
337 | char item_path[4096]; |
337 | char item_path[4096]; |
338 | char notify_message[512]; |
338 | char notify_message[512]; |
339 | EventStopPlayingMp3(); |
339 | EventStopPlayingMp3(); |
340 | if (current_playing_file_n > list.count) { |
340 | if (current_playing_file_n > list.count) { |
341 | current_playing_file_n = list.count; |
341 | current_playing_file_n = list.count; |
342 | return; |
342 | return; |
343 | } |
343 | } |
344 | if (current_playing_file_n < 0) { |
344 | if (current_playing_file_n < 0) { |
345 | current_playing_file_n = 0; |
345 | current_playing_file_n = 0; |
346 | return; |
346 | return; |
347 | } |
347 | } |
348 | playback_mode = PLAYBACK_MODE_PLAYING; |
348 | playback_mode = PLAYBACK_MODE_PLAYING; |
349 | strlcpy(#current_filename, Getcur_yItemName(), sizeof(current_filename)); |
349 | strlcpy(#current_filename, Getcur_yItemName(), sizeof(current_filename)); |
350 | sprintf(#item_path,"\"%s/%s\"",#work_folder,#current_filename); |
350 | sprintf(#item_path,"\"%s/%s\"",#work_folder,#current_filename); |
351 | DrawPlayList(); |
351 | DrawPlayList(); |
352 | DrawTopPanel(); |
352 | DrawTopPanel(); |
353 | if (strcmpi(#item_path+strlen(#item_path)-4,".mp3")) player_run_id = RunProgram(abspath("minimp3"), #item_path); |
353 | if (strcmpi(#item_path+strlen(#item_path)-4,".mp3")) player_run_id = RunProgram(abspath("minimp3"), #item_path); |
354 | sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename); |
354 | sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename); |
355 | for (i=2; i |
355 | for (i=2; i |
356 | notify_run_id = notify(#notify_message); |
356 | notify_run_id = notify(#notify_message); |
357 | } |
357 | } |
358 | 358 | ||
359 | 359 | ||
360 | void EventPlayAndPause() |
360 | void EventPlayAndPause() |
361 | { |
361 | { |
362 | if (playback_mode == PLAYBACK_MODE_PLAYING) |
362 | if (playback_mode == PLAYBACK_MODE_PLAYING) |
363 | { |
363 | { |
364 | playback_mode = PLAYBACK_MODE_STOPED; |
364 | playback_mode = PLAYBACK_MODE_STOPED; |
365 | EventStopPlayingMp3(); |
365 | EventStopPlayingMp3(); |
366 | } |
366 | } |
367 | else |
367 | else |
368 | { |
368 | { |
369 | playback_mode = PLAYBACK_MODE_PLAYING; |
369 | playback_mode = PLAYBACK_MODE_PLAYING; |
370 | EventStartPlayingMp3(); |
370 | EventStartPlayingMp3(); |
371 | } |
371 | } |
372 | } |
372 | } |
373 | 373 | ||
374 | 374 | ||
375 | void EventChangeWindowMode() |
375 | void EventChangeWindowMode() |
376 | { |
376 | { |
377 | if (window_mode == WINDOW_MODE_NORMAL) |
377 | if (window_mode == WINDOW_MODE_NORMAL) |
378 | { |
378 | { |
379 | window_mode = WINDOW_MODE_SMALL; |
379 | window_mode = WINDOW_MODE_SMALL; |
380 | win_x_normal = Form.left; |
380 | win_x_normal = Form.left; |
381 | win_y_normal = Form.top; |
381 | win_y_normal = Form.top; |
382 | MoveSize(OLD, OLD, WIN_W_SMALL-1, WIN_H_SMALL-1); |
382 | MoveSize(OLD, OLD, WIN_W_SMALL-1, WIN_H_SMALL-1); |
383 | MoveSize(OLD, win_y_small, OLD, OLD); |
383 | MoveSize(OLD, win_y_small, OLD, OLD); |
384 | MoveSize(win_x_small, OLD, OLD, OLD); |
384 | MoveSize(win_x_small, OLD, OLD, OLD); |
385 | } |
385 | } |
386 | else |
386 | else |
387 | { |
387 | { |
388 | window_mode = WINDOW_MODE_NORMAL; |
388 | window_mode = WINDOW_MODE_NORMAL; |
389 | win_x_small = Form.left; |
389 | win_x_small = Form.left; |
390 | win_y_small = Form.top; |
390 | win_y_small = Form.top; |
391 | MoveSize(win_x_normal, win_y_normal, skin.w -1 ,skin.h + list.h); |
391 | MoveSize(win_x_normal, win_y_normal, skin.w -1 ,skin.h + list.h); |
392 | } |
392 | } |
393 | } |
393 | } |
394 | 394 | ||
395 | void EventExitApp() |
395 | void EventExitApp() |
396 | { |
396 | { |
397 | EventStopPlayingMp3(); |
397 | EventStopPlayingMp3(); |
398 | SaveIniConfig(); |
398 | SaveIniConfig(); |
399 | ExitProcess(); |
399 | ExitProcess(); |
400 | } |
400 | } |
401 | 401 | ||
402 | void EventPlaybackPrevious() |
402 | void EventPlaybackPrevious() |
403 | { |
403 | { |
404 | current_playing_file_n--; |
404 | current_playing_file_n--; |
405 | EventStartPlayingMp3(); |
405 | EventStartPlayingMp3(); |
406 | } |
406 | } |
407 | 407 | ||
408 | void EventPlaybackNext() |
408 | void EventPlaybackNext() |
409 | { |
409 | { |
410 | current_playing_file_n++; |
410 | current_playing_file_n++; |
411 | EventStartPlayingMp3(); |
411 | EventStartPlayingMp3(); |
412 | } |
412 | } |
413 | 413 | ||
414 | void EventStartPlayingSelectedItem() |
414 | void EventStartPlayingSelectedItem() |
415 | { |
415 | { |
416 | current_playing_file_n=list.cur_y; |
416 | current_playing_file_n=list.cur_y; |
417 | EventStartPlayingMp3(); |
417 | EventStartPlayingMp3(); |
418 | } |
418 | } |
419 | 419 | ||
420 | void EventFileDialogOpen() |
420 | void EventFileDialogOpen() |
421 | { |
421 | { |
422 | OpenDialog_start stdcall (#o_dialog); |
422 | OpenDialog_start stdcall (#o_dialog); |
423 | if (o_dialog.status==1) EventOpenFolder(#openfile_path); |
423 | if (o_dialog.status==1) EventOpenFolder(#openfile_path); |
424 | } |
424 | } |
425 | 425 | ||
426 | void EventCheckSongFinished() |
426 | void EventCheckSongFinished() |
427 | { |
427 | { |
428 | if (playback_mode == PLAYBACK_MODE_PLAYING) && (!GetProcessSlot(player_run_id)) { |
428 | if (playback_mode == PLAYBACK_MODE_PLAYING) && (!GetProcessSlot(player_run_id)) { |
429 | EventPlaybackNext(); |
429 | EventPlaybackNext(); |
430 | } |
430 | } |
431 | } |
431 | } |
432 | 432 | ||
433 | 433 | ||
434 | stop: |
434 | stop: |
435 | 435 | ||
436 | char menu_stak[4096];>=> |
436 | char menu_stak[4096];>=> |