3 #include "../item/inputbox.qc"
4 CLASS(XonoticInputBox, InputBox)
5 METHOD(XonoticInputBox, configureXonoticInputBox, void(entity, float, string));
6 METHOD(XonoticInputBox, focusLeave, void(entity));
7 METHOD(XonoticInputBox, setText, void(entity, string));
8 ATTRIB(XonoticInputBox, fontSize, float, SKINFONTSIZE_NORMAL)
9 ATTRIB(XonoticInputBox, image, string, SKINGFX_INPUTBOX)
10 ATTRIB(XonoticInputBox, onChange, void(entity, entity), func_null)
11 ATTRIB(XonoticInputBox, onChangeEntity, entity, NULL)
12 ATTRIB(XonoticInputBox, onEnter, void(entity, entity), func_null)
13 ATTRIB(XonoticInputBox, onEnterEntity, entity, NULL)
14 ATTRIB(XonoticInputBox, marginLeft, float, SKINMARGIN_INPUTBOX_CHARS)
15 ATTRIB(XonoticInputBox, marginRight, float, SKINMARGIN_INPUTBOX_CHARS)
16 ATTRIB(XonoticInputBox, color, vector, SKINCOLOR_INPUTBOX_N)
17 ATTRIB(XonoticInputBox, colorF, vector, SKINCOLOR_INPUTBOX_F)
19 ATTRIB(XonoticInputBox, alpha, float, SKINALPHA_TEXT)
21 // Clear button attributes
22 ATTRIB(XonoticInputBox, cb_offset, float, SKINOFFSET_CLEARBUTTON) // bound to range -1, 0
23 ATTRIB(XonoticInputBox, cb_src, string, SKINGFX_CLEARBUTTON)
24 ATTRIB(XonoticInputBox, cb_color, vector, SKINCOLOR_CLEARBUTTON_N)
25 ATTRIB(XonoticInputBox, cb_colorF, vector, SKINCOLOR_CLEARBUTTON_F)
26 ATTRIB(XonoticInputBox, cb_colorC, vector, SKINCOLOR_CLEARBUTTON_C)
28 ATTRIB(XonoticInputBox, cvarName, string, string_null)
29 METHOD(XonoticInputBox, loadCvars, void(entity));
30 METHOD(XonoticInputBox, saveCvars, void(entity));
31 ATTRIB(XonoticInputBox, sendCvars, float, 0)
32 METHOD(XonoticInputBox, keyDown, float(entity, float, float, float));
34 ATTRIB(XonoticInputBox, saveImmediately, float, 0)
35 ENDCLASS(XonoticInputBox)
36 entity makeXonoticInputBox(float, string);
40 entity makeXonoticInputBox(float doEditColorCodes, string theCvar)
43 me = NEW(XonoticInputBox);
44 me.configureXonoticInputBox(me, doEditColorCodes, theCvar);
47 void XonoticInputBox_configureXonoticInputBox(entity me, float doEditColorCodes, string theCvar)
49 me.configureInputBox(me, "", 0, me.fontSize, me.image);
50 me.editColorCodes = doEditColorCodes;
53 me.cvarName = theCvar;
54 me.tooltip = getZonedTooltipForIdentifier(theCvar);
57 me.cursorPos = strlen(me.text);
59 void XonoticInputBox_focusLeave(entity me)
63 void XonoticInputBox_setText(entity me, string val)
67 SUPER(XonoticInputBox).setText(me, val);
69 me.onChange(me, me.onChangeEntity);
70 if(me.saveImmediately)
74 SUPER(XonoticInputBox).setText(me, val);
76 void XonoticInputBox_loadCvars(entity me)
80 SUPER(XonoticInputBox).setText(me, cvar_string(me.cvarName));
82 void XonoticInputBox_saveCvars(entity me)
86 cvar_set(me.cvarName, me.text);
87 CheckSendCvars(me, me.cvarName);
89 float XonoticInputBox_keyDown(entity me, float key, float ascii, float shift)
93 if(key == K_ENTER || key == K_KP_ENTER)
101 me.onEnter(me, me.onEnterEntity);
103 if(SUPER(XonoticInputBox).keyDown(me, key, ascii, shift))