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