X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fserverlist.qc;h=8d53be8fb5d5a0a9d4c0e47efc01c14627773e06;hp=33203c52b9dc72c10f80ad23183b609494d3310a;hb=99c1b6ca80a69e112d410ee493d62f757b2c6df8;hpb=f260e137aa3c5096e704f5e0a969ad69c079d884 diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index 33203c52b9..8d53be8fb5 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -27,6 +27,7 @@ CLASS(XonoticServerList, XonoticListBox) ATTRIB(XonoticServerList, columnTypeSize, float, 0) ATTRIB(XonoticServerList, columnPlayersOrigin, float, 0) ATTRIB(XonoticServerList, columnPlayersSize, float, 0) + ATTRIB(XonoticServerList, lockedSelectedItem, bool, true) // initially keep selected the first item of the list, avoiding an unwanted scrolling ATTRIB(XonoticServerList, selectedServer, string, string_null) // to restore selected server when needed METHOD(XonoticServerList, setSelected, void(entity, float)) @@ -460,6 +461,7 @@ void XonoticServerList_configureXonoticServerList(entity me) } void XonoticServerList_setSelected(entity me, int i) { + me.lockedSelectedItem = false; //int save = me.selectedItem; SUPER(XonoticServerList).setSelected(me, i); /* @@ -717,12 +719,26 @@ void XonoticServerList_draw(entity me) me.infoButton.disabled = ((me.nItems == 0) || !owned); me.favoriteButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == "")); - if(me.selectedServer) + if(me.lockedSelectedItem) + { + if(me.nItems > 0) + { + if(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem) != me.selectedServer) + { + if(me.selectedServer) + strunzone(me.selectedServer); + me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem)); + } + found = true; + } + } + else if(me.selectedServer) { for(i = 0; i < me.nItems; ++i) { if(gethostcachestring(SLIST_FIELD_CNAME, i) == me.selectedServer) { + // don't follow the selected item with SUPER(XonoticServerList).setSelected(me, i); me.selectedItem = i; found = true; break; @@ -733,8 +749,9 @@ void XonoticServerList_draw(entity me) { if(me.nItems > 0) { + // selected server disappeared, select the last server (scrolling to it) if(me.selectedItem >= me.nItems) - me.selectedItem = me.nItems - 1; + SUPER(XonoticServerList).setSelected(me, me.nItems - 1); if(me.selectedServer) strunzone(me.selectedServer); me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem));