X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fitem%2Fradiobutton.qc;h=00dcb680ad0d7e652000719d8312e02eacdaab95;hb=db3ca57a1d783b7cdd0cc8b714939f973a4d0f1e;hp=4dfadd2d569ce47132ee2f833460b439e59a8da9;hpb=7bae88d09fbd53cce732e31633aea92671b43699;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/item/radiobutton.qc b/qcsrc/menu/item/radiobutton.qc index 4dfadd2d5..00dcb680a 100644 --- a/qcsrc/menu/item/radiobutton.qc +++ b/qcsrc/menu/item/radiobutton.qc @@ -1,39 +1,24 @@ -#ifndef ITEM_RADIOBUTTON_H -#define ITEM_RADIOBUTTON_H -#include "checkbox.qc" -void RadioButton_Click(entity me, entity other); -CLASS(RadioButton, CheckBox) - METHOD(RadioButton, configureRadioButton, void(entity, string, float, string, float, float)); - ATTRIB(RadioButton, checked, float, 0) - ATTRIB(RadioButton, group, float, 0) - ATTRIB(RadioButton, allowDeselect, float, 0) - ATTRIB(RadioButton, onClick, void(entity, entity), RadioButton_Click) -ENDCLASS(RadioButton) -#endif +#include "radiobutton.qh" -#ifdef IMPLEMENTATION -void RadioButton_configureRadioButton(entity me, string txt, float sz, string gfx, float theGroup, float doAllowDeselect) -{ - me.configureCheckBox(me, txt, sz, gfx); - me.align = 0; - me.group = theGroup; - me.allowDeselect = doAllowDeselect; -} -void RadioButton_Click(entity me, entity other) -{ - if(me.checked) + void RadioButton_configureRadioButton(entity me, string txt, float sz, string gfx, float theGroup, float doAllowDeselect) { - if(me.allowDeselect) - me.setChecked(me, 0); + me.configureCheckBox(me, txt, sz, gfx); + me.align = 0; + me.group = theGroup; + me.allowDeselect = doAllowDeselect; } - else + void RadioButton_Click(entity me, entity other) { - entity e; - for(e = me.parent.firstChild; e; e = e.nextSibling) - if(e != me) - if(e.group == me.group) - e.setChecked(e, 0); - me.setChecked(me, 1); + if (me.checked) + { + if (me.allowDeselect) me.setChecked(me, 0); + } + else + { + entity e; + for (e = me.parent.firstChild; e; e = e.nextSibling) + if (e != me) + if (e.group == me.group) e.setChecked(e, 0); + me.setChecked(me, 1); + } } -} -#endif