From 6802e61fd5854b105583c072ad56ef8c3bf4c032 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 8 Apr 2018 13:07:55 +0200 Subject: [PATCH] Menu, server list: hide initial fake selection (always 1st server of the list) and disable Favorite, Info and Connect buttons as selected server is mutable; it fixes Favorite button not working until user manually selects a server --- qcsrc/menu/xonotic/serverlist.qc | 17 ++++++++--------- qcsrc/menu/xonotic/serverlist.qh | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index 11ab47116..694e85d91 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -547,9 +547,9 @@ void XonoticServerList_draw(entity me) } else { me.nItems = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); } - me.connectButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == "")); - me.infoButton.disabled = ((me.nItems == 0) || !owned); - me.favoriteButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == "")); + me.connectButton.disabled = (me.lockedSelectedItem || (me.nItems == 0 && me.ipAddressBox.text == "")); + me.infoButton.disabled = (me.lockedSelectedItem || me.nItems == 0 || !owned); + me.favoriteButton.disabled = (me.lockedSelectedItem || (me.nItems == 0 && me.ipAddressBox.text == "")); if(me.lockedSelectedItem) { @@ -769,11 +769,10 @@ void XonoticServerList_resizeNotify(entity me, vector relOrigin, vector relSize, } void ServerList_Connect_Click(entity btn, entity me) { - localcmd(sprintf("connect %s\n", - ((me.ipAddressBox.text != "") ? - me.ipAddressBox.text : me.selectedServer - ) - )); + if (me.lockedSelectedItem) + return; + string sv = (me.ipAddressBox.text != "") ? me.ipAddressBox.text : me.selectedServer; + localcmd(sprintf("connect %s\n", sv)); } void ServerList_Favorite_Click(entity btn, entity this) { @@ -851,7 +850,7 @@ void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool is } } - if(isSelected) + if(isSelected && !me.lockedSelectedItem) draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED); else if(isFocused) { diff --git a/qcsrc/menu/xonotic/serverlist.qh b/qcsrc/menu/xonotic/serverlist.qh index e45abfda3..32359ad2b 100644 --- a/qcsrc/menu/xonotic/serverlist.qh +++ b/qcsrc/menu/xonotic/serverlist.qh @@ -30,7 +30,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, lockedSelectedItem, bool, true); // initially keep selected the first item of the list to avoid unwanted scrolling ATTRIB(XonoticServerList, selectedServer, string); // to restore selected server when needed METHOD(XonoticServerList, setSelected, void(entity, float)); -- 2.39.2