]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix an error caused by the selection of the first cvar before the cvarlist is loaded...
authorterencehill <piuntn@gmail.com>
Thu, 3 Dec 2015 22:45:44 +0000 (23:45 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 3 Dec 2015 22:45:44 +0000 (23:45 +0100)
qcsrc/menu/item/listbox.qc
qcsrc/menu/xonotic/cvarlist.qc
qcsrc/menu/xonotic/demolist.qc
qcsrc/menu/xonotic/screenshotlist.qc

index 7f303fda7a17b2b891776d008ab8fe9ab56b574a..d6ea7d85958d7f994d1231e5ccd34cd5506921ee 100644 (file)
@@ -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)
index a286d08b1cc375ead60267d089058d68b02af52a..11e88a4e688a6b92cb075c6f11c58419b5023c6d 100644 (file)
@@ -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)
 {
index 182f79873c595161165e32c91711f37e1793dcc5..9f8978c14b1159e7d589fb23ed7c2d561a0be8e0 100644 (file)
@@ -48,6 +48,7 @@ entity makeXonoticDemoList()
 void XonoticDemoList_configureXonoticDemoList(entity me)
 {
        me.configureXonoticListBox(me);
+       me.nItems = 0;
 }
 
 string XonoticDemoList_demoName(entity me, float i)
index 39573d9d1a68b841529148aef1824f386b491259..900c446f31085093cfb9086e6502c0e2c5c1ff45 100644 (file)
@@ -58,6 +58,7 @@ entity makeXonoticScreenshotList()
 void XonoticScreenshotList_configureXonoticScreenshotList(entity me)
 {
        me.configureXonoticListBox(me);
+       me.nItems = 0;
 }
 
 string XonoticScreenshotList_screenshotName(entity me, float i)