Xonotic
serverlist.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #include "listbox.qh"
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));
13 
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));
18 
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
34 
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, disconnectButton, entity);
57  ATTRIB(XonoticServerList, infoButton, entity);
58  ATTRIB(XonoticServerList, currentSortOrder, float, 0);
59  ATTRIB(XonoticServerList, currentSortField, float, -1);
60 
61  ATTRIB(XonoticServerList, ipAddressBoxFocused, float, -1);
62 
63  ATTRIB(XonoticServerList, seenIPv4, float, 0);
64  ATTRIB(XonoticServerList, seenIPv6, float, 0);
65  ATTRIB(XonoticServerList, categoriesHeight, float, 1.25);
66  ATTRIB(XonoticServerList, serversHeight, float, 1.0);
67 
68  METHOD(XonoticServerList, getTotalHeight, float(entity));
69  METHOD(XonoticServerList, getItemAtPos, float(entity, float));
70  METHOD(XonoticServerList, getItemStart, float(entity, float));
71  METHOD(XonoticServerList, getItemHeight, float(entity, float));
74 
76 float CategoryForEntry(float entry);
85 void ServerList_Info_Click(entity btn, entity me);
86 
87 // server cache fields
88 #define SLIST_FIELDS \
89  SLIST_FIELD(CNAME, "cname") \
90  SLIST_FIELD(PING, "ping") \
91  SLIST_FIELD(GAME, "game") \
92  SLIST_FIELD(MOD, "mod") \
93  SLIST_FIELD(MAP, "map") \
94  SLIST_FIELD(NAME, "name") \
95  SLIST_FIELD(MAXPLAYERS, "maxplayers") \
96  SLIST_FIELD(NUMPLAYERS, "numplayers") \
97  SLIST_FIELD(NUMHUMANS, "numhumans") \
98  SLIST_FIELD(NUMBOTS, "numbots") \
99  SLIST_FIELD(PROTOCOL, "protocol") \
100  SLIST_FIELD(FREESLOTS, "freeslots") \
101  SLIST_FIELD(PLAYERS, "players") \
102  SLIST_FIELD(QCSTATUS, "qcstatus") \
103  SLIST_FIELD(CATEGORY, "category") \
104  SLIST_FIELD(ISFAVORITE, "isfavorite")
105 
106 #define SLIST_FIELD(suffix,name) float SLIST_FIELD_##suffix;
108 #undef SLIST_FIELD
109 
120 
121 const float REFRESHSERVERLIST_RESORT = 0; // sort the server list again to update for changes to e.g. favorite status, categories
122 const float REFRESHSERVERLIST_REFILTER = 1; // ..., also update filter and sort criteria
123 const float REFRESHSERVERLIST_ASK = 2; // ..., also suggest querying servers now
124 const float REFRESHSERVERLIST_RESET = 3; // ..., also clear the list first
125 
126 // function declarations
127 float IsServerInList(string list, string srv);
128 
129 entity RetrieveCategoryEnt(float catnum);
130 
131 float CategoryOverride(float cat);
132 float m_gethostcachecategory(float entry);
133 
134 
135 // fields for category entities
136 const int MAX_CATEGORIES = 9;
137 const int CATEGORY_FIRST = 1;
140 .string cat_name;
141 .string cat_string;
146 
147 // fields for drawing categories
151 
152 #define SLIST_CATEGORIES \
153  SLIST_CATEGORY(CAT_FAVORITED, "", "", CTX(_("SLCAT^Favorites"))) \
154  SLIST_CATEGORY(CAT_RECOMMENDED, "", "", CTX(_("SLCAT^Recommended"))) \
155  SLIST_CATEGORY(CAT_NORMAL, "", "CAT_SERVERS", CTX(_("SLCAT^Normal Servers"))) \
156  SLIST_CATEGORY(CAT_SERVERS, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Servers"))) \
157  SLIST_CATEGORY(CAT_XPM, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Competitive Mode"))) \
158  SLIST_CATEGORY(CAT_MODIFIED, "", "CAT_SERVERS", CTX(_("SLCAT^Modified Servers"))) \
159  SLIST_CATEGORY(CAT_OVERKILL, "", "CAT_SERVERS", CTX(_("SLCAT^Overkill"))) \
160  SLIST_CATEGORY(CAT_INSTAGIB, "", "CAT_SERVERS", CTX(_("SLCAT^InstaGib"))) \
161  SLIST_CATEGORY(CAT_DEFRAG, "", "CAT_SERVERS", CTX(_("SLCAT^Defrag Mode")))
162 
163 #define SLIST_CATEGORY_AUTOCVAR(name) autocvar_menu_slist_categories_##name##_override
164 #define SLIST_CATEGORY(name,enoverride,dioverride,str) \
165  int name; \
166  string SLIST_CATEGORY_AUTOCVAR(name) = enoverride;
168 #undef SLIST_CATEGORY
int category_draw_count
Definition: serverlist.qh:150
#define SLIST_CATEGORIES
Definition: serverlist.qh:152
float autocvar_menu_slist_recommendations_purethreshold
Definition: serverlist.qh:119
CLASS(Object) Object
Definition: oo.qh:318
float CategoryOverride(float cat)
string cat_string
Definition: serverlist.qh:141
int category_ent_count
Definition: serverlist.qh:139
float m_gethostcachecategory(float entry)
Definition: serverlist.qc:13
void ServerList_Info_Click(entity btn, entity me)
Definition: serverlist.qc:781
entity() spawn
int category_item[MAX_CATEGORIES]
Definition: serverlist.qh:149
float autocvar_menu_slist_recommendations_minfreeslots
Definition: serverlist.qh:117
const float REFRESHSERVERLIST_RESET
Definition: serverlist.qh:124
SLIST_FIELDS float autocvar_menu_slist_categories
Definition: serverlist.qh:110
const int MAX_CATEGORIES
Definition: serverlist.qh:136
string cat_enoverride_string
Definition: serverlist.qh:142
const float REFRESHSERVERLIST_RESORT
Definition: serverlist.qh:121
entity makeXonoticServerList()
Definition: serverlist.qc:272
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
void ServerList_Update_favoriteButton(entity btn, entity me)
Definition: serverlist.qc:257
float autocvar_menu_slist_categories_onlyifmultiple
Definition: serverlist.qh:111
float autocvar_menu_slist_modimpurity
Definition: serverlist.qh:113
#define SLIST_FIELDS
Definition: serverlist.qh:88
#define ATTRIB(...)
Definition: oo.qh:136
float IsServerInList(string list, string srv)
Definition: serverlist.qc:76
float autocvar_menu_slist_purethreshold
Definition: serverlist.qh:112
const float REFRESHSERVERLIST_REFILTER
Definition: serverlist.qh:122
void ServerList_Categories_Click(entity box, entity me)
Definition: serverlist.qc:667
void RegisterSLCategories()
Definition: serverlist.qc:44
float autocvar_menu_slist_recommendations
Definition: serverlist.qh:115
float autocvar_menu_slist_recommendations_minhumans
Definition: serverlist.qh:118
float autocvar_menu_slist_maxping
Definition: serverlist.qh:114
void ServerList_ShowLaggy_Click(entity box, entity me)
Definition: serverlist.qc:694
void ServerList_Favorite_Click(entity btn, entity me)
Definition: serverlist.qc:772
entity RetrieveCategoryEnt(float catnum)
float CategoryForEntry(float entry)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void ServerList_Filter_Change(entity box, entity me)
Definition: serverlist.qc:656
string cat_dioverride_string
Definition: serverlist.qh:143
float cat_enoverride
Definition: serverlist.qh:144
float cat_dioverride
Definition: serverlist.qh:145
#define ENDCLASS(cname)
Definition: oo.qh:269
entity categories[MAX_CATEGORIES]
Definition: serverlist.qh:138
const float REFRESHSERVERLIST_ASK
Definition: serverlist.qh:123
void ServerList_ShowFull_Click(entity box, entity me)
Definition: serverlist.qc:685
void ServerList_ShowEmpty_Click(entity box, entity me)
Definition: serverlist.qc:676
string cat_name
Definition: serverlist.qh:140
float autocvar_menu_slist_recommendations_maxping
Definition: serverlist.qh:116
int category_name[MAX_CATEGORIES]
Definition: serverlist.qh:148
const int CATEGORY_FIRST
Definition: serverlist.qh:137
void ServerList_Connect_Click(entity btn, entity me)
Definition: serverlist.qc:767