source: titan/plugins/wins3/wins3.h @ 14544

Last change on this file since 14544 was 14544, checked in by nit, 12 years ago

[titan] add plugin wins3

File size: 1.4 KB
Line 
1#ifndef WINS3_H
2#define WINS3_H
3
4void wins3new(struct skin* wins3)
5{
6        struct skin* node = wins3;
7
8        while(node != NULL)
9        {
10                if(ostrcmp(node->text, "O") == 0 || ostrcmp(node->text, "X") == 0)
11                        changetext(node, NULL);
12
13                node = node->next;
14        }
15}
16
17void wins3changetitle(struct skin* wins3, int player)
18{
19        char* title = "3 WINS Player ";
20        char* tmpstr = NULL, *tmpnr = NULL;
21
22        tmpnr = oitoa(player);
23        tmpstr = ostrcat(_(title), tmpnr, 0, 0);
24
25        changetitle(wins3, tmpstr);
26
27        free(tmpstr); tmpstr = NULL;
28        free(tmpnr); tmpnr = NULL;
29}
30
31void screenwins3()
32{
33        int rcret = 0, player = 1;
34        struct skin* wins3 = getscreen("wins3");
35        struct skin* grid = getscreennode(wins3, "grid");
36
37        wins3new(wins3);
38        wins3changetitle(wins3, player);
39       
40        drawscreen(wins3, 0);
41        addscreenrc(wins3, grid);
42
43        while(1)
44        {
45                rcret = waitrc(wins3, 0, 0);
46
47                if(rcret == getrcconfigint("rcexit", NULL)) break;
48                if(rcret == getrcconfigint("rcok", NULL))
49                {
50                        if(grid->select != NULL && grid->select->text == NULL)
51                        {
52                                if(player == 1)
53                                {
54                                        changetext(grid->select, "X");
55                                        player = 2;
56                                }
57                                else
58                                {
59                                        changetext(grid->select, "O");
60                                        player = 1;
61                                }
62                                wins3changetitle(wins3, player);
63                                drawscreen(wins3, 0);
64                        }
65                        continue;
66                }
67                if(rcret == getrcconfigint("rcred", NULL))
68                {
69                        wins3new(grid);
70                        player = 1;
71                        wins3changetitle(wins3, player);
72                        drawscreen(wins3, 0);
73                }
74        }
75
76        delownerrc(wins3);
77        clearscreen(wins3);
78}
79
80#endif
Note: See TracBrowser for help on using the repository browser.