Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
inputbox.qc
Go to the documentation of this file.
1#include "inputbox.qh"
2
3entity makeXonoticInputBox_T(bool doEditColorCodes, string theCvar, string theTooltip)
4{
6 me.configureXonoticInputBox(me, doEditColorCodes, theCvar, theTooltip);
7 return me;
8}
9entity makeXonoticInputBox(bool doEditColorCodes, string theCvar)
10{
11 return makeXonoticInputBox_T(doEditColorCodes, theCvar, string_null);
12}
13void XonoticInputBox_configureXonoticInputBox(entity me, bool doEditColorCodes, string theCvar, string theTooltip)
14{
15 me.configureInputBox(me, "", 0, me.fontSize, me.image);
16 me.editColorCodes = doEditColorCodes;
17 me.controlledCvar = (theCvar) ? theCvar : string_null;
18 me.loadCvars(me);
19 setZonedTooltip(me, theTooltip, theCvar);
20 me.cursorPos = strlen(me.text);
21}
23{
24 me.saveCvars(me);
25}
26void XonoticInputBox_setText(entity me, string val)
27{
28 if(me.text != val)
29 {
30 SUPER(XonoticInputBox).setText(me, val);
31 if(me.onChange)
32 me.onChange(me, me.onChangeEntity);
33 if(me.saveImmediately)
34 me.saveCvars(me);
35 }
36 else
37 SUPER(XonoticInputBox).setText(me, val);
38}
40{
41 if (!me.controlledCvar)
42 return;
43 SUPER(XonoticInputBox).setText(me, cvar_string(me.controlledCvar));
44}
46{
47 if (!me.controlledCvar)
48 return;
49 cvar_set(me.controlledCvar, me.text);
50 CheckSendCvars(me, me.controlledCvar);
51}
52float XonoticInputBox_keyDown(entity me, float key, float ascii, float shift)
53{
54 float r = 0;
55 if(key == K_ENTER || key == K_KP_ENTER)
56 {
57 if(me.controlledCvar)
58 {
59 me.saveCvars(me);
60 r = 1;
61 }
62 if(me.onEnter)
63 me.onEnter(me, me.onEnterEntity);
64 }
65 if(SUPER(XonoticInputBox).keyDown(me, key, ascii, shift))
66 r = 1;
67 return r;
68}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define strlen
float K_ENTER
Definition keycodes.qc:8
float K_KP_ENTER
Definition keycodes.qc:74
void CheckSendCvars(entity me, string cvarnamestring)
Definition util.qc:825
void setZonedTooltip(entity e, string theTooltip, string theCvar)
Definition util.qc:257
void cvar_set(string name, string value)
const string cvar_string(string name)
string string_null
Definition nil.qh:9
#define NEW(cname,...)
Definition oo.qh:117
#define SUPER(cname)
Definition oo.qh:231
entity makeXonoticInputBox(bool doEditColorCodes, string theCvar)
Definition inputbox.qc:9
entity makeXonoticInputBox_T(bool doEditColorCodes, string theCvar, string theTooltip)
Definition inputbox.qc:3
void XonoticInputBox_configureXonoticInputBox(entity me, bool doEditColorCodes, string theCvar, string theTooltip)
Definition inputbox.qc:13
void XonoticInputBox_setText(entity me, string val)
Definition inputbox.qc:26
float XonoticInputBox_keyDown(entity me, float key, float ascii, float shift)
Definition inputbox.qc:52
void XonoticInputBox_focusLeave(entity me)
Definition inputbox.qc:22
void XonoticInputBox_loadCvars(entity me)
Definition inputbox.qc:39
void XonoticInputBox_saveCvars(entity me)
Definition inputbox.qc:45