me.handle = buf_create();
me.nItems = 0;
}
+void CvarList_Load(entity me, string filter)
+{
+ if(me.handle < 0)
+ return;
+
+ buf_cvarlist(me.handle, filter, "_");
+ me.nItems = buf_getsize(me.handle);
+ if(autocvar_menu_cvarlist_onlymodified)
+ {
+ float newbuf = buf_create();
+ for (int i = 0; i < me.nItems; ++i)
+ {
+ string k = bufstr_get(me.handle, i);
+ if(cvar_string(k) != cvar_defstring(k))
+ bufstr_add(newbuf, k, false);
+ }
+ buf_del(me.handle);
+ me.handle = newbuf;
+ me.nItems = buf_getsize(me.handle);
+ }
+}
void XonoticCvarList_showNotify(entity me)
{
bool force_initial_selection = false;
if(me.handle >= 0 && me.nItems <= 0) // me.handle not loaded yet?
force_initial_selection = true;
- buf_cvarlist(me.handle, "", "_");
- me.nItems = buf_getsize(me.handle);
+ CvarList_Load(me, me.controlledTextbox.text);
if(force_initial_selection)
me.setSelected(me, 0);
}
}
void CvarList_Filter_Change(entity box, entity me)
{
- buf_cvarlist(me.handle, box.text, "_");
- me.nItems = buf_getsize(me.handle);
-
+ CvarList_Load(me, box.text);
+ me.setSelected(me, 0);
+}
+void CvarList_Filter_ModifiedCvars(entity box, entity me)
+{
+ cvar_set("menu_cvarlist_onlymodified", ftos(!autocvar_menu_cvarlist_onlymodified));
+ box.setChecked(box, autocvar_menu_cvarlist_onlymodified);
+ CvarList_Load(me, me.controlledTextbox.text);
me.setSelected(me, 0);
}
void XonoticCvarList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
ENDCLASS(XonoticCvarList)
entity makeXonoticCvarList();
void CvarList_Filter_Change(entity box, entity me);
+void CvarList_Filter_ModifiedCvars(entity box, entity me);
void CvarList_Value_Change(entity box, entity me);
void CvarList_Revert_Click(entity btn, entity me);
void CvarList_End_Editing(entity box, entity me);
+
+float autocvar_menu_cvarlist_onlymodified;
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Cvar filter:")));
- me.TD(me, 1, me.columns - 1, e = makeXonoticInputBox(0, string_null));
- e.color = SKINCOLOR_CVARLIST_CONTROLS;
- e.colorF = SKINCOLOR_CVARLIST_CONTROLS;
- e.cb_color = SKINCOLOR_CVARLIST_CONTROLS;
- e.cb_colorC = SKINCOLOR_CVARLIST_CONTROLS;
- e.cb_colorF = SKINCOLOR_CVARLIST_CONTROLS;
+ me.TD(me, 1, 3, e = makeXonoticInputBox(0, string_null));
+ e.color = e.colorF = SKINCOLOR_CVARLIST_CONTROLS;
+ e.cb_color = e.cb_colorC = e.cb_colorF = SKINCOLOR_CVARLIST_CONTROLS;
e.onChange = CvarList_Filter_Change;
e.onChangeEntity = cvarlist;
cvarlist.controlledTextbox = e; // this COULD also be the Value box, but this leads to accidentally editing stuff
+ me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "menu_cvarlist_onlymodified", _("Modified cvars only")));
+ e.color = e.colorC = e.colorF = e.colorD = SKINCOLOR_CVARLIST_CONTROLS;
+ e.onClickEntity = cvarlist;
+ e.onClick = CvarList_Filter_ModifiedCvars;
me.TR(me);
me.TD(me, me.rows - me.currentRow - 9, me.columns, cvarlist);
me.gotoRC(me, me.rows - 8, 0);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Value:")));
me.TD(me, 1, me.columns - 2, e = makeXonoticInputBox(0, string_null));
cvarlist.cvarValueBox = e;
- e.color = SKINCOLOR_CVARLIST_CONTROLS;
- e.colorF = SKINCOLOR_CVARLIST_CONTROLS;
- e.cb_color = SKINCOLOR_CVARLIST_CONTROLS;
- e.cb_colorC = SKINCOLOR_CVARLIST_CONTROLS;
- e.cb_colorF = SKINCOLOR_CVARLIST_CONTROLS;
+ e.color = e.colorF = SKINCOLOR_CVARLIST_CONTROLS;
+ e.cb_color = e.cb_colorC = e.cb_colorF = SKINCOLOR_CVARLIST_CONTROLS;
e.onChange = CvarList_Value_Change;
e.onChangeEntity = cvarlist;
e.onEnter = CvarList_End_Editing;