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