source: titan/plugins/permtime/permtime.c @ 43068

Last change on this file since 43068 was 24056, checked in by nit, 10 years ago

[titan] add new plugindir system

  • Property svn:executable set to *
File size: 3.6 KB
Line 
1#include "../../titan/struct.h"
2#include "../../titan/debug.h"
3#include "../../titan/header.h"
4
5char pluginname[] = "Permanent Time";
6char plugindesc[] = "Extensions";
7char pluginpic[] = "%pluginpath%/permtime/plugin.png";
8
9int pluginaktiv = 0;
10int pluginversion = 999999;
11//struct skin* pluginmenu = NULL;
12//int pluginflag = 1; //don't show the plugin in pluginmanager
13
14struct stimerthread* permtimethread = NULL;
15
16void permtime_thread()
17{
18       
19        char* tmpstr = NULL;
20        struct skin* framebuffer = getscreen("framebuffer");
21        struct skin* permtime = getscreen("permtime");
22        char* bg = NULL;
23       
24        int posx = getconfigint("permtime_posx", NULL);
25        int posy = getconfigint("permtime_posy", NULL);
26       
27        if(getconfigint("permtime_trans", NULL) == 1)
28                permtime->bgcol = -1;
29 
30        //if (posx == 0) posx = 3;
31        //if (posy == 0) posy = 2;
32        permtime->prozposx = 1;
33        permtime->prozposy = 1;
34        permtime->posx = posx;
35        permtime->posy = posy;
36       
37       
38        setnodeattr(permtime, framebuffer, 0);
39        bg = savescreen(permtime);
40       
41        while (permtimethread->aktion != STOP) {
42                tmpstr = gettime(NULL, "%H:%M");
43                changetext(permtime, tmpstr);
44                if(status.tuxtxt == 0)
45                        drawscreen(permtime, 0, 0);
46                free(tmpstr); tmpstr = NULL;
47                sleep(1);
48        }
49        restorescreen(bg, permtime);
50        blitfb(0);
51        permtimethread = NULL;
52  return;
53}
54
55void permtime_main()
56{
57        if(permtimethread == NULL)
58        {
59                permtimethread = addtimer(&permtime_thread, START, 10000, 1, NULL, NULL, NULL);
60                addconfig("permtime_plugin_running", "yes");
61        }
62        else
63        {
64                permtimethread->aktion = STOP;
65                addconfig("permtime_plugin_running", "no");
66        }
67}       
68                       
69//wird beim laden ausgefuehrt
70void init(void)
71{
72        char* tmpstr = NULL;
73        pluginaktiv = 1;
74       
75        tmpstr = createpluginpath("/permtime/skin.xml", 0);
76        readscreen(tmpstr, 115, 1);
77        free(tmpstr); tmpstr = NULL;
78        tmpstr = getconfig("permtime_plugin_running", NULL);
79        if(ostrcmp(tmpstr, "yes") == 0)
80                permtime_main();
81        tmpstr=NULL;
82       
83        debug(10, "Permanent Time Plugin loadet !!!");
84}
85
86//wird beim entladen ausgefuehrt
87void deinit(void)
88{
89        delmarkedscreen(115);
90        pluginaktiv = 0;
91        debug(10, "Permanent Time removed !!!");
92}
93
94//wird in der Pluginverwaltung bzw Menue ausfeguehrt
95void start(void)
96{
97        char* tmpstr = NULL;
98        int rcret;
99 
100        struct skin* pospermtime = getscreen("pospermtime");
101 
102        int posx = getconfigint("permtime_posx", NULL);
103        int posy = getconfigint("permtime_posy", NULL);
104        int trans = getconfigint("permtime_trans", NULL);
105        int bgc = pospermtime->bgcol;
106 
107        //if (posx == 0) posx = 3;
108        //if (posy == 0) posy = 2;
109        pospermtime->prozposx = 1;
110        pospermtime->prozposy = 1;
111       
112        tmpstr = getconfig("permtime_plugin_running", NULL);
113        if(ostrcmp(tmpstr, "yes") == 0) {
114                tmpstr=NULL;
115                permtime_main();
116        }
117        else {
118                tmpstr=NULL;
119                while(1)
120                {
121                        pospermtime->posx = posx;
122                        pospermtime->posy = posy;
123                        if(trans == 1)
124                                pospermtime->bgcol = -1;
125                        else
126                                pospermtime->bgcol = bgc;
127                        drawscreen(pospermtime, 0, 0);
128                        rcret = waitrc(pospermtime, 0, 0);
129                        clearscreen(pospermtime);
130                        if(rcret == getrcconfigint("rcup", NULL)) {
131                                posy = posy - 2;
132                                if(posy <= 0) posy = 0;
133                        }
134                        else if(rcret == getrcconfigint("rcdown", NULL)) {
135                                posy = posy + 2;
136                                if(posy >=96) posy = 96;
137                        }
138                        else if(rcret == getrcconfigint("rcleft", NULL)) {
139                                posx = posx - 3;
140                                if(posx <= 0) posx = 0;
141                        }
142                        else if(rcret == getrcconfigint("rcright", NULL)) {
143                                posx = posx + 3;
144                                if(posx >= 97) posx = 97;
145                        }
146                        else if(rcret == getrcconfigint("rc0", NULL)) {
147                                if(trans == 1)
148                                        trans = 0;
149                                else
150                                        trans = 1;
151                        }
152                        else if(rcret == getrcconfigint("rcok", NULL)) {
153                                addconfigint("permtime_posx", posx);
154                                addconfigint("permtime_posy", posy);
155                                addconfigint("permtime_trans", trans);
156                                break;
157                        }
158                }
159                permtime_main();
160               
161        }
162}
Note: See TracBrowser for help on using the repository browser.