]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/item/checkbox.c
Merge branch 'terencehill/menu_optimizations' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / item / checkbox.c
1 #ifdef INTERFACE
2 void CheckBox_Click(entity me, entity other);
3 CLASS(CheckBox) EXTENDS(Button)
4         METHOD(CheckBox, configureCheckBox, void(entity, string, float, string))
5         METHOD(CheckBox, draw, void(entity))
6         METHOD(CheckBox, playClickSound, void(entity))
7         METHOD(CheckBox, toString, string(entity))
8         METHOD(CheckBox, setChecked, void(entity, float))
9         ATTRIB(CheckBox, useDownAsChecked, float, 0)
10         ATTRIB(CheckBox, checked, float, 0)
11         ATTRIB(CheckBox, onClick, void(entity, entity), CheckBox_Click)
12         ATTRIB(CheckBox, srcMulti, float, 0)
13         ATTRIB(CheckBox, disabled, float, 0)
14 ENDCLASS(CheckBox)
15 #endif
16
17 #ifdef IMPLEMENTATION
18 void CheckBox_setChecked(entity me, float val)
19 {
20         me.checked = val;
21 }
22 void CheckBox_Click(entity me, entity other)
23 {
24         me.setChecked(me, !me.checked);
25 }
26 string CheckBox_toString(entity me)
27 {
28         return strcat(SUPER(CheckBox).toString(me), ", ", me.checked ? "checked" : "unchecked");
29 }
30 void CheckBox_configureCheckBox(entity me, string txt, float sz, string gfx)
31 {
32         me.configureButton(me, txt, sz, gfx);
33         me.align = 0;
34 }
35 void CheckBox_draw(entity me)
36 {
37         float s;
38         s = me.pressed;
39         if(me.useDownAsChecked)
40         {
41                 me.srcSuffix = string_null;
42                 me.forcePressed = me.checked;
43         }
44         else
45                 me.srcSuffix = (me.checked ? "1" : "0");
46         me.pressed = s;
47         SUPER(CheckBox).draw(me);
48 }
49 void CheckBox_playClickSound(entity me)
50 {
51         m_play_click_sound(MENU_SOUND_SELECT);
52 }
53 #endif