X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fserverlist.qc;h=7d5d21e30df9c2653f448cced6b08c18d141fb43;hb=abf4b5a430d71fc83abbe90da9b17b457a65e149;hp=578e1eca6f35c9deb4900a49caec0f01dba2ad20;hpb=24151b08c3de08e46dace760129f0526a455be4b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index 578e1eca6..7d5d21e30 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -6,6 +6,12 @@ #include "dialog_multiplayer_join_serverinfo.qh" #include +#define IsFavorite(srv) IsServerInList(cvar_string("net_slist_favorites"), srv) +#define IsPromoted(srv) IsServerInList(_Nex_ExtResponseSystem_PromotedServers, srv) +#define IsRecommended(srv) IsServerInList(_Nex_ExtResponseSystem_RecommendedServers, srv) + +float m_gethostcachecategory(float entry) { return CategoryOverride(CategoryForEntry(entry)); } + void SL_ProcessCategoryOverrides(.string override_field_string, .float override_field) { for (int i = 0; i < category_ent_count; ++i) @@ -341,6 +347,10 @@ void XonoticServerList_refreshServerList(entity me, int mode) if(!me.filterShowEmpty) sethostcachemasknumber(++m, SLIST_FIELD_NUMHUMANS, 1, SLIST_TEST_GREATEREQUAL); + // show laggy button + if(!me.filterShowLaggy && autocvar_menu_slist_maxping > 0) + sethostcachemasknumber(++m, SLIST_FIELD_PING, autocvar_menu_slist_maxping, SLIST_TEST_LESSEQUAL); + // gametype filtering if(typestr != "") sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, strcat(typestr, ":"), SLIST_TEST_STARTSWITH); @@ -394,6 +404,8 @@ void XonoticServerList_focusEnter(entity me) void XonoticServerList_draw(entity me) { + me.serversHeight = (autocvar_menu_slist_categories > 0 ? 1.0 : me.categoriesHeight); + if(_Nex_ExtResponseSystem_BannedServersNeedsRefresh) { if(!me.needsRefresh) @@ -440,10 +452,11 @@ void XonoticServerList_draw(entity me) for(int i = 0; i < category_draw_count; ++i) { category_name[i] = -1; category_item[i] = -1; } category_draw_count = 0; + me.nItems = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); + if(autocvar_menu_slist_categories >= 0) // if less than 0, don't even draw a category heading for favorites { - float itemcount = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); - me.nItems = itemcount; + int itemcount = me.nItems; //float visible = floor(me.scrollPos / me.itemHeight); // ^ unfortunately no such optimization can be made-- we must process through the @@ -526,7 +539,6 @@ void XonoticServerList_draw(entity me) me.nItems = itemcount; } } - else { me.nItems = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); } me.connectButton.disabled = (me.ipAddressBox.text == ""); //me.disconnectButton.disabled = (!(gamestatus & (GAME_ISSERVER | GAME_CONNECTED))); @@ -679,6 +691,15 @@ void ServerList_ShowFull_Click(entity box, entity me) me.ipAddressBox.cursorPos = 0; me.ipAddressBoxFocused = -1; } +void ServerList_ShowLaggy_Click(entity box, entity me) +{ + box.setChecked(box, me.filterShowLaggy = !me.filterShowLaggy); + me.refreshServerList(me, REFRESHSERVERLIST_REFILTER); + + me.ipAddressBox.setText(me.ipAddressBox, ""); + me.ipAddressBox.cursorPos = 0; + me.ipAddressBoxFocused = -1; +} void XonoticServerList_setSortOrder(entity me, int fld, int direction) { if(me.currentSortField == fld) @@ -762,8 +783,10 @@ void ServerList_Info_Click(entity btn, entity me) if (me.nItems != 0) main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem); - vector org = boxToGlobal(eY * (me.selectedItem * me.itemHeight - me.scrollPos), me.origin, me.size); - vector sz = boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size); + float thisPos = me.getItemStart(me, me.selectedItem); + float thisHeight = me.getItemHeight(me, me.selectedItem); + vector org = boxToGlobal(eY * (thisPos - me.scrollPos), me.origin, me.size); + vector sz = boxToGlobalSize(eY * thisHeight + eX * (1 - me.controlWidth), me.size); DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz); } void XonoticServerList_doubleClickListBoxItem(entity me, int i, vector where) @@ -775,8 +798,8 @@ void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool is vector oldscale = draw_scale; vector oldshift = draw_shift; #define SET_YRANGE(start,end) \ - draw_scale = boxToGlobalSize(eX + eY * (end - start), oldscale); \ - draw_shift = boxToGlobal(eY * start, oldshift, oldscale); + draw_scale = boxToGlobalSize(eX + eY * ((end) - (start)), oldscale); \ + draw_shift = boxToGlobal(eY * (start), oldshift, oldscale); int c; for (c = 0; c < category_draw_count; ++c) { @@ -813,6 +836,10 @@ void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool is } } + // Now categories are done. Set the Y range in stone. + oldscale = draw_scale; + oldshift = draw_shift; + if(isSelected && !me.lockedSelectedItem) draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED); else if(isFocused) @@ -959,7 +986,7 @@ void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool is // -------------- vector iconSize = '0 0 0'; iconSize_y = me.realFontSize.y * me.iconsSizeFactor; - iconSize_x = me.realFontSize.x * me.iconsSizeFactor; + iconSize_x = me.realFontSize.x * me.iconsSizeFactor * me.serversHeight; vector iconPos = '0 0 0'; iconPos_x = (me.columnIconsSize - 3 * iconSize.x) * 0.5; @@ -1009,7 +1036,12 @@ void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool is // Stats if(sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) - draw_Picture(iconPos, "icon_stats1", iconSize, '1 1 1', 1); + { + if (sflags & SERVERFLAG_PLAYERSTATS_CUSTOM) + draw_Picture(iconPos, "icon_mod_", iconSize, '1 1 1', 1); // TODO: custom stats server icon + else + draw_Picture(iconPos, "icon_stats1", iconSize, '1 1 1', 1); + } if(isFocused && me.mouseOverIcons && !me.tooltip) { @@ -1021,13 +1053,19 @@ void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool is if(pure_available) t = strcat(t, sprintf(" (%s)", (pure) ? _("official settings") : _("modified settings"))); t = strcat(t, ", "); - t = strcat(t, ((sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) ? _("stats enabled") : _("stats disabled"))); + t = strcat(t, ((sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) ? ((sflags & SERVERFLAG_PLAYERSTATS_CUSTOM) ? _("custom stats server") : _("stats enabled")) : _("stats disabled"))); setZonedTooltip(me, t, string_null); } // -------------- // RENDER TEXT // -------------- + // Center it in the row. + SET_YRANGE( + 0.5 - 0.5 / me.serversHeight, + 0.5 + 0.5 / me.serversHeight + ); + // ping s = ftos(ping); draw_Text(me.realUpperMargin * eY + (me.columnPingOrigin + me.columnPingSize - draw_TextWidth(s, 0, me.realFontSize)) * eX, s, me.realFontSize, theColor, theAlpha, 0); @@ -1080,8 +1118,10 @@ bool XonoticServerList_keyDown(entity me, int scan, bool ascii, bool shift) { if(me.nItems != 0) { - vector org = boxToGlobal(eY * (me.selectedItem * me.itemHeight - me.scrollPos), me.origin, me.size); - vector sz = boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size); + float thisPos = me.getItemStart(me, me.selectedItem); + float thisHeight = me.getItemHeight(me, me.selectedItem); + vector org = boxToGlobal(eY * (thisPos - me.scrollPos), me.origin, me.size); + vector sz = boxToGlobalSize(eY * thisHeight + eX * (1 - me.controlWidth), me.size); m_play_click_sound(MENU_SOUND_OPEN); main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem); DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz); @@ -1111,41 +1151,42 @@ float XonoticServerList_getTotalHeight(entity me) { float num_normal_rows = me.nItems; int num_headers = category_draw_count; - return me.itemHeight * (num_normal_rows + me.categoriesHeight * num_headers); + return me.itemHeight * (me.serversHeight * num_normal_rows + me.categoriesHeight * num_headers); } int XonoticServerList_getItemAtPos(entity me, float pos) { pos = pos / me.itemHeight; for (int i = category_draw_count - 1; i >= 0; --i) { int itemidx = category_item[i]; - float itempos = i * me.categoriesHeight + category_item[i]; - if (pos >= itempos + me.categoriesHeight + 1) - return itemidx + 1 + floor(pos - (itempos + me.categoriesHeight + 1)); + float itempos = i * me.categoriesHeight + itemidx * me.serversHeight; + if (pos >= itempos + me.categoriesHeight + me.serversHeight) + return itemidx + 1 + floor((pos - (itempos + me.categoriesHeight + me.serversHeight)) / me.serversHeight); if (pos >= itempos) return itemidx; } // No category matches? Note that category 0 is... 0. Therefore no headings exist at all. - return floor(pos); + return floor(pos / me.serversHeight); } float XonoticServerList_getItemStart(entity me, int item) { for (int i = category_draw_count - 1; i >= 0; --i) { int itemidx = category_item[i]; - float itempos = i * me.categoriesHeight + category_item[i]; + float itempos = i * me.categoriesHeight + itemidx * me.serversHeight; if (item >= itemidx + 1) - return (itempos + me.categoriesHeight + 1 + item - (itemidx + 1)) * me.itemHeight; + return (itempos + me.categoriesHeight + (1 + item - (itemidx + 1)) * me.serversHeight) * me.itemHeight; if (item >= itemidx) return itempos * me.itemHeight; } // No category matches? Note that category 0 is... 0. Therefore no headings exist at all. - return item * me.itemHeight; + return item * me.serversHeight * me.itemHeight; } float XonoticServerList_getItemHeight(entity me, int item) { for (int i = 0; i < category_draw_count; ++i) { // Matches exactly the headings with increased height. + // FIXME server row next to the heading is slightly smaller than others if (autocvar_menu_slist_categories <= 0) if (item == category_item[i]) - return me.itemHeight * (me.categoriesHeight + 1); + return me.itemHeight * (me.categoriesHeight + me.serversHeight); } - return me.itemHeight; + return me.itemHeight * me.serversHeight; }