]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/nexuiz/inputbox.c
add missing effect sliders; "fix" the "bug" that showfps was in multiple panes
[divverent/nexuiz.git] / data / qcsrc / menu / 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         ATTRIB(NexuizInputBox, keepspaceLeft, float, SKINMARGIN_INPUTBOX)
11         ATTRIB(NexuizInputBox, keepspaceRight, float, SKINMARGIN_INPUTBOX)
12         ATTRIB(NexuizInputBox, color, vector, SKINCOLOR_INPUTBOX_N)
13         ATTRIB(NexuizInputBox, colorF, vector, SKINCOLOR_INPUTBOX_F)
14
15         ATTRIB(NexuizInputBox, alpha, float, SKINALPHA_TEXT)
16
17         ATTRIB(NexuizInputBox, cvarName, string, string_null)
18         METHOD(NexuizInputBox, loadCvars, void(entity))
19         METHOD(NexuizInputBox, saveCvars, void(entity))
20 ENDCLASS(NexuizInputBox)
21 entity makeNexuizInputBox(float, string);
22 #endif
23
24 #ifdef IMPLEMENTATION
25 entity makeNexuizInputBox(float doEditColorCodes, string theCvar)
26 {
27         entity me;
28         me = spawnNexuizInputBox();
29         me.configureNexuizInputBox(me, doEditColorCodes, theCvar);
30         return me;
31 }
32 void configureNexuizInputBoxNexuizInputBox(entity me, float doEditColorCodes, string theCvar)
33 {
34         me.configureInputBox(me, "", 0, me.fontSize, me.image);
35         me.editColorCodes = doEditColorCodes;
36         if(theCvar)
37         {
38                 me.cvarName = theCvar;
39                 me.loadCvars(me);
40         }
41         me.cursorPos = strlen(me.text);
42 }
43 void focusLeaveNexuizInputBox(entity me)
44 {
45         if(me.cvarName)
46                 me.saveCvars(me);
47 }
48 void setTextNexuizInputBox(entity me, string new)
49 {
50         if(me.text != new)
51         {
52                 setTextInputBox(me, new);
53                 me.onChange(me, me.onChangeEntity);
54         }
55         else
56                 setTextInputBox(me, new);
57 }
58 void loadCvarsNexuizInputBox(entity me)
59 {
60         setTextInputBox(me, cvar_string(me.cvarName));
61 }
62 void saveCvarsNexuizInputBox(entity me)
63 {
64         cvar_set(me.cvarName, me.text);
65 }
66 #endif