From: terencehill Date: Fri, 15 Apr 2016 14:09:24 +0000 (+0200) Subject: Add a checkbox in the cvar list dialog to show only the modified cvars X-Git-Tag: xonotic-v0.8.2~950^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e2fd6769daddf8facc0a57153b6a84fcb9da6590;p=xonotic%2Fxonotic-data.pk3dir.git Add a checkbox in the cvar list dialog to show only the modified cvars --- diff --git a/qcsrc/menu/xonotic/cvarlist.qc b/qcsrc/menu/xonotic/cvarlist.qc index 956285ec8..e41223277 100644 --- a/qcsrc/menu/xonotic/cvarlist.qc +++ b/qcsrc/menu/xonotic/cvarlist.qc @@ -16,13 +16,33 @@ void XonoticCvarList_configureXonoticCvarList(entity me) 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); } @@ -102,9 +122,14 @@ void XonoticCvarList_setSelected(entity me, float i) } 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) diff --git a/qcsrc/menu/xonotic/cvarlist.qh b/qcsrc/menu/xonotic/cvarlist.qh index 4bc56b3b8..11ab45f35 100644 --- a/qcsrc/menu/xonotic/cvarlist.qh +++ b/qcsrc/menu/xonotic/cvarlist.qh @@ -38,6 +38,9 @@ CLASS(XonoticCvarList, XonoticListBox) 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; diff --git a/qcsrc/menu/xonotic/dialog_settings_misc_cvars.qc b/qcsrc/menu/xonotic/dialog_settings_misc_cvars.qc index f1fec78cf..d34588ce8 100644 --- a/qcsrc/menu/xonotic/dialog_settings_misc_cvars.qc +++ b/qcsrc/menu/xonotic/dialog_settings_misc_cvars.qc @@ -28,15 +28,16 @@ void XonoticCvarsDialog_fill(entity me) // in this dialog, use SKINCOLOR_CVARLIS 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); @@ -51,11 +52,8 @@ void XonoticCvarsDialog_fill(entity me) // in this dialog, use SKINCOLOR_CVARLIS 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;