blob: f91231b6b9f49801ed977312c3941e4f8d142e8c (
plain)
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
237
238
239
240
241
242
243
244
245
|
global function InitOpenInvitesMenu
global function UICodeCallback_OpenInviteUpdated
global function InPendingOpenInvite
global function LeaveOpenInvite
global function JoinOpenInvite
global function JoinOpenInvite_OnClick
global function CanJoinOpenInvite
global function CanLeaveOpenInvite
global function CanDestroyOpenInvite
global function LeaveOpenInviteButton
global function IsOpenInviteVisible
struct
{
bool openInviteJoinable
bool openInviteVisible
} file
bool function InPendingOpenInvite()
{
if ( !file.openInviteVisible )
return false
OpenInvite openInvite = GetOpenInvite()
return openInvite.amIInThis
}
void function LeaveOpenInviteButton( var button )
{
LeaveOpenInvite()
}
void function LeaveOpenInvite()
{
EmitUISound( "UI_Networks_Invitation_Canceled" )
ClientCommand( "leaveopeninvite" )
// sort of HACK: revert lobby to non-FD mode when you cancel out of open invite
Lobby_SetFDMode( false )
Lobby_RefreshButtons()
}
void function JoinOpenInvite( var button )
{
if ( CanJoinOpenInvite() )
{
EmitUISound( "UI_Networks_Invitation_Accepted" )
ClientCommand( "joinopeninvite" )
}
else if ( CanLeaveOpenInvite() )
{
LeaveOpenInvite()
}
}
void function JoinOpenInvite_OnClick( var button )
{
// haaaack. Either join it or leave it here, depending on context
OpenInvite openInvite = GetOpenInvite()
if ( openInvite.amIInThis )
LeaveOpenInvite()
else
JoinOpenInvite( button )
}
bool function IsOpenInviteVisible()
{
return file.openInviteVisible
}
bool function CanDestroyOpenInvite()
{
OpenInvite openInvite = GetOpenInvite()
return file.openInviteVisible && openInvite.amILeader
}
bool function CanJoinOpenInvite()
{
OpenInvite openInvite = GetOpenInvite()
int currentPartySize = GetPartySize()
return currentPartySize <= 1 && file.openInviteVisible && file.openInviteJoinable && !openInvite.amIInThis
}
bool function CanLeaveOpenInvite()
{
OpenInvite openInvite = GetOpenInvite()
return file.openInviteVisible && file.openInviteJoinable && !openInvite.amILeader && openInvite.amIInThis
}
void function UpdateOpenInvite()
{
OpenInvite openInvite = GetOpenInvite()
if ( openInvite.timeLeft <= -1 || openInvite.numFreeSlots == 0 )
{
HideOpenInvite()
if ( openInvite.amILeader )
ClientCommand( "openinvitelaunch" )
if ( openInvite.amIInThis )
{
CloseAllToTargetMenu( GetMenu( "LobbyMenu" ) )
AdvanceMenu( GetMenu( "SearchMenu" ) )
}
else
{
Lobby_SetFDMode( false )
Lobby_RefreshButtons()
}
file.openInviteVisible = false
file.openInviteJoinable = false
UpdateFooterOptions()
return
}
array<string> playlists = split( openInvite.playlistName, "," )
string message = ""
string param1 = ""
string ornull param2 = null
switch( openInvite.inviteType )
{
case "party":
if ( openInvite.amILeader )
message = "#OPENINVITE_SENDER_PARTY";
else
message = "#OPENINVITE_PARTY";
param1 = openInvite.originatorName
break;
case "playlist":
if ( playlists.len() > 1 )
{
if ( openInvite.amILeader )
message = "#OPENINVITE_SENDER_PLAYLIST_MANY"
else
message = "#OPENINVITE_PLAYLIST_MANY"
param1 = openInvite.originatorName
param2 = GetPlaylistDisplayName( openInvite.playlistName )
}
else
{
if ( openInvite.amILeader )
message = "#OPENINVITE_SENDER_PLAYLIST"
else
message = "#OPENINVITE_PLAYLIST"
param1 = openInvite.originatorName
param2 = GetPlaylistDisplayName( openInvite.playlistName )
}
break;
case "private_match":
if ( openInvite.amILeader )
message = "#OPENINVITE_SENDER_PRIVATEMATCH"
else
message = "#OPENINVITE_PRIVATEMATCH"
param1 = openInvite.originatorName
break;
default:
HideOpenInvite()
file.openInviteVisible = false
file.openInviteJoinable = false
UpdateFooterOptions()
return;
}
int timeLeft = int( openInvite.timeLeft ) + 1
if ( openInvite.timeLeft <= 0 || openInvite.numFreeSlots == 0 )
{
if ( file.openInviteJoinable )
{
file.openInviteJoinable = false
UpdateFooterOptions()
}
timeLeft = 0
}
else
{
if ( !file.openInviteJoinable )
{
file.openInviteJoinable = true
UpdateFooterOptions()
printt( "openinvite is joinable" )
}
}
UpdateOpenInvites( openInvite, message, param1, param2, timeLeft )
}
void function UpdateOpenInvite_Thread()
{
while ( file.openInviteVisible )
{
if ( !IsConnected() || !IsLobby() )
{
HideOpenInvite()
file.openInviteVisible = false
file.openInviteJoinable = false
UpdateFooterOptions()
return
}
UpdateOpenInvite()
WaitFrame()
}
}
void function UICodeCallback_OpenInviteUpdated()
{
// don't support on northstar
return
if ( file.openInviteVisible )
return
int currentPartySize = GetPartySize()
if ( currentPartySize > 1 )
{
HideOpenInvite()
file.openInviteVisible = false
return
}
if ( !IsConnected() )
{
HideOpenInvite()
file.openInviteVisible = false
return
}
entity player = GetUIPlayer()
if ( IsValid( player ) && Player_NextAvailableMatchmakingTime( player ) > 0 )
{
HideOpenInvite()
file.openInviteVisible = false
return
}
OpenInvite openInvite = GetOpenInvite()
ShowOpenInvite()
file.openInviteVisible = true
UpdateOpenInvite()
thread UpdateOpenInvite_Thread()
}
void function InitOpenInvitesMenu()
{
file.openInviteVisible = false
file.openInviteJoinable = false
}
|