2 CLASS(NexuizCvarList) EXTENDS(NexuizListBox)
3 METHOD(NexuizCvarList, configureNexuizCvarList, void(entity))
4 ATTRIB(NexuizCvarList, rowsPerItem, float, 1)
5 METHOD(NexuizCvarList, drawListBoxItem, void(entity, float, vector, float))
6 METHOD(NexuizCvarList, resizeNotify, void(entity, vector, vector, vector, vector))
7 METHOD(NexuizCvarList, keyDown, float(entity, float, float, float))
9 ATTRIB(NexuizCvarList, realFontSize, vector, '0 0 0')
10 ATTRIB(NexuizCvarList, realUpperMargin, float, 0)
11 ATTRIB(NexuizCvarList, columnNameOrigin, float, 0)
12 ATTRIB(NexuizCvarList, columnNameSize, float, 0)
13 ATTRIB(NexuizCvarList, columnValueOrigin, float, 0)
14 ATTRIB(NexuizCvarList, columnValueSize, float, 0)
16 METHOD(NexuizCvarList, setSelected, void(entity, float))
17 ATTRIB(NexuizCvarList, controlledTextbox, entity, NULL)
18 ATTRIB(NexuizCvarList, cvarNameBox, entity, NULL)
19 ATTRIB(NexuizCvarList, cvarDescriptionBox, entity, NULL)
20 ATTRIB(NexuizCvarList, cvarTypeBox, entity, NULL)
21 ATTRIB(NexuizCvarList, cvarValueBox, entity, NULL)
22 ATTRIB(NexuizCvarList, cvarDefaultBox, entity, NULL)
24 ATTRIB(NexuizCvarList, handle, float, -1)
25 ATTRIB(NexuizCvarList, cvarName, string, string_null)
26 ATTRIB(NexuizCvarList, cvarDescription, string, string_null)
27 ATTRIB(NexuizCvarList, cvarType, string, string_null)
28 ATTRIB(NexuizCvarList, cvarDefault, string, string_null)
29 ENDCLASS(NexuizCvarList)
30 entity makeNexuizCvarList();
31 void CvarList_Filter_Change(entity box, entity me);
32 void CvarList_Value_Change(entity box, entity me);
33 void CvarList_Revert_Click(entity btn, entity me);
37 entity makeNexuizCvarList()
40 me = spawnNexuizCvarList();
41 me.configureNexuizCvarList(me);
44 void configureNexuizCvarListNexuizCvarList(entity me)
46 me.configureNexuizListBox(me);
48 me.handle = buf_create();
49 buf_cvarlist(me.handle, "", "_");
50 me.nItems = buf_getsize(me.handle);
52 void setSelectedNexuizCvarList(entity me, float i)
56 setSelectedListBox(me, i);
61 strunzone(me.cvarName);
62 if(me.cvarDescription)
63 strunzone(me.cvarDescription);
65 strunzone(me.cvarType);
67 strunzone(me.cvarDefault);
68 me.cvarName = strzone(bufstr_get(me.handle, me.selectedItem));
69 me.cvarDescription = strzone(cvar_description(me.cvarName));
70 me.cvarDefault = strzone(cvar_defstring(me.cvarName));
73 t = cvar_type(me.cvarName);
75 if(t & CVAR_TYPEFLAG_SAVED)
76 me.cvarType = strcat(me.cvarType, ", will be saved to config.cfg");
78 me.cvarType = strcat(me.cvarType, ", will not be saved");
79 if(t & CVAR_TYPEFLAG_PRIVATE)
80 me.cvarType = strcat(me.cvarType, ", private");
81 if(t & CVAR_TYPEFLAG_ENGINE)
82 me.cvarType = strcat(me.cvarType, ", engine setting");
83 if(t & CVAR_TYPEFLAG_READONLY)
84 me.cvarType = strcat(me.cvarType, ", read only");
85 me.cvarType = strzone(substring(me.cvarType, 2, strlen(me.cvarType) - 2));
87 me.cvarNameBox.setText(me.cvarNameBox, me.cvarName);
88 me.cvarDescriptionBox.setText(me.cvarDescriptionBox, me.cvarDescription);
89 me.cvarTypeBox.setText(me.cvarTypeBox, me.cvarType);
90 me.cvarDefaultBox.setText(me.cvarDefaultBox, me.cvarDefault);
92 // this one can handle tempstrings
93 s = cvar_string(me.cvarName);
94 me.cvarValueBox.setText(me.cvarValueBox, s);
95 me.cvarValueBox.cursorPos = strlen(s);
97 void CvarList_Filter_Change(entity box, entity me)
99 buf_cvarlist(me.handle, box.text, "_");
100 me.nItems = buf_getsize(me.handle);
102 me.setSelected(me, 0);
104 void resizeNotifyNexuizCvarList(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
106 resizeNotifyNexuizListBox(me, relOrigin, relSize, absOrigin, absSize);
108 me.realFontSize_y = me.fontSize / (absSize_y * me.itemHeight);
109 me.realFontSize_x = me.fontSize / (absSize_x * (1 - me.controlWidth));
110 me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
112 me.columnNameOrigin = 0;
113 me.columnValueSize = me.realFontSize_x * 20;
114 me.columnNameSize = 1 - me.columnValueSize - me.realFontSize_x;
115 me.columnValueOrigin = me.columnNameOrigin + me.columnNameSize + me.realFontSize_x;
117 me.setSelected(me, me.selectedItem);
119 void drawListBoxItemNexuizCvarList(entity me, float i, vector absSize, float isSelected)
130 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
132 k = bufstr_get(me.handle, i);
135 d = cvar_defstring(k);
137 if(t & CVAR_TYPEFLAG_SAVED)
138 theAlpha = SKINALPHA_CVARLIST_SAVED;
140 theAlpha = SKINALPHA_CVARLIST_TEMPORARY;
142 theColor = SKINCOLOR_CVARLIST_UNCHANGED;
144 theColor = SKINCOLOR_CVARLIST_CHANGED;
146 s = draw_TextShortenToWidth(k, me.columnNameSize / me.realFontSize_x, 0);
147 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, theColor, theAlpha, 0);
148 s = draw_TextShortenToWidth(v, me.columnValueSize / me.realFontSize_x, 0);
149 draw_Text(me.realUpperMargin * eY + me.columnValueOrigin * eX, s, me.realFontSize, theColor, theAlpha, 0);
152 float keyDownNexuizCvarList(entity me, float scan, float ascii, float shift)
154 if(keyDownListBox(me, scan, ascii, shift))
156 else if(!me.controlledTextbox)
159 return me.controlledTextbox.keyDown(me.controlledTextbox, scan, ascii, shift);
162 void CvarList_Value_Change(entity box, entity me)
164 cvar_set(me.cvarNameBox.text, box.text);
167 void CvarList_Revert_Click(entity btn, entity me)
169 me.cvarValueBox.setText(me.cvarValueBox, me.cvarDefault);
170 me.cvarValueBox.cursorPos = strlen(me.cvarDefault);