]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/inputbox.c
remove playermodel descriptions
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / inputbox.c
index 0793ae181227fade01f859aa06b40c9c4ddfdb97..78bab2bccb33418b146c79e75cf08fc4722211f2 100644 (file)
@@ -5,9 +5,9 @@ CLASS(XonoticInputBox) EXTENDS(InputBox)
        METHOD(XonoticInputBox, setText, void(entity, string))
        ATTRIB(XonoticInputBox, fontSize, float, SKINFONTSIZE_NORMAL)
        ATTRIB(XonoticInputBox, image, string, SKINGFX_INPUTBOX)
-       ATTRIB(XonoticInputBox, onChange, void(entity, entity), SUB_Null)
+       ATTRIB(XonoticInputBox, onChange, void(entity, entity), func_null)
        ATTRIB(XonoticInputBox, onChangeEntity, entity, NULL)
-       ATTRIB(XonoticInputBox, onEnter, void(entity, entity), SUB_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)
@@ -16,10 +16,19 @@ CLASS(XonoticInputBox) EXTENDS(InputBox)
 
        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))
        METHOD(XonoticInputBox, keyDown, float(entity, float, float, float))
+
+       ATTRIB(XonoticInputBox, saveImmediately, float, 0)
 ENDCLASS(XonoticInputBox)
 entity makeXonoticInputBox(float, string);
 #endif
@@ -32,7 +41,7 @@ entity makeXonoticInputBox(float doEditColorCodes, string theCvar)
        me.configureXonoticInputBox(me, doEditColorCodes, theCvar);
        return me;
 }
-void configureXonoticInputBoxXonoticInputBox(entity me, float doEditColorCodes, string theCvar)
+void XonoticInputBox_configureXonoticInputBox(entity me, float doEditColorCodes, string theCvar)
 {
        me.configureInputBox(me, "", 0, me.fontSize, me.image);
        me.editColorCodes = doEditColorCodes;
@@ -44,46 +53,50 @@ void configureXonoticInputBoxXonoticInputBox(entity me, float doEditColorCodes,
        }
        me.cursorPos = strlen(me.text);
 }
-void focusLeaveXonoticInputBox(entity me)
+void XonoticInputBox_focusLeave(entity me)
 {
        me.saveCvars(me);
 }
-void setTextXonoticInputBox(entity me, string new)
+void XonoticInputBox_setText(entity me, string new)
 {
        if(me.text != new)
        {
-               setTextInputBox(me, new);
-               me.onChange(me, me.onChangeEntity);
+               SUPER(XonoticInputBox).setText(me, new);
+               if(me.onChange)
+                       me.onChange(me, me.onChangeEntity);
+               if(me.saveImmediately)
+                       me.saveCvars(me);
        }
        else
-               setTextInputBox(me, new);
+               SUPER(XonoticInputBox).setText(me, new);
 }
-void loadCvarsXonoticInputBox(entity me)
+void XonoticInputBox_loadCvars(entity me)
 {
-       if not(me.cvarName)
+       if (!me.cvarName)
                return;
-       setTextInputBox(me, cvar_string(me.cvarName));
+       SUPER(XonoticInputBox).setText(me, cvar_string(me.cvarName));
 }
-void saveCvarsXonoticInputBox(entity me)
+void XonoticInputBox_saveCvars(entity me)
 {
-       if not(me.cvarName)
+       if (!me.cvarName)
                return;
        cvar_set(me.cvarName, me.text);
 }
-float keyDownXonoticInputBox(entity me, float key, float ascii, float shift)
+float XonoticInputBox_keyDown(entity me, float key, float ascii, float shift)
 {
        float r;
        r = 0;
-       if(key == K_ENTER)
+       if(key == K_ENTER || key == K_KP_ENTER)
        {
                if(me.cvarName)
                {
                        me.saveCvars(me);
                        r = 1;
                }
-               me.onEnter(me, me.onEnterEntity);
+               if(me.onEnter)
+                       me.onEnter(me, me.onEnterEntity);
        }
-       if(keyDownInputBox(me, key, ascii, shift))
+       if(SUPER(XonoticInputBox).keyDown(me, key, ascii, shift))
                r = 1;
        return r;
 }