]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/radiobutton.qc
Compact weapon flag checks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / radiobutton.qc
index 65f2486f2111e57d749bc28ff73ac2aff1254afa..536ea4f154f1b07d4c9b17afe67f18a2ff176f4d 100644 (file)
@@ -1,47 +1,22 @@
-#ifndef RADIOBUTTON_H
-#define RADIOBUTTON_H
-#include "../item/radiobutton.qc"
-CLASS(XonoticRadioButton, RadioButton)
-       METHOD(XonoticRadioButton, configureXonoticRadioButton, void(entity, float, string, string, string));
-       METHOD(XonoticRadioButton, draw, void(entity));
-       METHOD(XonoticRadioButton, setChecked, void(entity, float));
-       ATTRIB(XonoticRadioButton, fontSize, float, SKINFONTSIZE_NORMAL)
-       ATTRIB(XonoticRadioButton, image, string, SKINGFX_RADIOBUTTON)
-       ATTRIB(XonoticRadioButton, color, vector, SKINCOLOR_RADIOBUTTON_N)
-       ATTRIB(XonoticRadioButton, colorC, vector, SKINCOLOR_RADIOBUTTON_C)
-       ATTRIB(XonoticRadioButton, colorF, vector, SKINCOLOR_RADIOBUTTON_F)
-       ATTRIB(XonoticRadioButton, colorD, vector, SKINCOLOR_RADIOBUTTON_D)
+#include "radiobutton.qh"
 
-       ATTRIB(XonoticRadioButton, cvarName, string, string_null)
-       ATTRIB(XonoticRadioButton, cvarValue, string, string_null)
-       ATTRIB(XonoticRadioButton, cvarOffValue, string, string_null)
-       ATTRIB(XonoticRadioButton, cvarValueIsAnotherCvar, float, 0)
-       METHOD(XonoticRadioButton, loadCvars, void(entity));
-       METHOD(XonoticRadioButton, saveCvars, void(entity));
-
-       ATTRIB(XonoticRadioButton, alpha, float, SKINALPHA_TEXT)
-       ATTRIB(XonoticRadioButton, disabledAlpha, float, SKINALPHA_DISABLED)
-ENDCLASS(XonoticRadioButton)
-entity makeXonoticRadioButton(float, string, string, string);
-#endif
-
-#ifdef IMPLEMENTATION
-entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, string theText)
+entity makeXonoticRadioButton_T(float theGroup, string theCvar, string theValue, string theText, string theTooltip)
 {
        entity me;
        me = NEW(XonoticRadioButton);
-       me.configureXonoticRadioButton(me, theGroup, theCvar, theValue, theText);
+       me.configureXonoticRadioButton(me, theGroup, theCvar, theValue, theText, theTooltip);
        return me;
 }
-void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText)
+entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, string theText)
+{
+       return makeXonoticRadioButton_T(theGroup, theCvar, theValue, theText, string_null);
+}
+void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText, string theTooltip)
 {
-       if(theCvar)
-       {
-               me.cvarName = theCvar;
-               me.cvarValue = theValue;
-               me.tooltip = getZonedTooltipForIdentifier(theCvar);
-               me.loadCvars(me);
-       }
+       me.cvarName = (theCvar) ? theCvar : string_null;
+       me.cvarValue = theValue;
+       me.loadCvars(me);
+       setZonedTooltip(me, theTooltip, theCvar);
        me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
 }
 void XonoticRadioButton_setChecked(entity me, float val)
@@ -68,7 +43,7 @@ void XonoticRadioButton_loadCvars(entity me)
        {
                if(me.cvarName)
                {
-                       me.checked = !!cvar(me.cvarName);
+                       me.checked = boolean(cvar(me.cvarName));
                }
                else
                {
@@ -124,4 +99,3 @@ void XonoticRadioButton_saveCvars(entity me)
                }
        }
 }
-#endif