From ac8f316a963d4efe7b35b3823e364a61cebf6699 Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 3 Dec 2015 23:45:44 +0100 Subject: [PATCH] Fix an error caused by the selection of the first cvar before the cvarlist is loaded; also fix another small issue when restarting the menu caused by nItems getting initialized to 42 in the listBox class (WTF!) --- qcsrc/menu/item/listbox.qc | 2 +- qcsrc/menu/xonotic/cvarlist.qc | 8 ++++++-- qcsrc/menu/xonotic/demolist.qc | 1 + qcsrc/menu/xonotic/screenshotlist.qc | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/qcsrc/menu/item/listbox.qc b/qcsrc/menu/item/listbox.qc index 7f303fda7..d6ea7d859 100644 --- a/qcsrc/menu/item/listbox.qc +++ b/qcsrc/menu/item/listbox.qc @@ -43,7 +43,7 @@ ATTRIB(ListBox, colorF, vector, '1 1 1') ATTRIB(ListBox, tolerance, vector, '0 0 0') // drag tolerance ATTRIB(ListBox, scrollbarWidth, float, 0) // pixels - ATTRIB(ListBox, nItems, float, 42) + ATTRIB(ListBox, nItems, float, 42) // FIXME: why?!? ATTRIB(ListBox, itemHeight, float, 0) ATTRIB(ListBox, colorBG, vector, '0 0 0') ATTRIB(ListBox, alphaBG, float, 0) diff --git a/qcsrc/menu/xonotic/cvarlist.qc b/qcsrc/menu/xonotic/cvarlist.qc index a286d08b1..11e88a4e6 100644 --- a/qcsrc/menu/xonotic/cvarlist.qc +++ b/qcsrc/menu/xonotic/cvarlist.qc @@ -55,11 +55,17 @@ void XonoticCvarList_configureXonoticCvarList(entity me) { me.configureXonoticListBox(me); me.handle = buf_create(); + me.nItems = 0; } 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); + if(force_initial_selection) + me.setSelected(me, 0); } void XonoticCvarList_destroy(entity me) { @@ -154,8 +160,6 @@ void XonoticCvarList_resizeNotify(entity me, vector relOrigin, vector relSize, v me.columnValueSize = me.realFontSize.x * 20; me.columnNameSize = 1 - me.columnValueSize - me.realFontSize.x; me.columnValueOrigin = me.columnNameOrigin + me.columnNameSize + me.realFontSize.x; - - me.setSelected(me, me.selectedItem); } void XonoticCvarList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { diff --git a/qcsrc/menu/xonotic/demolist.qc b/qcsrc/menu/xonotic/demolist.qc index 182f79873..9f8978c14 100644 --- a/qcsrc/menu/xonotic/demolist.qc +++ b/qcsrc/menu/xonotic/demolist.qc @@ -48,6 +48,7 @@ entity makeXonoticDemoList() void XonoticDemoList_configureXonoticDemoList(entity me) { me.configureXonoticListBox(me); + me.nItems = 0; } string XonoticDemoList_demoName(entity me, float i) diff --git a/qcsrc/menu/xonotic/screenshotlist.qc b/qcsrc/menu/xonotic/screenshotlist.qc index 39573d9d1..900c446f3 100644 --- a/qcsrc/menu/xonotic/screenshotlist.qc +++ b/qcsrc/menu/xonotic/screenshotlist.qc @@ -58,6 +58,7 @@ entity makeXonoticScreenshotList() void XonoticScreenshotList_configureXonoticScreenshotList(entity me) { me.configureXonoticListBox(me); + me.nItems = 0; } string XonoticScreenshotList_screenshotName(entity me, float i) -- 2.39.2