-
Notifications
You must be signed in to change notification settings - Fork 4
/
GoldSrc.VGUI.ServerBrowser.pas
236 lines (187 loc) · 8.25 KB
/
GoldSrc.VGUI.ServerBrowser.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
(*============ (C) Copyright 2019, Alexander B. All rights reserved. ============*)
(* *)
(* Module: *)
(* GoldSrc.GoldSrc.VGUI.ServerBrowser *)
(* *)
(* License: *)
(* You may freely use this code provided you retain this copyright message. *)
(* *)
(* Description: *)
(* Binary-correct implementation of virtual tables for working with *)
(* serverbrowser.dll library objects. *)
(* *)
(* In Linux, virtual methods created through multiple inheritance *)
(* are copied to the class table, while in Windows they *)
(* are implemented in separate tables, pointers to which are written *)
(* into class fields. For example, if you need to use the functions of *)
(* IGameList, then you need to perform a special offset relative to this *)
(* class, which inherits the methods of this interface, and then perform a *)
(* dereference, as a result, a pointer to the desired interface will *)
(* be obtained. *)
(*===============================================================================*)
unit GoldSrc.VGUI.ServerBrowser;
{$Z4}
{$A4}
interface
uses
Steam.API,
GoldSrc.KeyValues,
GoldSrc.VGUI;
type
EMatchMakingServerResponse =
(
eServerResponded = 0,
eServerFailedToRespond,
eNoServersListedOnMasterServer // for the Internet query type, returned in response callback if no servers of this type match
);
serverdisplay_t = record
ListID, ServerID: Integer;
DoNotRefresh: Boolean;
end;
TServerDisplay = serverdisplay_t;
PServerDisplay = ^TServerDisplay;
{$REGION 'IGameList'}
InterfaceItem_e =
(
FILTERS = 0,
GETNEWLIST,
ADDSERVER,
ADDCURRENTSERVER
);
PVTableIGameList = ^VTableIGameList;
VTableIGameList = object
public
// returns true if the game list supports the specified ui elements
SupportsItem: function(Item: InterfaceItem_e): Boolean; stdcall;
// starts the servers refreshing
StartRefresh: procedure; stdcall;
// gets a new server list
GetNewServerList: procedure; stdcall;
// stops current refresh/GetNewServerList()
StopRefresh: procedure; stdcall;
// returns true if the list is currently refreshing servers
IsRefreshing: function: Boolean; stdcall;
// gets information about specified server
GetServer: function(const ServerID: Integer): PServerDisplay; stdcall;
// gets information about specified server from SteamMatchmakingServers interface
GetServerInfo: function(const ServerID: Integer): PGameServerItem; stdcall;
// called when Connect button is pressed
OnBeginConnect: procedure; stdcall;
// invalid server index
GetInvalidServerListID: function: Integer; stdcall;
end;
IGameList = ^PVTableIGameList;
{$ENDREGION}
{$REGION 'ISteamMatchmakingServerListResponse'}
PVTableISteamMatchmakingServerListResponse = ^VTableISteamMatchmakingServerListResponse;
VTableISteamMatchmakingServerListResponse = object
public
ServerResponded: procedure(Server: Integer); stdcall;
ServerFailedToRespond: procedure(Server: Integer); stdcall;
RefreshComplete: procedure(Response: EMatchMakingServerResponse); stdcall;
end;
ISteamMatchmakingServerListResponse = ^PVTableISteamMatchmakingServerListResponse;
{$ENDREGION}
{$REGION 'ISteamMatchmakingPingResponse'}
PVTableISteamMatchmakingPingResponse = ^VTableISteamMatchmakingPingResponse;
VTableISteamMatchmakingPingResponse = object
public
ServerResponded: procedure(const Server: TGameServerItem); stdcall;
ServerFailedToRespond: procedure; stdcall;
end;
ISteamMatchmakingPingResponse = ^PVTableISteamMatchmakingPingResponse;
{$ENDREGION}
{$REGION 'ISteamMatchmakingPlayersResponse'}
PVTableISteamMatchmakingPlayersResponse = ^VTableISteamMatchmakingPlayersResponse;
VTableISteamMatchmakingPlayersResponse = object
public
AddPlayerToList: procedure(Name: PAnsiChar; Score: Integer; TimePlayed: Single); stdcall;
PlayersFailedToRespond: procedure; stdcall;
PlayersRefreshComplete: procedure; stdcall;
end;
ISteamMatchmakingPlayersResponse = ^PVTableISteamMatchmakingPlayersResponse;
{$ENDREGION}
{$REGION 'ISteamMatchmakingRulesResponse'}
PVTableISteamMatchmakingRulesResponse = ^VTableISteamMatchmakingRulesResponse;
VTableISteamMatchmakingRulesResponse = object
public
RulesResponded: procedure(Rule, Value: PAnsiChar); stdcall;
RulesFailedToRespond: procedure; stdcall;
RulesRefreshComplete: procedure; stdcall;
end;
ISteamMatchmakingRulesResponse = ^PVTableISteamMatchmakingRulesResponse;
{$ENDREGION}
{$REGION 'CBaseGamesPage'}
PVTableCBaseGamesPage = ^VTableCBaseGamesPage;
VTableCBaseGamesPage = object(VTablePropertyPage)
public
SetRefreshing: procedure(State: Boolean); stdcall;
// loads filter settings from disk
LoadFilterSettings: procedure; stdcall;
// Called by CGameList when the enter key is pressed.
// This is overridden in the add server dialog - since there is no Connect button, the message
// never gets handled, but we want to add a server when they dbl-click or press enter.
OnGameListEnterPressed: procedure; stdcall;
// adds a server to the favorites
OnAddToFavorites: procedure; stdcall;
OnLoadModList: procedure(AppID: UInt64); stdcall;
GetRegionCodeToFilter: function: Integer; stdcall;
OnItemSelected: procedure; stdcall;
// ISteamMatchmakingServerListResponse callbacks
ServerResponded: procedure(Server: Integer); stdcall;
BShowServer: function(const Server: TServerDisplay): Boolean; stdcall;
// filtering methods
// returns true if filters passed; false if failed
CheckPrimaryFilters: function(const Server: TGameServerItem): Boolean; stdcall;
CheckSecondaryFilters: function(const Server: TGameServerItem): Boolean; stdcall;
OnSaveFilter: procedure(Filter: PKeyValues); stdcall;
OnLoadFilter: procedure(Filter: PKeyValues); stdcall;
// called to look at game info
OnViewGameInfo: procedure; stdcall;
// refreshes a single server
OnRefreshServer: procedure(ServerID: Integer); stdcall;
OnButtonToggled: procedure(Panel: Pointer; State: Integer); stdcall;
OnTextChanged: procedure(Panel: Pointer; Text: PAnsiChar); stdcall;
end;
CBaseGamesPage = ^PVTableCBaseGamesPage;
{$ENDREGION}
{$REGION 'CInternetGames'}
PVTableCInternetGames = ^VTableCInternetGames;
VTableCInternetGames = object(VTableCBaseGamesPage)
public
OnOpenContextMenu: procedure(ItemID: Integer); stdcall;
end;
CInternetGames = ^PVTableCInternetGames;
{$ENDREGION}
{$REGION 'CFavoriteGames'}
PVTableCFavoriteGames = ^VTableCFavoriteGames;
VTableCFavoriteGames = object(VTableCBaseGamesPage)
public
// context menu message handlers
OnOpenContextMenu: procedure(ItemID: Integer); stdcall;
OnRemoveFromHistory: procedure; stdcall;
OnAddServerByName: procedure; stdcall;
end;
CFavoriteGames = ^PVTableCFavoriteGames;
{$ENDREGION}
{$REGION 'CServerBrowserDialog'}
PVTableCServerBrowserDialog = ^VTableCServerBrowserDialog;
VTableCServerBrowserDialog = object(VTableFrame)
public
GetCurrentConnectedServer: function: PGameServerItem; stdcall;
// current game list change
OnGameListChanged: procedure; stdcall;
// receives a specified game is active, so no other game types can be displayed in server list
OnActiveGameName: procedure(Name: PAnsiChar); stdcall;
// notification that we connected / disconnected
OnConnectToGame: procedure(KV: PKeyValues); stdcall;
OnDisconnectFromGame: procedure; stdcall;
end;
CServerBrowserDialog = ^PVTableCServerBrowserDialog;
{$ENDREGION}
{$REGION 'CServerBrowser'}
DCServerBrowser = object
end;
{$ENDREGION}
implementation
end.