]> de.git.xonotic.org Git - voretournament/voretournament.git/blob - data/qcsrc/menu/item/radiobutton.c
Less blurry crosshair ring
[voretournament/voretournament.git] / data / qcsrc / menu / item / radiobutton.c
1 #ifdef INTERFACE\r
2 void RadioButton_Click(entity me, entity other);\r
3 CLASS(RadioButton) EXTENDS(CheckBox)\r
4         METHOD(RadioButton, configureRadioButton, void(entity, string, float, string, float, float))\r
5         ATTRIB(RadioButton, checked, float, 0)\r
6         ATTRIB(RadioButton, group, float, 0)\r
7         ATTRIB(RadioButton, allowDeselect, float, 0)\r
8         ATTRIB(RadioButton, onClick, void(entity, entity), RadioButton_Click)\r
9 ENDCLASS(RadioButton)\r
10 #endif\r
11 \r
12 #ifdef IMPLEMENTATION\r
13 void configureRadioButtonRadioButton(entity me, string txt, float sz, string gfx, float theGroup, float doAllowDeselect)\r
14 {\r
15         me.configureCheckBox(me, txt, sz, gfx);\r
16         me.align = 0;\r
17         me.group = theGroup;\r
18         me.allowDeselect = doAllowDeselect;\r
19 }\r
20 void RadioButton_Click(entity me, entity other)\r
21 {\r
22         if(me.checked)\r
23         {\r
24                 if(me.allowDeselect)\r
25                         me.setChecked(me, 0);\r
26         }\r
27         else\r
28         {\r
29                 entity e;\r
30                 for(e = me.parent.firstChild; e; e = e.nextSibling)\r
31                         if(e != me)\r
32                                 if(e.group == me.group)\r
33                                         e.setChecked(e, 0);\r
34                 me.setChecked(me, 1);\r
35         }\r
36 }\r
37 #endif\r