source: titan/titan/dir.h @ 38961

Last change on this file since 38961 was 34070, checked in by obi, 9 years ago

add comment

File size: 7.2 KB
Line 
1#ifndef DIR_H
2#define DIR_H
3
4void readlabelext(struct skin* label, char* filename, char* ext)
5{
6        char *tmpstr = NULL, *tmpstr1 = NULL;
7
8        tmpstr = changefilenameext(filename, ext);
9        tmpstr1 = readfiletomem(tmpstr, 0);
10        if(tmpstr1 == NULL && ostrcmp(ext, ".epg") == 0)
11        {
12                free(tmpstr); tmpstr = NULL;
13                tmpstr = changefilenameext(filename, ".eit");
14                tmpstr1 = readeittomem(tmpstr);
15        }
16       
17        changetext(label, tmpstr1);
18
19        free(tmpstr); tmpstr = NULL;
20        free(tmpstr1); tmpstr1 = NULL;
21}
22
23//flag 1: add selected dir to path
24//flag 2-15: add selected dir to path and use dirrcret for dirs
25//flag 16-127: use dirrcret for dirs
26char* screendirreal(char* path, char* mask, char* selection, int *dirrcret, char* ext, char* b1, int rc1, char* b2, int rc2, char* b3, int rc3, char* b4, int rc4, int width, int prozwidth, int height, int prozheight, int holdselection, int flag)
27{
28        int rcret = 0;
29        struct skin* dir = NULL;
30
31        if(ext != NULL)
32                dir = getscreen("dirlabel");
33        else
34                dir = getscreen("dir");
35
36        struct skin* filelistpath = getscreennode(dir, "filelistpath");
37        struct skin* filelist = getscreennode(dir, "filelist");
38        struct skin* label = getscreennode(dir, "label");
39        struct skin* thumb = getscreennode(dir, "thumb");
40        struct skin* b5 = getscreennode(dir, "b5");
41        struct skin *button = NULL;
42        struct skin* load = getscreen("loading");
43        drawscreen(load, 0, 0);
44
45        char *ret = NULL;
46        char *tmppath = NULL;
47
48        if(path == NULL || strlen(path) == 0 || !isdir(path))
49                tmppath = ostrcat("/", NULL, 0, 0);
50        else
51                tmppath = ostrcat(path, NULL, 0, 0);
52
53        if(holdselection == 0)
54        {
55                filelist->aktline = 0;
56                filelist->aktpage = 0;
57        }
58        changemask(filelist, mask);
59        changeinput(filelist, tmppath);
60        changetext(filelistpath, filelist->input);
61        dir->width = width;
62        dir->prozwidth = prozwidth;
63        dir->height = height;
64        dir->prozheight = prozheight;
65
66        free(tmppath);
67        delmarkedscreennodes(dir, FILELISTDELMARK);
68        createfilelist(dir, filelist, 0);
69        if(holdselection == 0) setlistboxselection(filelist, selection);
70
71        if(ext != NULL)
72        {
73                ret = createpath(filelist->input, selection);
74                readlabelext(label, ret, ext);
75                free(ret); ret = NULL;
76        }
77
78        button = getscreennode(dir, "b1");
79        if(b1 != NULL)
80                changetext(button, _(b1));
81        else
82        {
83                changetext(button, _("---"));
84                button->hidden = YES;
85        }
86
87        button = getscreennode(dir, "b2");
88        if(b2 != NULL)
89                changetext(button, _(b2));
90        else
91        {
92                changetext(button, _("---"));
93                button->hidden = YES;
94        }
95
96        button = getscreennode(dir,  "b3");
97        if(b3 != NULL)
98                changetext(button, _(b3));
99        else
100        {
101                changetext(button, _("---"));
102                button->hidden = YES;
103        }
104
105        button = getscreennode(dir, "b4");
106        if(b4 != NULL)
107                changetext(button, _(b4));
108        else
109        {
110                changetext(button, _("---"));
111                button->hidden = YES;
112        }
113
114        if(flag == 64)
115                b5->hidden = NO;
116        else
117                b5->hidden = YES;
118
119        changepic(thumb, "playpic.png");
120
121        clearscreen(load);
122        drawscreen(dir, 0, 0);
123        addscreenrc(dir, filelist);
124
125        while(1)
126        {
127                if(ext != NULL)
128                        rcret = waitrc(dir, 0, 2);
129                else
130                        rcret = waitrc(dir, 0, 0);
131
132                if(rcret == getrcconfigint("rcexit", NULL))
133                {
134                        free(ret); ret = NULL;
135                        if(dirrcret != NULL) *dirrcret = 5;
136                        break;
137                }
138
139                if(rcret == getrcconfigint("rcup", NULL) || rcret == getrcconfigint("rcdown", NULL) || rcret == getrcconfigint("rcright", NULL) || rcret == getrcconfigint("rcleft", NULL))
140                {
141                        if(ext != NULL && filelist->select != NULL && filelist->select->input != NULL) //dir
142                        {
143                                changetext(label, NULL);
144                                drawscreen(dir, 0, 0);
145                        }
146                        else if(filelist->select != NULL && filelist->select->input == NULL) //file
147                        {
148                                ret = createpath(filelistpath->text, filelist->select->text);
149                                if(ext != NULL)
150                                {
151                                        char* tmpstr = NULL, *pic = NULL;
152                                        struct mediadb* mnode = getmediadb(filelistpath->text, filelist->select->text, 0);
153                                        if(mnode != NULL)
154                                        {
155                                                if(mnode->id != NULL)
156                                                {
157                                                        tmpstr = ostrcat(tmpstr, getconfig("mediadbpath", NULL), 1, 0);
158                                                        tmpstr = ostrcat(tmpstr, "/", 1, 0);
159                                                        tmpstr = ostrcat(tmpstr, mnode->id, 1, 0);
160
161                                                        pic = ostrcat(tmpstr, "_poster.jpg", 0, 0);
162                                                        changepic(thumb, pic);
163                                                }
164                                                else
165                                                        changepic(thumb, "playpic.png");
166                                        }
167                                        else
168                                                changepic(thumb, "playpic.png");
169                                                                                       
170                                        free(pic), pic = NULL;
171                                        free(tmpstr), tmpstr = NULL;
172
173                                        readlabelext(label, ret, ext);
174                                        drawscreen(dir, 0, 0);
175                                }
176                                free(ret); ret = NULL;
177                        }
178                        continue;
179                }
180                if(rcret == getrcconfigint("rcok", NULL) || (b1 != NULL && rcret == getrcconfigint("rcred", NULL)) || (b3 != NULL && rcret == getrcconfigint("rcyellow", NULL)) || (b4 != NULL && rcret == getrcconfigint("rcblue", NULL)))
181                {
182                        if(filelist->select != NULL && filelist->select->input != NULL) //dir
183                        {
184                                if(dirrcret != NULL)
185                                {
186                                        if(((flag & 2) || (flag & 16)) && b1 != NULL && rcret == getrcconfigint("rcred", NULL))
187                                        {
188                                                *dirrcret = 1;
189                                                break;
190                                        }
191                                        if(((flag & 4) || (flag & 32)) && b3 != NULL && rcret == getrcconfigint("rcyellow", NULL))
192                                        {
193                                                *dirrcret = 4;
194                                                break;
195                                        }
196                                        if(((flag & 8) || (flag & 64)) && b4 != NULL && rcret == getrcconfigint("rcblue", NULL))
197                                        {
198                                                *dirrcret = 4;
199                                                break;
200                                        }
201                                        if(flag == 64 && b1 != NULL && rcret == getrcconfigint("rcred", NULL)) // remove folder
202                                        {
203                                                ret = createpath(filelistpath->text, filelist->select->text);
204                                                *dirrcret = 1;
205                                                break;
206                                        }
207                                       
208                                }
209                                if(ext != NULL)
210                                        drawscreen(dir, 0, 0);
211                                continue;
212                        }
213                        else if(filelist->select != NULL && filelist->select->input == NULL) //file
214                        {
215                                ret = createpath(filelistpath->text, filelist->select->text);
216                                if(dirrcret != NULL)
217                                {
218                                        if(b1 != NULL && rcret == getrcconfigint("rcred", NULL))
219                                                *dirrcret = 1;
220                                        else if(b3 != NULL && rcret == getrcconfigint("rcyellow", NULL))
221                                                *dirrcret = 3;
222                                        else if(b4 != NULL && rcret == getrcconfigint("rcblue", NULL))
223                                                *dirrcret = 4;
224                                }
225                                break;
226                        }
227                        else if(ext != NULL)
228                                drawscreen(dir, 0, 0);
229                }
230
231                if(rcret == getrcconfigint("rcgreen", NULL))
232                {
233                        if(filelistpath != NULL)
234                        {
235                                if(filelist->mask == NULL || strlen(filelist->mask) == 0)
236                                {
237                                        if(flag >= 1 && flag <= 15)
238                                                ret = createpath(filelistpath->text, filelist->select->text);
239                                        else
240                                                ret = createpath(filelistpath->text, "");
241                                        if(dirrcret != NULL) *dirrcret = 2;
242                                        break;
243                                }
244                                else if(filelist->select != NULL && filelist->select->input == NULL)
245                                {
246                                        ret = createpath(filelistpath->text, filelist->select->text);
247                                        if(dirrcret != NULL) *dirrcret = 2;
248                                        break;
249                                }
250                        }
251                }
252
253                if(rcret == getrcconfigint("rcinfo", NULL) && status.play == 0 && flag == 64)
254                {
255                        char* file = createpath(filelistpath->text, filelist->select->text);
256                        if(playrcred(file, NULL, 0, 1, 1) == 9999)
257                        {
258                                delmarkedscreennodes(dir, FILELISTDELMARK);
259                                createfilelist(dir, filelist, 0);
260                        }
261                        free(file); file = NULL;
262                        drawscreen(dir, 0, 0);
263                }
264        }
265
266        delmarkedscreennodes(dir, FILELISTDELMARK);
267        delownerrc(dir);
268        clearscreen(dir);
269        return ret;
270}
271
272char* screendir(char* path, char* mask, char* selection, int *dirrcret, char* ext, char* b1, int rc1, char* b2, int rc2, char* b3, int rc3, char* b4, int rc4, int width, int prozwidth, int height, int prozheight, int flag)
273{
274        return screendirreal(path, mask, selection, dirrcret, ext, b1, rc1, b2, rc2, b3, rc3, b4, rc4, width, prozwidth, height, prozheight, 0, flag);
275}
276
277#endif
Note: See TracBrowser for help on using the repository browser.