-#ifdef INTERFACE
-CLASS(XonoticServerList) EXTENDS(XonoticListBox)
- METHOD(XonoticServerList, configureXonoticServerList, void(entity))
+#ifndef SERVERLIST_H
+#define SERVERLIST_H
+#include "listbox.qc"
+CLASS(XonoticServerList, XonoticListBox)
+ METHOD(XonoticServerList, configureXonoticServerList, void(entity));
ATTRIB(XonoticServerList, rowsPerItem, float, 1)
- METHOD(XonoticServerList, draw, void(entity))
- METHOD(XonoticServerList, drawListBoxItem, void(entity, float, vector, float))
- METHOD(XonoticServerList, doubleClickListBoxItem, void(entity, float, vector))
- METHOD(XonoticServerList, resizeNotify, void(entity, vector, vector, vector, vector))
- METHOD(XonoticServerList, keyDown, float(entity, float, float, float))
- METHOD(XonoticServerList, toggleFavorite, void(entity, string))
+ METHOD(XonoticServerList, draw, void(entity));
+ METHOD(XonoticServerList, drawListBoxItem, void(entity, int, vector, bool, bool));
+ METHOD(XonoticServerList, doubleClickListBoxItem, void(entity, float, vector));
+ METHOD(XonoticServerList, resizeNotify, void(entity, vector, vector, vector, vector));
+ METHOD(XonoticServerList, keyDown, float(entity, float, float, float));
+ METHOD(XonoticServerList, toggleFavorite, void(entity, string));
ATTRIB(XonoticServerList, iconsSizeFactor, float, 0.85)
+ METHOD(XonoticServerList, mouseMove, float(entity, vector));
+ ATTRIB(XonoticServerList, mouseOverIcons, bool, false)
+ METHOD(XonoticServerList, focusedItemChangeNotify, void(entity));
ATTRIB(XonoticServerList, realFontSize, vector, '0 0 0')
ATTRIB(XonoticServerList, realUpperMargin, float, 0)
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))
- METHOD(XonoticServerList, setSortOrder, void(entity, float, float))
+ METHOD(XonoticServerList, setSelected, void(entity, float));
+ METHOD(XonoticServerList, setSortOrder, void(entity, float, float));
ATTRIB(XonoticServerList, filterShowEmpty, float, 1)
ATTRIB(XonoticServerList, filterShowFull, float, 1)
ATTRIB(XonoticServerList, filterString, string, string_null)
ATTRIB(XonoticServerList, ipAddressBox, entity, NULL)
ATTRIB(XonoticServerList, favoriteButton, entity, NULL)
ATTRIB(XonoticServerList, nextRefreshTime, float, 0)
- METHOD(XonoticServerList, refreshServerList, void(entity, float)) // refresh mode: REFRESHSERVERLIST_*
+ METHOD(XonoticServerList, refreshServerList, void(entity, float)); // refresh mode: REFRESHSERVERLIST_*
ATTRIB(XonoticServerList, needsRefresh, float, 1)
- METHOD(XonoticServerList, focusEnter, void(entity))
- METHOD(XonoticServerList, positionSortButton, void(entity, entity, float, float, string, void(entity, entity)))
+ METHOD(XonoticServerList, focusEnter, void(entity));
+ METHOD(XonoticServerList, positionSortButton, void(entity, entity, float, float, string, void(entity, entity)));
ATTRIB(XonoticServerList, sortButton1, entity, NULL)
ATTRIB(XonoticServerList, sortButton2, entity, NULL)
ATTRIB(XonoticServerList, sortButton3, entity, NULL)
ATTRIB(XonoticServerList, seenIPv6, float, 0)
ATTRIB(XonoticServerList, categoriesHeight, float, 1.25)
- METHOD(XonoticServerList, getTotalHeight, float(entity))
- METHOD(XonoticServerList, getItemAtPos, float(entity, float))
- METHOD(XonoticServerList, getItemStart, float(entity, float))
- METHOD(XonoticServerList, getItemHeight, float(entity, float))
+ METHOD(XonoticServerList, getTotalHeight, float(entity));
+ METHOD(XonoticServerList, getItemAtPos, float(entity, float));
+ METHOD(XonoticServerList, getItemStart, float(entity, float));
+ METHOD(XonoticServerList, getItemHeight, float(entity, float));
ENDCLASS(XonoticServerList)
entity makeXonoticServerList();
void ServerList_Update_favoriteButton(entity btn, entity me);
// fields for category entities
-const float MAX_CATEGORIES = 9;
-const float CATEGORY_FIRST = 1;
+const int MAX_CATEGORIES = 9;
+const int CATEGORY_FIRST = 1;
entity categories[MAX_CATEGORIES];
-float category_ent_count;
+int category_ent_count;
.string cat_name;
.string cat_string;
.string cat_enoverride_string;
.float cat_dioverride;
// fields for drawing categories
-float category_name[MAX_CATEGORIES];
-float category_item[MAX_CATEGORIES];
-float category_draw_count;
+int category_name[MAX_CATEGORIES];
+int category_item[MAX_CATEGORIES];
+int category_draw_count;
#define SLIST_CATEGORIES \
SLIST_CATEGORY(CAT_FAVORITED, "", "", ZCTX(_("SLCAT^Favorites"))) \
#define SLIST_CATEGORY_AUTOCVAR(name) autocvar_menu_slist_categories_##name##_override
#define SLIST_CATEGORY(name,enoverride,dioverride,str) \
- float name; \
+ int name; \
string SLIST_CATEGORY_AUTOCVAR(name) = enoverride;
SLIST_CATEGORIES
#undef SLIST_CATEGORY
#define SLIST_CATEGORY(name,enoverride,dioverride,str) \
SET_FIELD_COUNT(name, CATEGORY_FIRST, category_ent_count) \
CHECK_MAX_COUNT(name, MAX_CATEGORIES, category_ent_count, "SLIST_CATEGORY") \
- cat = spawn(); \
- categories[name - 1] = cat; \
- cat.classname = "slist_category"; \
+ cat = categories[name - 1] = new(slist_category); \
cat.cat_name = strzone(#name); \
cat.cat_enoverride_string = strzone(SLIST_CATEGORY_AUTOCVAR(name)); \
cat.cat_dioverride_string = strzone(dioverride); \
SLIST_CATEGORIES
#undef SLIST_CATEGORY
- float i, x, catnum;
+ int i, x, catnum;
string s;
#define PROCESS_OVERRIDE(override_string,override_field) \
} \
else \
{ \
- printf( \
+ LOG_INFOF( \
"RegisterSLCategories(): Improper override '%s' for category '%s'!\n", \
s, \
categories[i].cat_name \
}
// Supporting Functions
-entity RetrieveCategoryEnt(float catnum)
+entity RetrieveCategoryEnt(int catnum)
{
if((catnum > 0) && (catnum <= category_ent_count))
{
else
{
error(sprintf("RetrieveCategoryEnt(%d): Improper category number!\n", catnum));
- return world;
+ return NULL;
}
}
-float IsServerInList(string list, string srv)
+bool IsServerInList(string list, string srv)
{
string p;
- float i, n;
+ int i, n;
if(srv == "")
return false;
srv = netaddress_resolve(srv, 26000);
return false;
}
-float CheckCategoryOverride(float cat)
+int CheckCategoryOverride(int cat)
{
entity catent = RetrieveCategoryEnt(cat);
if(catent)
{
- float override = (autocvar_menu_slist_categories ? catent.cat_enoverride : catent.cat_dioverride);
+ int override = (autocvar_menu_slist_categories ? catent.cat_enoverride : catent.cat_dioverride);
if(override) { return override; }
else { return cat; }
}
}
}
-float CheckCategoryForEntry(float entry)
+int CheckCategoryForEntry(int entry)
{
string s, k, v, modtype = "";
- float j, m, impure = 0, freeslots = 0, sflags = 0;
+ int j, m, impure = 0, freeslots = 0, sflags = 0;
s = gethostcachestring(SLIST_FIELD_QCSTATUS, entry);
m = tokenizebyseparator(s, ":");
case "cts":
case "xdf": { return CAT_DEFRAG; }
- default: { dprintf("Found strange mod type: %s\n", modtype); return CAT_MODIFIED; }
+ default: { LOG_TRACEF("Found strange mod type: %s\n", modtype); return CAT_MODIFIED; }
}
}
void XonoticServerList_toggleFavorite(entity me, string srv)
{
string s, s0, s1, s2, srv_resolved, p;
- float i, n, f;
+ int i, n;
+ bool f = false;
srv_resolved = netaddress_resolve(srv, 26000);
p = crypto_getidfp(srv_resolved);
s = cvar_string("net_slist_favorites");
n = tokenize_console(s);
- f = 0;
for(i = 0; i < n; ++i)
{
if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
cvar_set("net_slist_favorites", strcat(s0, s1, s2));
s = cvar_string("net_slist_favorites");
n = tokenize_console(s);
- f = 1;
+ f = true;
--i;
}
void ServerList_Update_favoriteButton(entity btn, entity me)
{
- me.favoriteButton.setText(me.favoriteButton,
- (IsFavorite(me.ipAddressBox.text) ?
- _("Remove") : _("Favorite")
- )
- );
+ entity e = me.favoriteButton;
+ if(IsFavorite(me.ipAddressBox.text))
+ {
+ e.setText(e, _("Remove"));
+ clearTooltip(e);
+ }
+ else
+ {
+ e.setText(e, _("Favorite"));
+ setZonedTooltip(e, _("Bookmark the currently highlighted server so that it's faster to find in the future"), string_null);
+ }
}
entity makeXonoticServerList()
{
entity me;
- me = spawnXonoticServerList();
+ me = NEW(XonoticServerList);
me.configureXonoticServerList(me);
return me;
}
// clear list
me.nItems = 0;
}
-void XonoticServerList_setSelected(entity me, float i)
+void XonoticServerList_setSelected(entity me, int i)
{
- float save;
- save = me.selectedItem;
+ me.lockedSelectedItem = false;
+ //int save = me.selectedItem;
SUPER(XonoticServerList).setSelected(me, i);
/*
if(me.selectedItem == save)
me.ipAddressBox.cursorPos = strlen(me.selectedServer);
me.ipAddressBoxFocused = -1;
}
-void XonoticServerList_refreshServerList(entity me, float mode)
+void XonoticServerList_refreshServerList(entity me, int mode)
{
//print("refresh of type ", ftos(mode), "\n");
if(mode >= REFRESHSERVERLIST_REFILTER)
{
- float m, i, n;
- float listflags = 0;
+ float m;
+ int i, n;
+ int listflags = 0;
string s, typestr, modstr;
s = me.filterString;
void XonoticServerList_draw(entity me)
{
- float i, found, owned;
+ int i;
+ bool found = false, owned;
if(_Nex_ExtResponseSystem_BannedServersNeedsRefresh)
{
me.infoButton.disabled = ((me.nItems == 0) || !owned);
me.favoriteButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == ""));
- found = 0;
- 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 = 1;
+ found = true;
break;
}
}
{
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));
me.ipAddressBox.cursorPos = 0;
me.ipAddressBoxFocused = -1;
}
-void XonoticServerList_setSortOrder(entity me, float fld, float direction)
+void XonoticServerList_setSortOrder(entity me, int fld, int direction)
{
if(me.currentSortField == fld)
direction = -me.currentSortOrder;
me.positionSortButton(me, me.sortButton4, me.columnTypeOrigin, me.columnTypeSize, _("Type"), ServerList_TypeSort_Click);
me.positionSortButton(me, me.sortButton5, me.columnPlayersOrigin, me.columnPlayersSize, _("Players"), ServerList_PlayerSort_Click);
- float f;
- f = me.currentSortField;
+ int f = me.currentSortField;
if(f >= 0)
{
me.currentSortField = -1;
vector sz = boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size);
DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz);
}
-void XonoticServerList_doubleClickListBoxItem(entity me, float i, vector where)
+void XonoticServerList_doubleClickListBoxItem(entity me, int i, vector where)
{
ServerList_Connect_Click(NULL, me);
}
-void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
+void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
{
// layout: Ping, Server name, Map name, NP, TP, MP
- float p, q;
- float isv4, isv6;
+ float p;
+ int q;
+ bool isv4, isv6;
vector theColor;
float theAlpha;
- float m, pure, freeslots, j, sflags;
+ bool pure = false, pure_available = false;
+ int freeslots = -1, sflags = -1, j, m;
string s, typestr, versionstr, k, v, modname;
//printf("time: %f, i: %d, item: %d, nitems: %d\n", time, i, item, me.nItems);
if(isSelected)
draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
+ else if(isFocused)
+ {
+ me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
+ draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
+ }
s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
m = tokenizebyseparator(s, ":");
versionstr = argv(1);
}
freeslots = -1;
- sflags = -1;
modname = "";
- pure = 0;
for(j = 2; j < m; ++j)
{
if(argv(j) == "")
k = substring(argv(j), 0, 1);
v = substring(argv(j), 1, -1);
if(k == "P")
- pure = stof(v);
+ {
+ pure = (stof(v) == 0);
+ pure_available = true;
+ }
else if(k == "S")
freeslots = stof(v);
else if(k == "F")
- sflags = stof(v);
+ sflags = stoi(v);
else if(k == "M")
modname = v;
}
modname = "Xonotic";
#endif
+ string original_modname = modname;
+ modname = strtolower(modname);
+
/*
SLIST_FIELD_MOD = gethostcacheindexforkey("mod");
s = gethostcachestring(SLIST_FIELD_MOD, i);
if(s != "data")
- if(modname == "Xonotic")
+ if(modname == "xonotic")
modname = s;
*/
// list the mods here on which the pure server check actually works
- if(modname != "Xonotic")
- if(modname != "InstaGib" || modname != "MinstaGib")
- if(modname != "CTS")
- if(modname != "NIX")
- if(modname != "NewToys")
- pure = 0;
+ if(modname != "xonotic")
+ if(modname != "instagib" || modname != "minstagib")
+ if(modname != "cts")
+ if(modname != "nix")
+ if(modname != "newtoys")
+ pure_available = false;
if(gethostcachenumber(SLIST_FIELD_FREESLOTS, i) <= 0)
theAlpha = SKINALPHA_SERVERLIST_FULL;
theAlpha = 1;
p = gethostcachenumber(SLIST_FIELD_PING, i);
- const float PING_LOW = 75;
- const float PING_MED = 200;
- const float PING_HIGH = 500;
+ const int PING_LOW = 75;
+ const int PING_MED = 200;
+ const int PING_HIGH = 500;
if(p < PING_LOW)
theColor = SKINCOLOR_SERVERLIST_LOWPING + (SKINCOLOR_SERVERLIST_MEDPING - SKINCOLOR_SERVERLIST_LOWPING) * (p / PING_LOW);
else if(p < PING_MED)
s = gethostcachestring(SLIST_FIELD_CNAME, i);
- isv4 = isv6 = 0;
+ isv4 = isv6 = false;
if(substring(s, 0, 1) == "[")
{
- isv6 = 1;
+ isv6 = true;
me.seenIPv6 += 1;
}
else if(strstrofs("0123456789", substring(s, 0, 1), 0) >= 0)
{
- isv4 = 1;
+ isv4 = true;
me.seenIPv4 += 1;
}
iconPos_x = (me.columnIconsSize - 3 * iconSize.x) * 0.5;
iconPos_y = (1 - iconSize.y) * 0.5;
- string n;
-
- if (!(me.seenIPv4 && me.seenIPv6))
+ // IP
+ if(me.seenIPv4 && me.seenIPv6)
{
- iconPos.x += iconSize.x * 0.5;
- }
- else if(me.seenIPv4 && me.seenIPv6)
- {
- n = string_null;
if(isv6)
- draw_PreloadPictureWithFlags(n = strcat(SKINGFX_SERVERLIST_ICON, "_ipv6"), 0); // PRECACHE_PIC_MIPMAP
+ draw_Picture(iconPos, "icon_ipv6", iconSize, '1 1 1', 1);
else if(isv4)
- draw_PreloadPictureWithFlags(n = strcat(SKINGFX_SERVERLIST_ICON, "_ipv4"), 0); // PRECACHE_PIC_MIPMAP
- if(n)
- draw_Picture(iconPos, n, iconSize, '1 1 1', 1);
- iconPos.x += iconSize.x;
+ draw_Picture(iconPos, "icon_ipv4", iconSize, '1 1 1', 1);
}
+ iconPos.x += iconSize.x;
+
+ // AES
if(q > 0)
- {
- draw_PreloadPictureWithFlags(n = strcat(SKINGFX_SERVERLIST_ICON, "_aeslevel", ftos(q)), 0); // PRECACHE_PIC_MIPMAP
- draw_Picture(iconPos, n, iconSize, '1 1 1', 1);
- }
+ draw_Picture(iconPos, strcat("icon_aeslevel", ftos(q)), iconSize, '1 1 1', 1);
+
iconPos.x += iconSize.x;
- if(modname == "Xonotic")
+ // Mod
+ if(modname == "xonotic")
{
- if(pure == 0)
- {
- draw_PreloadPictureWithFlags(n = strcat(SKINGFX_SERVERLIST_ICON, "_pure1"), PRECACHE_PIC_MIPMAP);
- draw_Picture(iconPos, n, iconSize, '1 1 1', 1);
- }
+ // Here, pure_available should always be set. If not, consider
+ // it an impurity.
+ if(pure_available && pure)
+ draw_Picture(iconPos, "icon_pure1", iconSize, '1 1 1', 1);
}
else
{
- draw_PreloadPictureWithFlags(n = strcat(SKINGFX_SERVERLIST_ICON, "_mod_", modname), PRECACHE_PIC_MIPMAP);
- if(draw_PictureSize(n) == '0 0 0')
- draw_PreloadPictureWithFlags(n = strcat(SKINGFX_SERVERLIST_ICON, "_mod_"), PRECACHE_PIC_MIPMAP);
- if(pure == 0)
- draw_Picture(iconPos, n, iconSize, '1 1 1', 1);
+ string icon = strcat("icon_mod_", modname);
+ if(draw_PictureSize(icon) == '0 0 0')
+ icon = "icon_mod_";
+
+ // In mods, pure_available not being present indicates
+ // non-support of the feature. Just show the mod icon as is
+ // then.
+ if(pure_available && !pure)
+ draw_Picture(iconPos, icon, iconSize, '1 1 1', SKINALPHA_SERVERLIST_ICON_NONPURE);
else
- draw_Picture(iconPos, n, iconSize, '1 1 1', SKINALPHA_SERVERLIST_ICON_NONPURE);
+ draw_Picture(iconPos, icon, iconSize, '1 1 1', 1);
}
+
iconPos.x += iconSize.x;
+ // Stats
if(sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS))
+ draw_Picture(iconPos, "icon_stats1", iconSize, '1 1 1', 1);
+
+ if(isFocused && me.mouseOverIcons && !me.tooltip)
{
- draw_PreloadPictureWithFlags(n = strcat(SKINGFX_SERVERLIST_ICON, "_stats1"), 0); // PRECACHE_PIC_MIPMAP
- draw_Picture(iconPos, n, iconSize, '1 1 1', 1);
+ string t = "";
+ if(me.seenIPv4 && me.seenIPv6)
+ t = strcat(t, (isv6) ? "IPv6, " : "IPv4, ");
+ t = strcat(t, _("encryption:"), " ", (q ? sprintf(_("AES level %d"), q) : ZCTX(_("ENC^none"))), ", ");
+ t = strcat(t, sprintf(_("mod: %s"), ((modname == "xonotic") ? ZCTX(_("MOD^Default")) : original_modname)));
+ 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")));
+ setZonedTooltip(me, t, string_null);
}
- iconPos.x += iconSize.x;
-
// --------------
// RENDER TEXT
// --------------
draw_Text(me.realUpperMargin * eY + (me.columnPlayersOrigin + (me.columnPlayersSize - draw_TextWidth(s, 0, me.realFontSize)) * 0.5) * eX, s, me.realFontSize, theColor, theAlpha, 0);
}
-float XonoticServerList_keyDown(entity me, float scan, float ascii, float shift)
+void XonoticServerList_focusedItemChangeNotify(entity me)
+{
+ clearTooltip(me);
+}
+
+float XonoticServerList_mouseMove(entity me, vector pos)
+{
+ if(!SUPER(XonoticServerList).mouseMove(me, pos))
+ {
+ me.mouseOverIcons = false;
+ clearTooltip(me);
+ return 1;
+ }
+
+ me.mouseOverIcons = (pos_x <= me.columnIconsSize);
+ if(!me.mouseOverIcons)
+ clearTooltip(me);
+ return 1;
+}
+
+bool XonoticServerList_keyDown(entity me, int scan, bool ascii, bool shift)
{
vector org, sz;
if(scan == K_ENTER || scan == K_KP_ENTER)
{
ServerList_Connect_Click(NULL, me);
- return 1;
+ return true;
}
else if(scan == K_MOUSE2 || scan == K_SPACE)
{
m_play_click_sound(MENU_SOUND_OPEN);
main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem);
DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
else if(scan == K_INS || scan == K_MOUSE3 || scan == K_KP_INS)
{
{
me.toggleFavorite(me, me.selectedServer);
me.ipAddressBoxFocused = -1;
- return 1;
+ return true;
}
- return 0;
+ return false;
}
else if(SUPER(XonoticServerList).keyDown(me, scan, ascii, shift))
- return 1;
+ return true;
else if(!me.controlledTextbox)
- return 0;
+ return false;
else
return me.controlledTextbox.keyDown(me.controlledTextbox, scan, ascii, shift);
}
-float XonoticServerList_getTotalHeight(entity me) {
+float XonoticServerList_getTotalHeight(entity me)
+{
float num_normal_rows = me.nItems;
- float num_headers = category_draw_count;
+ int num_headers = category_draw_count;
return me.itemHeight * (num_normal_rows + me.categoriesHeight * num_headers);
}
-float XonoticServerList_getItemAtPos(entity me, float pos) {
+int XonoticServerList_getItemAtPos(entity me, float pos)
+{
pos = pos / me.itemHeight;
- float i;
+ int i;
for (i = category_draw_count - 1; i >= 0; --i) {
- float itemidx = category_item[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));
// No category matches? Note that category 0 is... 0. Therefore no headings exist at all.
return floor(pos);
}
-float XonoticServerList_getItemStart(entity me, float item) {
- float i;
+float XonoticServerList_getItemStart(entity me, int item)
+{
+ int i;
for (i = category_draw_count - 1; i >= 0; --i) {
- float itemidx = category_item[i];
+ int itemidx = category_item[i];
float itempos = i * me.categoriesHeight + category_item[i];
if (item >= itemidx + 1)
return (itempos + me.categoriesHeight + 1 + item - (itemidx + 1)) * me.itemHeight;
// No category matches? Note that category 0 is... 0. Therefore no headings exist at all.
return item * me.itemHeight;
}
-float XonoticServerList_getItemHeight(entity me, float item) {
- float i;
+float XonoticServerList_getItemHeight(entity me, int item)
+{
+ int i;
for (i = 0; i < category_draw_count; ++i) {
// Matches exactly the headings with increased height.
if (item == category_item[i])