1 | #ifndef HELP_H |
---|
2 | #define HELP_H |
---|
3 | |
---|
4 | void screenhelp(struct skin* node) |
---|
5 | { |
---|
6 | int rcret = 0; |
---|
7 | struct skin* help = getscreen("helpbox"); |
---|
8 | struct skin* textbox = getscreennode(help, "textbox"); |
---|
9 | char* helppath = NULL, *tmpstr = NULL, *lang = NULL, *buf = NULL; |
---|
10 | |
---|
11 | if(node == NULL || node->name == NULL) return; |
---|
12 | |
---|
13 | helppath = getconfig("helppath", NULL); |
---|
14 | if(helppath == NULL) return; |
---|
15 | |
---|
16 | //get language |
---|
17 | lang = ostrcat(getconfig("lang", NULL), NULL, 0, 0); |
---|
18 | lang = string_replace("po/", "", lang, 1); |
---|
19 | |
---|
20 | //create full filename |
---|
21 | tmpstr = ostrcat(helppath, "/", 0, 0); |
---|
22 | tmpstr = ostrcat(tmpstr, lang, 1, 1); |
---|
23 | tmpstr = ostrcat(tmpstr, "/", 1, 0); |
---|
24 | tmpstr = ostrcat(tmpstr, node->name, 1, 0); |
---|
25 | tmpstr = ostrcat(tmpstr, ".txt", 1, 0); |
---|
26 | |
---|
27 | buf = readfiletomem(tmpstr, 0); |
---|
28 | if(buf == NULL) |
---|
29 | { |
---|
30 | free(tmpstr); tmpstr = NULL; |
---|
31 | return; |
---|
32 | } |
---|
33 | changetext(textbox, buf); |
---|
34 | |
---|
35 | free(tmpstr); tmpstr = NULL; |
---|
36 | free(buf); buf = NULL; |
---|
37 | |
---|
38 | drawscreen(help, 0, 0); |
---|
39 | addscreenrc(help, textbox); |
---|
40 | delrc(getrcconfigint("rchelp", NULL), help, textbox); |
---|
41 | |
---|
42 | while(1) |
---|
43 | { |
---|
44 | rcret = waitrc(help, 0, 0); |
---|
45 | |
---|
46 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
47 | } |
---|
48 | |
---|
49 | changetext(textbox, NULL); |
---|
50 | delownerrc(help); |
---|
51 | clearscreen(help); |
---|
52 | } |
---|
53 | |
---|
54 | #endif |
---|