]> git.mxchange.org Git - quix0rs-blobwars.git/blob - patches/blobwars-1.10-options.patch
Capitalize Makefiles.
[quix0rs-blobwars.git] / patches / blobwars-1.10-options.patch
1 diff -ur blobwars-1.10.orig/src/widgets.cpp blobwars-1.10/src/widgets.cpp
2 --- blobwars-1.10.orig/src/widgets.cpp  2009-02-01 14:34:45.000000000 +0300
3 +++ blobwars-1.10/src/widgets.cpp       2009-02-27 22:01:52.000000000 +0300
4 @@ -34,68 +34,48 @@
5  
6         char *c = widget->options;
7  
8 -       char token[100];
9 -       strcpy(token, "");
10 -       
11         SDL_Surface *text;
12  
13 -       while (*c != '\0')
14 +       while (*c)
15         {
16 -               if (*c == '|')
17 -               {
18 -                       if (widget->enabled)
19 -                       {
20 -                               graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
21 -                               if (count == *widget->value)
22 -                                       graphics.setFontColor(0x00, 0x00, 0x00, 0x00, 0xff, 0x00);
23 -                       }
24 -                       else
25 -                       {
26 -                               graphics.setFontColor(0x77, 0x77, 0x77, 0x00, 0x00, 0x00);
27 -                       }
28 -
29 -                       sprintf(token, "%s", token);
30 +               char token[100];
31 +               int token_len;
32  
33 -                       text = graphics.getString(token, false);
34 +               char *eow = strchr (c, '|');
35 +               if (!eow)
36 +                       eow = strchr (c, 0);
37 +
38 +               token_len = eow - c;
39 +               if (token_len > sizeof (token) - 1)
40 +                       token_len = sizeof (token) - 1;
41 +               memcpy (token, c, token_len);
42 +               token [token_len] = 0;
43 +
44 +               c = eow;
45 +               if (*c)
46 +                       c++;
47  
48 -                       if ((widget->enabled) && (count == *widget->value))
49 -                               graphics.drawWidgetRect(x, widget->y, text->w, text->h);
50 -
51 -                       graphics.blit(text, x, widget->y, graphics.screen, false);
52 -
53 -                       x += text->w + 25;
54 -                       count++;
55 -                       strcpy(token, "");
56 +               if (widget->enabled)
57 +               {
58 +                       graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
59 +                       if (count == *widget->value)
60 +                               graphics.setFontColor(0x00, 0x00, 0x00, 0x00, 0xff, 0x00);
61                 }
62                 else
63                 {
64 -                       sprintf(token, "%s%c", token, *c);
65 +                       graphics.setFontColor(0x77, 0x77, 0x77, 0x00, 0x00, 0x00);
66                 }
67  
68 -               *c++;
69 -       }
70 -
71 -       if (widget->enabled)
72 -       {
73 -               graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
74 -               if (count == *widget->value)
75 -                       graphics.setFontColor(0x00, 0x00, 0x00, 0x00, 0xff, 0x00);
76 -       }
77 -       else
78 -       {
79 -               graphics.setFontColor(0x77, 0x77, 0x77, 0x00, 0x00, 0x00);
80 -       }
81 +               text = graphics.getString(token, false);
82  
83 -       sprintf(token, "%s", token);
84 +               if ((widget->enabled) && (count == *widget->value))
85 +                       graphics.drawWidgetRect(x, widget->y, text->w, text->h);
86  
87 -       text = graphics.getString(token, false);
88 +               graphics.blit(text, x, widget->y, graphics.screen, false);
89  
90 -       if ((widget->enabled) && (count == *widget->value))
91 -       {
92 -               graphics.drawWidgetRect(x, widget->y, text->w, text->h);
93 +               x += text->w + 25;
94 +               count++;
95         }
96 -
97 -       graphics.blit(text, x, widget->y, graphics.screen, false);
98  }
99  
100  /**
101 @@ -176,12 +156,8 @@
102         
103         int x = 300;
104         
105 -       char text[25];
106 -       strcpy(text, "");
107 -       
108 -       sprintf(text, "%s", Keyboard::translateKey(*widget->value));
109 -       
110 -       graphics.drawString(text, x, widget->y, TXT_LEFT, graphics.screen);
111 +       graphics.drawString(Keyboard::translateKey(*widget->value),
112 +                           x, widget->y, TXT_LEFT, graphics.screen);
113  }
114  
115  /**