4 CLASS(XonoticServerList, XonoticListBox)
5 METHOD(XonoticServerList, configureXonoticServerList, void(entity));
6 ATTRIB(XonoticServerList, rowsPerItem, float, 1);
7 METHOD(XonoticServerList, draw, void(entity));
8 METHOD(XonoticServerList, drawListBoxItem, void(entity, int, vector, bool, bool));
9 METHOD(XonoticServerList, doubleClickListBoxItem, void(entity, float, vector));
10 METHOD(XonoticServerList, resizeNotify, void(entity, vector, vector, vector, vector));
11 METHOD(XonoticServerList, keyDown, float(entity, float, float, float));
12 METHOD(XonoticServerList, toggleFavorite, void(entity, string));
14 ATTRIB(XonoticServerList, iconsSizeFactor, float, 0.85);
15 METHOD(XonoticServerList, mouseMove, float(entity, vector));
16 ATTRIB(XonoticServerList, mouseOverIcons, bool, false);
17 METHOD(XonoticServerList, focusedItemChangeNotify, void(entity));
19 ATTRIB(XonoticServerList, realFontSize, vector, '0 0 0');
20 ATTRIB(XonoticServerList, realUpperMargin, float, 0);
21 ATTRIB(XonoticServerList, columnIconsOrigin, float, 0);
22 ATTRIB(XonoticServerList, columnIconsSize, float, 0);
23 ATTRIB(XonoticServerList, columnPingOrigin, float, 0);
24 ATTRIB(XonoticServerList, columnPingSize, float, 0);
25 ATTRIB(XonoticServerList, columnNameOrigin, float, 0);
26 ATTRIB(XonoticServerList, columnNameSize, float, 0);
27 ATTRIB(XonoticServerList, columnMapOrigin, float, 0);
28 ATTRIB(XonoticServerList, columnMapSize, float, 0);
29 ATTRIB(XonoticServerList, columnTypeOrigin, float, 0);
30 ATTRIB(XonoticServerList, columnTypeSize, float, 0);
31 ATTRIB(XonoticServerList, columnPlayersOrigin, float, 0);
32 ATTRIB(XonoticServerList, columnPlayersSize, float, 0);
33 ATTRIB(XonoticServerList, lockedSelectedItem, bool, true); // initially keep selected the first item of the list to avoid unwanted scrolling
35 ATTRIB(XonoticServerList, selectedServer, string); // to restore selected server when needed
36 METHOD(XonoticServerList, setSelected, void(entity, float));
37 METHOD(XonoticServerList, setSortOrder, void(entity, float, float));
38 ATTRIB(XonoticServerList, filterShowEmpty, float, 1);
39 ATTRIB(XonoticServerList, filterShowFull, float, 1);
40 ATTRIB(XonoticServerList, filterShowLaggy, float, 0);
41 ATTRIB(XonoticServerList, filterString, string);
42 ATTRIB(XonoticServerList, controlledTextbox, entity);
43 ATTRIB(XonoticServerList, ipAddressBox, entity);
44 ATTRIB(XonoticServerList, favoriteButton, entity);
45 ATTRIB(XonoticServerList, nextRefreshTime, float, 0);
46 METHOD(XonoticServerList, refreshServerList, void(entity, float)); // refresh mode: REFRESHSERVERLIST_*
47 ATTRIB(XonoticServerList, needsRefresh, float, 1);
48 METHOD(XonoticServerList, focusEnter, void(entity));
49 METHOD(XonoticServerList, positionSortButton, void(entity, entity, float, float, string, void(entity, entity)));
50 ATTRIB(XonoticServerList, sortButton1, entity);
51 ATTRIB(XonoticServerList, sortButton2, entity);
52 ATTRIB(XonoticServerList, sortButton3, entity);
53 ATTRIB(XonoticServerList, sortButton4, entity);
54 ATTRIB(XonoticServerList, sortButton5, entity);
55 ATTRIB(XonoticServerList, connectButton, entity);
56 ATTRIB(XonoticServerList, infoButton, entity);
57 ATTRIB(XonoticServerList, currentSortOrder, float, 0);
58 ATTRIB(XonoticServerList, currentSortField, float, -1);
60 ATTRIB(XonoticServerList, ipAddressBoxFocused, float, -1);
62 ATTRIB(XonoticServerList, seenIPv4, float, 0);
63 ATTRIB(XonoticServerList, seenIPv6, float, 0);
64 ATTRIB(XonoticServerList, categoriesHeight, float, 1.25);
65 ATTRIB(XonoticServerList, serversHeight, float, 1.0);
67 METHOD(XonoticServerList, getTotalHeight, float(entity));
68 METHOD(XonoticServerList, getItemAtPos, float(entity, float));
69 METHOD(XonoticServerList, getItemStart, float(entity, float));
70 METHOD(XonoticServerList, getItemHeight, float(entity, float));
71 ENDCLASS(XonoticServerList)
72 entity makeXonoticServerList();
74 void RegisterSLCategories();
75 float CategoryForEntry(float entry);
76 void ServerList_Filter_Change(entity box, entity me);
77 void ServerList_Categories_Click(entity box, entity me);
78 void ServerList_ShowEmpty_Click(entity box, entity me);
79 void ServerList_ShowFull_Click(entity box, entity me);
80 void ServerList_ShowLaggy_Click(entity box, entity me);
81 void ServerList_Connect_Click(entity btn, entity me);
82 void ServerList_Update_favoriteButton(entity btn, entity me);
83 void ServerList_Favorite_Click(entity btn, entity me);
84 void ServerList_Info_Click(entity btn, entity me);
86 // server cache fields
87 #define SLIST_FIELDS \
88 SLIST_FIELD(CNAME, "cname") \
89 SLIST_FIELD(PING, "ping") \
90 SLIST_FIELD(GAME, "game") \
91 SLIST_FIELD(MOD, "mod") \
92 SLIST_FIELD(MAP, "map") \
93 SLIST_FIELD(NAME, "name") \
94 SLIST_FIELD(MAXPLAYERS, "maxplayers") \
95 SLIST_FIELD(NUMPLAYERS, "numplayers") \
96 SLIST_FIELD(NUMHUMANS, "numhumans") \
97 SLIST_FIELD(NUMBOTS, "numbots") \
98 SLIST_FIELD(PROTOCOL, "protocol") \
99 SLIST_FIELD(FREESLOTS, "freeslots") \
100 SLIST_FIELD(PLAYERS, "players") \
101 SLIST_FIELD(QCSTATUS, "qcstatus") \
102 SLIST_FIELD(CATEGORY, "category") \
103 SLIST_FIELD(ISFAVORITE, "isfavorite")
105 #define SLIST_FIELD(suffix,name) float SLIST_FIELD_##suffix;
109 float autocvar_menu_slist_categories;
110 float autocvar_menu_slist_categories_onlyifmultiple;
111 float autocvar_menu_slist_purethreshold;
112 float autocvar_menu_slist_modimpurity;
113 float autocvar_menu_slist_maxping = 300;
114 float autocvar_menu_slist_recommendations;
115 float autocvar_menu_slist_recommendations_maxping;
116 float autocvar_menu_slist_recommendations_minfreeslots;
117 float autocvar_menu_slist_recommendations_minhumans;
118 float autocvar_menu_slist_recommendations_purethreshold;
120 const float REFRESHSERVERLIST_RESORT = 0; // sort the server list again to update for changes to e.g. favorite status, categories
121 const float REFRESHSERVERLIST_REFILTER = 1; // ..., also update filter and sort criteria
122 const float REFRESHSERVERLIST_ASK = 2; // ..., also suggest querying servers now
123 const float REFRESHSERVERLIST_RESET = 3; // ..., also clear the list first
125 // function declarations
126 float IsServerInList(string list, string srv);
128 entity RetrieveCategoryEnt(float catnum);
130 float CategoryOverride(float cat);
131 float m_gethostcachecategory(float entry);
134 // fields for category entities
135 const int MAX_CATEGORIES = 9;
136 const int CATEGORY_FIRST = 1;
137 entity categories[MAX_CATEGORIES];
138 int category_ent_count;
141 .string cat_enoverride_string;
142 .string cat_dioverride_string;
143 .float cat_enoverride;
144 .float cat_dioverride;
146 // fields for drawing categories
147 int category_name[MAX_CATEGORIES];
148 int category_item[MAX_CATEGORIES];
149 int category_draw_count;
151 #define SLIST_CATEGORIES \
152 SLIST_CATEGORY(CAT_FAVORITED, "", "", CTX(_("SLCAT^Favorites"))) \
153 SLIST_CATEGORY(CAT_RECOMMENDED, "", "", CTX(_("SLCAT^Recommended"))) \
154 SLIST_CATEGORY(CAT_NORMAL, "", "CAT_SERVERS", CTX(_("SLCAT^Normal Servers"))) \
155 SLIST_CATEGORY(CAT_SERVERS, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Servers"))) \
156 SLIST_CATEGORY(CAT_XPM, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Competitive Mode"))) \
157 SLIST_CATEGORY(CAT_MODIFIED, "", "CAT_SERVERS", CTX(_("SLCAT^Modified Servers"))) \
158 SLIST_CATEGORY(CAT_OVERKILL, "", "CAT_SERVERS", CTX(_("SLCAT^Overkill"))) \
159 SLIST_CATEGORY(CAT_INSTAGIB, "", "CAT_SERVERS", CTX(_("SLCAT^InstaGib"))) \
160 SLIST_CATEGORY(CAT_DEFRAG, "", "CAT_SERVERS", CTX(_("SLCAT^Defrag Mode")))
162 #define SLIST_CATEGORY_AUTOCVAR(name) autocvar_menu_slist_categories_##name##_override
163 #define SLIST_CATEGORY(name,enoverride,dioverride,str) \
165 string SLIST_CATEGORY_AUTOCVAR(name) = enoverride;
167 #undef SLIST_CATEGORY