X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Finputbox.qc;h=4a3f905288fbc6ebecc7cd34dabd38d5e00ce801;hb=4435e6a342e65c52cb1fc00aea84f6018eff16ac;hp=5d7d179995028719bc107d1158edcd91678bc1e8;hpb=253cc10990569fd90917dba809ce03c90fc89336;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/inputbox.qc b/qcsrc/menu/xonotic/inputbox.qc index 5d7d17999..4a3f90528 100644 --- a/qcsrc/menu/xonotic/inputbox.qc +++ b/qcsrc/menu/xonotic/inputbox.qc @@ -1,88 +1,54 @@ -#ifdef INTERFACE -CLASS(XonoticInputBox) EXTENDS(InputBox) - METHOD(XonoticInputBox, configureXonoticInputBox, void(entity, float, string)) - METHOD(XonoticInputBox, focusLeave, void(entity)) - METHOD(XonoticInputBox, setText, void(entity, string)) - ATTRIB(XonoticInputBox, fontSize, float, SKINFONTSIZE_NORMAL) - ATTRIB(XonoticInputBox, image, string, SKINGFX_INPUTBOX) - ATTRIB(XonoticInputBox, onChange, void(entity, entity), func_null) - ATTRIB(XonoticInputBox, onChangeEntity, entity, NULL) - ATTRIB(XonoticInputBox, onEnter, void(entity, entity), func_null) - ATTRIB(XonoticInputBox, onEnterEntity, entity, NULL) - ATTRIB(XonoticInputBox, marginLeft, float, SKINMARGIN_INPUTBOX_CHARS) - ATTRIB(XonoticInputBox, marginRight, float, SKINMARGIN_INPUTBOX_CHARS) - ATTRIB(XonoticInputBox, color, vector, SKINCOLOR_INPUTBOX_N) - ATTRIB(XonoticInputBox, colorF, vector, SKINCOLOR_INPUTBOX_F) +#include "inputbox.qh" - ATTRIB(XonoticInputBox, alpha, float, SKINALPHA_TEXT) - - // Clear button attributes - ATTRIB(XonoticInputBox, cb_offset, float, SKINOFFSET_CLEARBUTTON) // bound to range -1, 0 - ATTRIB(XonoticInputBox, cb_src, string, SKINGFX_CLEARBUTTON) - ATTRIB(XonoticInputBox, cb_color, vector, SKINCOLOR_CLEARBUTTON_N) - ATTRIB(XonoticInputBox, cb_colorF, vector, SKINCOLOR_CLEARBUTTON_F) - ATTRIB(XonoticInputBox, cb_colorC, vector, SKINCOLOR_CLEARBUTTON_C) - - ATTRIB(XonoticInputBox, cvarName, string, string_null) - METHOD(XonoticInputBox, loadCvars, void(entity)) - METHOD(XonoticInputBox, saveCvars, void(entity)) - ATTRIB(XonoticInputBox, sendCvars, float, 0) - METHOD(XonoticInputBox, keyDown, float(entity, float, float, float)) - - ATTRIB(XonoticInputBox, saveImmediately, float, 0) -ENDCLASS(XonoticInputBox) -entity makeXonoticInputBox(float, string); -#endif - -#ifdef IMPLEMENTATION -entity makeXonoticInputBox(float doEditColorCodes, string theCvar) +entity makeXonoticInputBox_T(float doEditColorCodes, string theCvar, string theTooltip) { entity me; - me = spawnXonoticInputBox(); - me.configureXonoticInputBox(me, doEditColorCodes, theCvar); + me = NEW(XonoticInputBox); + me.configureXonoticInputBox(me, doEditColorCodes, theCvar, theTooltip); return me; } -void XonoticInputBox_configureXonoticInputBox(entity me, float doEditColorCodes, string theCvar) +entity makeXonoticInputBox(float doEditColorCodes, string theCvar) +{ + return makeXonoticInputBox_T(doEditColorCodes, theCvar, string_null); +} +void XonoticInputBox_configureXonoticInputBox(entity me, float doEditColorCodes, string theCvar, string theTooltip) { me.configureInputBox(me, "", 0, me.fontSize, me.image); me.editColorCodes = doEditColorCodes; - if(theCvar) - { - me.cvarName = theCvar; - me.tooltip = getZonedTooltipForIdentifier(theCvar); - me.loadCvars(me); - } + me.controlledCvar = (theCvar) ? theCvar : string_null; + me.loadCvars(me); + setZonedTooltip(me, theTooltip, theCvar); me.cursorPos = strlen(me.text); } void XonoticInputBox_focusLeave(entity me) { me.saveCvars(me); } -void XonoticInputBox_setText(entity me, string new) +void XonoticInputBox_setText(entity me, string val) { - if(me.text != new) + if(me.text != val) { - SUPER(XonoticInputBox).setText(me, new); + SUPER(XonoticInputBox).setText(me, val); if(me.onChange) me.onChange(me, me.onChangeEntity); if(me.saveImmediately) me.saveCvars(me); } else - SUPER(XonoticInputBox).setText(me, new); + SUPER(XonoticInputBox).setText(me, val); } void XonoticInputBox_loadCvars(entity me) { - if (!me.cvarName) + if (!me.controlledCvar) return; - SUPER(XonoticInputBox).setText(me, cvar_string(me.cvarName)); + SUPER(XonoticInputBox).setText(me, cvar_string(me.controlledCvar)); } void XonoticInputBox_saveCvars(entity me) { - if (!me.cvarName) + if (!me.controlledCvar) return; - cvar_set(me.cvarName, me.text); - CheckSendCvars(me, me.cvarName); + cvar_set(me.controlledCvar, me.text); + CheckSendCvars(me, me.controlledCvar); } float XonoticInputBox_keyDown(entity me, float key, float ascii, float shift) { @@ -90,7 +56,7 @@ float XonoticInputBox_keyDown(entity me, float key, float ascii, float shift) r = 0; if(key == K_ENTER || key == K_KP_ENTER) { - if(me.cvarName) + if(me.controlledCvar) { me.saveCvars(me); r = 1; @@ -102,4 +68,3 @@ float XonoticInputBox_keyDown(entity me, float key, float ascii, float shift) r = 1; return r; } -#endif