]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu-div0test/nexuiz/inputbox.c
made server filter work! Hooray, JOIN dialog is complete!
[divverent/nexuiz.git] / data / qcsrc / menu-div0test / nexuiz / inputbox.c
1 #ifdef INTERFACE
2 CLASS(NexuizInputBox) EXTENDS(InputBox)
3         METHOD(NexuizInputBox, configureNexuizInputBox, void(entity, float, string))
4         METHOD(NexuizInputBox, focusLeave, void(entity))
5         METHOD(NexuizInputBox, setText, void(entity, string))
6         ATTRIB(NexuizInputBox, fontSize, float, SKINFONTSIZE_NORMAL)
7         ATTRIB(NexuizInputBox, image, string, SKINGFX_INPUTBOX)
8         ATTRIB(NexuizInputBox, onChange, void(entity, entity), SUB_Null)
9         ATTRIB(NexuizInputBox, onChangeEntity, entity, NULL)
10
11         ATTRIB(NexuizInputBox, cvarName, string, string_null)
12         METHOD(NexuizInputBox, loadCvars, void(entity))
13         METHOD(NexuizInputBox, saveCvars, void(entity))
14 ENDCLASS(NexuizInputBox)
15 entity makeNexuizInputBox(float, string);
16 #endif
17
18 #ifdef IMPLEMENTATION
19 entity makeNexuizInputBox(float doEditColorCodes, string theCvar)
20 {
21         entity me;
22         me = spawnNexuizInputBox();
23         me.configureNexuizInputBox(me, doEditColorCodes, theCvar);
24         return me;
25 }
26 void configureNexuizInputBoxNexuizInputBox(entity me, float doEditColorCodes, string theCvar)
27 {
28         me.configureInputBox(me, "", 0, me.fontSize, me.image);
29         me.editColorCodes = doEditColorCodes;
30         if(theCvar)
31         {
32                 me.cvarName = theCvar;
33                 me.loadCvars(me);
34         }
35         me.cursorPos = strlen(me.text);
36 }
37 void focusLeaveNexuizInputBox(entity me)
38 {
39         if(me.cvarName)
40                 me.saveCvars(me);
41 }
42 void setTextNexuizInputBox(entity me, string new)
43 {
44         if(me.text != new)
45         {
46                 setTextInputBox(me, new);
47                 me.onChange(me, me.onChangeEntity);
48         }
49         else
50                 setTextInputBox(me, new);
51 }
52 void loadCvarsNexuizInputBox(entity me)
53 {
54         setTextInputBox(me, cvar_string(me.cvarName));
55 }
56 void saveCvarsNexuizInputBox(entity me)
57 {
58         cvar_set(me.cvarName, me.text);
59 }
60 #endif