X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fcheckbox.qc;h=949b01c41da50c353beb177a70991d4683f28741;hb=659af223ade0881df7e5ea537fe58cc73d91767b;hp=18ac036ae54d2ebfbdd327796610a3bed9ab33bf;hpb=2aed36e128f8f00da9c76f9e66baae89d5bb26b2;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/checkbox.qc b/qcsrc/menu/xonotic/checkbox.qc index 18ac036ae..949b01c41 100644 --- a/qcsrc/menu/xonotic/checkbox.qc +++ b/qcsrc/menu/xonotic/checkbox.qc @@ -1,75 +1,55 @@ -#ifndef CHECKBOX_H -#define CHECKBOX_H -#include "../item/checkbox.qc" -CLASS(XonoticCheckBox, CheckBox) - METHOD(XonoticCheckBox, configureXonoticCheckBox, void(entity, float, float, string, string)); - METHOD(XonoticCheckBox, setChecked, void(entity, float)); - ATTRIB(XonoticCheckBox, fontSize, float, SKINFONTSIZE_NORMAL) - ATTRIB(XonoticCheckBox, image, string, SKINGFX_CHECKBOX) - ATTRIB(XonoticCheckBox, yesValue, float, 1) - ATTRIB(XonoticCheckBox, noValue, float, 0) +#include "checkbox.qh" - ATTRIB(XonoticCheckBox, color, vector, SKINCOLOR_CHECKBOX_N) - ATTRIB(XonoticCheckBox, colorC, vector, SKINCOLOR_CHECKBOX_C) - ATTRIB(XonoticCheckBox, colorF, vector, SKINCOLOR_CHECKBOX_F) - ATTRIB(XonoticCheckBox, colorD, vector, SKINCOLOR_CHECKBOX_D) - - ATTRIB(XonoticCheckBox, cvarName, string, string_null) - METHOD(XonoticCheckBox, loadCvars, void(entity)); - METHOD(XonoticCheckBox, saveCvars, void(entity)); - ATTRIB(XonoticCheckBox, sendCvars, float, 0) - - ATTRIB(XonoticCheckBox, alpha, float, SKINALPHA_TEXT) - ATTRIB(XonoticCheckBox, disabledAlpha, float, SKINALPHA_DISABLED) -ENDCLASS(XonoticCheckBox) -entity makeXonoticCheckBox(float, string, string); -entity makeXonoticCheckBoxEx(float, float, string, string); -#endif - -#ifdef IMPLEMENTATION -entity makeXonoticCheckBox(float isInverted, string theCvar, string theText) +entity makeXonoticCheckBox_T(float isInverted, string theCvar, string theText, string theTooltip) { - float y, n; + float m, n; if(isInverted > 1) { n = isInverted - 1; - y = -n; + m = -n; } else if(isInverted < -1) { n = isInverted + 1; - y = -n; + m = -n; } else if(isInverted == 1) { n = 1; - y = 0; + m = 0; } else { n = 0; - y = 1; + m = 1; } - return makeXonoticCheckBoxEx(y, n, theCvar, theText); + return makeXonoticCheckBoxEx_T(m, n, theCvar, theText, theTooltip); } -entity makeXonoticCheckBoxEx(float theYesValue, float theNoValue, string theCvar, string theText) +entity makeXonoticCheckBox(float isInverted, string theCvar, string theText) +{ + return makeXonoticCheckBox_T(isInverted, theCvar, theText, string_null); +} + +entity makeXonoticCheckBoxEx_T(float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip) { entity me; me = NEW(XonoticCheckBox); - me.configureXonoticCheckBox(me, theYesValue, theNoValue, theCvar, theText); + me.configureXonoticCheckBox(me, theYesValue, theNoValue, theCvar, theText, theTooltip); return me; } -void XonoticCheckBox_configureXonoticCheckBox(entity me, float theYesValue, float theNoValue, string theCvar, string theText) +entity makeXonoticCheckBoxEx(float theYesValue, float theNoValue, string theCvar, string theText) +{ + return makeXonoticCheckBoxEx_T(theYesValue, theNoValue, theCvar, theText, string_null); +} + +void XonoticCheckBox_configureXonoticCheckBox(entity me, float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip) { me.yesValue = theYesValue; me.noValue = theNoValue; me.checked = 0; - if(theCvar) - { - me.cvarName = theCvar; - me.tooltip = getZonedTooltipForIdentifier(theCvar); - me.loadCvars(me); - } + me.cvarName = (theCvar) ? theCvar : string_null; + me.loadCvars(me); + setZonedTooltip(me, theTooltip, theCvar); me.configureCheckBox(me, theText, me.fontSize, me.image); } void XonoticCheckBox_setChecked(entity me, float val) @@ -78,6 +58,8 @@ void XonoticCheckBox_setChecked(entity me, float val) { me.checked = val; me.saveCvars(me); + if(me.linkedCheckBox) + me.linkedCheckBox.loadCvars(me.linkedCheckBox); } } void XonoticCheckBox_loadCvars(entity me) @@ -97,10 +79,9 @@ void XonoticCheckBox_saveCvars(entity me) return; if(me.checked) - cvar_set(me.cvarName, ftos(me.yesValue)); + cvar_set(me.cvarName, ftos_mindecimals(me.yesValue)); else - cvar_set(me.cvarName, ftos(me.noValue)); + cvar_set(me.cvarName, ftos_mindecimals(me.noValue)); CheckSendCvars(me, me.cvarName); } -#endif