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 | buf = string_replace_all("\n", _("\n"), buf, 1); |
---|
34 | changetext(textbox, buf); |
---|
35 | |
---|
36 | free(tmpstr); tmpstr = NULL; |
---|
37 | free(buf); buf = NULL; |
---|
38 | |
---|
39 | drawscreen(help, 0, 0); |
---|
40 | addscreenrc(help, textbox); |
---|
41 | delrc(getrcconfigint("rchelp", NULL), help, textbox); |
---|
42 | |
---|
43 | while(1) |
---|
44 | { |
---|
45 | rcret = waitrc(help, 0, 0); |
---|
46 | |
---|
47 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
48 | } |
---|
49 | |
---|
50 | changetext(textbox, NULL); |
---|
51 | delownerrc(help); |
---|
52 | clearscreen(help); |
---|
53 | } |
---|
54 | |
---|
55 | #endif |
---|