-
Notifications
You must be signed in to change notification settings - Fork 1
/
ifs_mp_lobby.lua
1178 lines (996 loc) · 40.4 KB
/
ifs_mp_lobby.lua
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
-- Multiplayer lobby
gVoiceIconSpeaker = gXLFriendsEnum2UVs[7]
gVoiceIconTalking = gXLFriendsEnum2UVs[10]
gVoiceIconMuted = gXLFriendsEnum2UVs[8]
gVoiceIconTV = gXLFriendsEnum2UVs[9]
--
-- voice status icons
gVoiceStatus =
{
send =
{
{ alpha = 1.0, UVs = gVoiceIconMuted, flash = nil }, -- send disabled
{ alpha = 0.8, UVs = gVoiceIconSpeaker, flash = 1 }, -- send disabled, remote receive enabled
{ alpha = 0.4, UVs = gVoiceIconSpeaker, flash = nil }, -- send enabled
{ alpha = 1.0, UVs = gVoiceIconSpeaker, flash = nil }, -- send possible
{ alpha = 1.0, UVs = gVoiceIconTalking, flash = nil }, -- sending
{ alpha = 1.0, UVs = gVoiceIconTV, flash = nil }, -- send possible / sending to TV
},
receive =
{
{ alpha = 1.0, UVs = gVoiceIconMuted, flash = nil }, -- receive disabled
{ alpha = 0.8, UVs = gVoiceIconSpeaker, flash = 1 }, -- receive disabled, remote send enabled
{ alpha = 0.4, UVs = gVoiceIconSpeaker, flash = nil }, -- receive enabled
{ alpha = 1.0, UVs = gVoiceIconSpeaker, flash = nil }, -- receive possible
{ alpha = 1.0, UVs = gVoiceIconTalking, flash = nil }, -- receiving
{ alpha = 1.0, UVs = gVoiceIconTV, flash = nil }, -- receive possible / receiving to TV
}
}
-- Helper function. Given a layout (x,y,width, height), returns a
-- fully-built item.
function ifs_mp_lobby_Listbox_CreateItem(layout)
-- Make a coordinate system pegged to the top-left of where the cursor would go.
local Temp = NewIFContainer { x = layout.x - 0.5 * layout.width, y = layout.y}
-- SM 8-Feb-05 all column widths are now relative to the width of the list box
local BorderWidth = 10 -- should be subtracted from the first and
-- last column widths
local NameWidth = layout.width * 0.5
local TeamWidth = layout.width * 0.2
local KillsWidth = layout.width * 0.1
local PingWidth = layout.width * 0.11
local QOSWidth = layout.width * 0.2
local XLiveStatusWidth = layout.width * 0.05
local VoiceWidth = layout.width * 0.05
local VoiceSendWidth = layout.width * 0.13
local VoiceReceiveWidth = layout.width * 0.12
local y_offset = 4
-- SM 8-Feb-05 not sure what this has to do with idiot mode
-- (bars instead of numbers for ping)
-- if a column doesn't need to be displayed then just set its width to 0
-- and it will not be created
-- futhermore, I disabled the ability to toggle idiot mode on and off
-- it requires a significant amount of real estate to display the
-- "connection" header for the QOS field
if (not ifs_mp_lobby.bIdiotMode) then
QOSWidth = 0
else
PingWidth = 0
end
if (gPlatformStr ~= "PC") then
KillsWidth = 0
end
-- Removed voice columns NM 9/19/05, per bug 13422
if ((gOnlineServiceStr == "XLive") or (gPlatformStr == "PC")) then
VoiceSendWidth = 0
VoiceReceiveWidth = 0
VoiceWidth = VoiceWidth + BorderWidth
else
XLiveStatusWidth = 0
VoiceWidth = 0
VoiceReceiveWidth = VoiceReceiveWidth + BorderWidth
end
-- SM 7-Feb-05 I decided to right align all fields with the exception
-- of the name field
local NamePos = BorderWidth
local VoiceReceivePos = layout.width - VoiceReceiveWidth
local VoiceSendPos = VoiceReceivePos - VoiceSendWidth
local VoicePos = VoiceSendPos - VoiceWidth -- XLive voice status icon
local PingPos = VoicePos - PingWidth
local QOSPos = VoicePos - QOSWidth -- XLive ping / quality of service icon
local XLiveStatusPos = QOSPos - XLiveStatusWidth
local KillsPos = math.min(PingPos, QOSPos) - KillsWidth
local TeamPos = KillsPos - TeamWidth
-- clamp name width to the actually displayed value
NameWidth = TeamPos - NamePos
local QOSHeight = 0.8 * layout.height -- height of ping bar
local IconSize = 0.9 * layout.height -- size of each icon in lobby_icons.tga
local fontLocal
-- SM 8-Feb-05 only use big font when idiot mode is disabled or
-- on PS2 where the resolution is poopy
if (layout.bTitles and
((gPlatformStr == "XBox") or (gPlatformStr == "PS2"))) then
fontLocal = "meu_myriadpro_small" -- big(ish) font for column headers
else
fontLocal = "meu_myriadpro_small" -- smaller font for contents
end
if (NameWidth > 0) then
Temp.namefield = NewIFText{
x = NamePos, y = -10 + y_offset, textw = NameWidth,
halign = "left", font = fontLocal, nocreatebackground=1,
inert_all = 1,
}
end
if (TeamWidth > 0) then
Temp.teamfield = NewIFText{
x = TeamPos, y = -10 + y_offset, textw = TeamWidth,
halign = "left", font = fontLocal, nocreatebackground=1,
inert_all = 1,
}
end
if (KillsWidth > 0) then
Temp.killsfield = NewIFText{
x = KillsPos, y = -10 + y_offset, textw = KillsWidth,
halign = "left", font = fontLocal, nocreatebackground=1,
inert_all = 1,
}
end
if (PingWidth > 0) then
Temp.pingfield = NewIFText{
x = PingPos, y = -10 + y_offset, textw = PingWidth,
halign = "left", font = fontLocal, nocreatebackground=1,
inert_all = 1,
}
end
-- if the titles of the list box are being created
if (layout.bTitles) then
if (QOSWidth > 0) then
-- XLive requires ping / quality of service to be displayed as a status bar
Temp.qosfield = NewIFText{
x = QOSPos, y = -10 + y_offset, textw = QOSWidth,
halign = "left", font = fontLocal, nocreatebackground = 1,
inert_all = 1,
}
end
-- seperate send / receive status
if (VoiceSendWidth > 0) then
Temp.voiceSendField = NewIFText{
x = VoiceSendPos, y = -10 + y_offset, textw = VoiceWidth,
halign = "left", font = fontLocal, nocreatebackground = 1,
inert_all = 1,
}
end
if (VoiceReceiveWidth > 0) then
Temp.voiceReceiveField = NewIFText{
x = VoiceReceivePos, y = -10 + y_offset, textw = 120,
halign = "left", font = fontLocal, nocreatebackground = 1,
inert_all = 1,
}
end
else
if (QOSWidth > 0) then
-- XLive requires ping / quality of service to be displayed as a
-- status bar
Temp.qosfield = NewIFImage{
x = QOSPos, y = 6 + y_offset, -- y-pos is to get it centered in bar
texture = "ping_icon",
localpos_l = 0, localpos_t = -13,
localpos_b = QOSHeight - 10 - 7, localpos_r = 40,
}
end
local VoiceIconYOffset = 14
-- XLive friend state
if (XLiveStatusWidth > 0) then
Temp.StateIcon = NewIFImage{
x = XLiveStatusPos, y = 3 + y_offset, -- y-pos is to get it centered in bar
texture = "lobby_icons",
localpos_l = 0, localpos_t = -VoiceIconYOffset,
localpos_b = IconSize - VoiceIconYOffset, localpos_r = IconSize,
bInertPos = 1, inert_all = 1,
}
end
if (VoiceWidth > 0) then
-- XLive requires certain icons for voice status which means the
-- muted (send + receive enabled) status is hidden to other players
-- the local player only knows who is locally muted
Temp.VoiceIcon = NewIFImage {
x = VoicePos, y = 3 + y_offset, -- y-pos is to get it centered in bar
texture = "lobby_icons",
localpos_l = 0, localpos_t = -VoiceIconYOffset,
localpos_b = IconSize - VoiceIconYOffset, localpos_r = IconSize,
bInertPos = 1, inert_all = 1,
}
end
if (VoiceSendWidth > 0) then
-- seperate send / receive status
Temp.voiceSendField = NewIFImage {
x = VoiceSendPos, y = 3 + y_offset, -- y-pos is to get it centered in bar
texture = "lobby_icons",
localpos_l = 0, localpos_t = -VoiceIconYOffset,
localpos_b = IconSize - VoiceIconYOffset, localpos_r = IconSize,
bInertPos = 1, inert_all = 1,
}
end
if (VoiceReceiveWidth > 0) then
Temp.voiceReceiveField = NewIFImage {
x = VoiceReceivePos, y = 3 + y_offset, -- y-pos is to get it centered in bar
texture = "lobby_icons",
localpos_l = 0, localpos_t = -VoiceIconYOffset,
localpos_b = IconSize - VoiceIconYOffset, localpos_r = IconSize,
bInertPos = 1, inert_all = 1,
}
end
end
return Temp
end
-- display a voice icon
function ifs_mp_lobby_Listbox_DisplayVoiceIcon(field, iconInfo, flashAlpha)
local UVs
local alpha
UVs = iconInfo.UVs
alpha = iconInfo.alpha
if (iconInfo.flash) then
alpha = alpha * flashAlpha
end
IFImage_fnSetUVs(field, UVs.u, UVs.v, UVs.u + 0.25, UVs.v + 0.25)
IFObj_fnSetAlpha(field, alpha)
IFObj_fnSetVis (field, 1)
end
-- Helper function. For a destination item (previously created w/
-- CreateItem), fills it in with data, which may be nil (==blank it)
function ifs_mp_lobby_Listbox_PopulateItem(Dest, Data, bSelected, ColorR, ColorG, ColorB, fAlpha)
-- If we need to zap the glyphcache, do so.
if (gBlankListbox) then
if (Dest.namefield) then
IFText_fnSetString(Dest.namefield, "")
end
if (Dest.teamfield) then
IFText_fnSetString(Dest.teamfield, "")
end
if (Dest.pingfield) then
IFText_fnSetString(Dest.pingfield, "")
end
if (Dest.killsfield) then
IFText_fnSetString(Dest.killsfield," ")
end
elseif (Data) then
-- Have data, time to draw. Do so.
if (Dest.namefield) then
IFObj_fnSetColor(Dest.namefield, ColorR, ColorG, ColorB)
IFObj_fnSetAlpha(Dest.namefield, fAlpha)
end
if (Dest.teamfield) then
IFObj_fnSetColor(Dest.teamfield, ColorR, ColorG, ColorB)
IFObj_fnSetAlpha(Dest.teamfield, fAlpha)
end
if (Dest.pingfield) then
IFObj_fnSetColor(Dest.pingfield, ColorR, ColorG, ColorB)
IFObj_fnSetAlpha(Dest.pingfield, fAlpha)
end
if (Dest.killsfield) then
IFObj_fnSetColor(Dest.killsfield, ColorR, ColorG, ColorB)
IFObj_fnSetAlpha(Dest.killsfield, fAlpha)
end
-- name
if (Dest.namefield) then
IFText_fnSetString(Dest.namefield, Data.namestr)
--IFText_fnSetString(Dest.namefield,"WWWWWWWWWWWWWWM") -- space test
end
-- team
if (Dest.teamfield) then
if (Data.iTeam < 0.5) then
IFText_fnSetUString(Dest.teamfield, ScriptCB_GetTeamName(1))
else
IFText_fnSetUString(Dest.teamfield, ScriptCB_GetTeamName(2))
end
if (Data.ColorR) then
IFObj_fnSetColor(Dest.teamfield, Data.ColorR, Data.ColorG, Data.ColorB)
end
end
-- ping / quality of service
if (Dest.qosfield) then
local U1 = (5 - Data.iQOS) * 0.2
IFImage_fnSetUVs(Dest.qosfield, U1, 0.0, U1 + 0.2, 1.0)
elseif (Dest.pingfield) then
IFText_fnSetString(Dest.pingfield, Data.pingstr)
end
if (Dest.killsfield) then
IFText_fnSetString(Dest.killsfield, Data.killsstr)
end
-- update XLive friend state icon
if(Data.StateIcon) then
local UVs = gXLFriendsEnum2UVs[Data.StateIcon + 1] -- lua counts from 1
IFImage_fnSetUVs(Dest.StateIcon, UVs.u, UVs.v, UVs.u + 0.25, UVs.v + 0.25)
end
if (Dest.StateIcon) then
IFObj_fnSetVis(Dest.StateIcon, Data.StateIcon)
end
-- update XLive voice icon
if (Data.VoiceIcon) then
local UVs = gXLFriendsEnum2UVs[Data.VoiceIcon + 1] -- lua counts from 1
IFImage_fnSetUVs(Dest.VoiceIcon, UVs.u, UVs.v, UVs.u + 0.25, UVs.v + 0.25)
IFObj_fnSetAlpha(Dest.VoiceIcon, Data.VoiceIconAlpha)
end
if (Dest.VoiceIcon) then
IFObj_fnSetVis(Dest.VoiceIcon, Data.VoiceIcon)
end
-- voice send / receive states
if (Dest.voiceSendField and Dest.voiceReceiveField) then
local sendStatus = ScriptCB_GetVoiceSendStatus(Data.indexstr)
local receiveStatus = ScriptCB_GetVoiceReceiveStatus(Data.indexstr)
local iconInfo
local flashAlpha = ((math.min(ifs_mp_lobby.flashNextTime - ifs_mp_lobby.flashTimeElapsed, 1.0)) /
ifs_mp_lobby.flashInterval)
-- flash on or off as the update rate is really slow
if (flashAlpha > 0.5) then
flashAlpha = 1.0
else
flashAlpha = 0
end
if (sendStatus > 0) then
ifs_mp_lobby_Listbox_DisplayVoiceIcon(Dest.voiceSendField, gVoiceStatus.send[sendStatus], flashAlpha)
else
IFObj_fnSetVis(Dest.voiceSendField, nil)
end
if (receiveStatus > 0) then
ifs_mp_lobby_Listbox_DisplayVoiceIcon(Dest.voiceReceiveField, gVoiceStatus.receive[receiveStatus], flashAlpha)
else
IFObj_fnSetVis(Dest.voiceReceiveField, nil)
end
end
end -- Data exists
-- Show entry if Data != nil
IFObj_fnSetVis(Dest,Data)
end
lobby_listbox_layout = {
showcount = 10,
-- yTop = -130 + 13, -- auto-calc'd now
yHeight = 26,
ySpacing = 0,
width = 430,
x = 0,
slider = 1,
CreateFn = ifs_mp_lobby_Listbox_CreateItem,
PopulateFn = ifs_mp_lobby_Listbox_PopulateItem,
}
ifs_mp_lobby_listbox_contents = {
-- Filled in from C++ now. NM 8/7/03
-- Stubbed to show the string.format it wants.
-- { indexstr = "1", namestr = "Alpha"},
-- { indexstr = "2", namestr = "Bravo"},
}
-- Callbacks from the busy popup
-- Returns -1, 0, or 1, depending on error, busy, or success
function ifs_mplobby_leavepopup_fnCheckDone()
-- local this = ifs_sessionlist_joinpopup
ScriptCB_UpdateLeave() -- think...
return ScriptCB_IsLeaveDone()
end
function ifs_mplobby_leavepopup_fnOnSuccess()
local this = ifs_mp_lobby
Popup_Busy:fnActivate(nil)
ifs_mp_lobby_fnShowHideItems(this, 1)
ScriptCB_PopScreen("ifs_mp_main")
end
function ifs_mplobby_leavepopup_fnOnFail()
-- This shouldn't happen, but go back in any case
local this = ifs_mp_lobby
Popup_Busy:fnActivate(nil)
ifs_mp_lobby_fnShowHideItems(this, 1)
ScriptCB_PopScreen("ifs_mp_main")
end
function ifs_mplobby_leavepopup_fnOnCancel()
-- Shouldn't happen!
ifs_mp_lobby_fnShowHideItems(this, 1)
end
-- Callback after the "really leave session?" popup is done.
-- If bResult is true, then the user hit yes, else no.
function ifs_mp_lobby_fnLeavePopupDone(bResult)
local this = ifs_mp_lobby
if(bResult) then
-- User does want to leave. Start the process.
ScriptCB_BeginLeave()
-- And show the popup.
Popup_Busy.fnCheckDone = ifs_mplobby_leavepopup_fnCheckDone
Popup_Busy.fnOnSuccess = ifs_mplobby_leavepopup_fnOnSuccess
Popup_Busy.fnOnFail = ifs_mplobby_leavepopup_fnOnFail
Popup_Busy.fnOnCancel = ifs_mplobby_leavepopup_fnOnCancel
Popup_Busy.bNoCancel = 1 -- no cancel button
Popup_Busy.fTimeout = 5 -- seconds
IFText_fnSetString(Popup_Busy.title,"common.mp.leaving")
Popup_Busy:fnActivate(1)
else
ifs_mp_lobby_fnShowHideItems(this,1)
end
end
-- callback when the lobby options popup is done
function ifs_mp_lobby_fnLobbyOptionsPopupDone()
local this = ifs_mp_lobby
-- force a reget of the listbox to update any changes
ifs_mp_lobby_SetHilight(this,lobby_listbox_layout.SelectedIdx)
end
-- Helper function: turns pieces on/off as requested
function ifs_mp_lobby_fnShowHideItems(this,bNormalVis)
IFObj_fnSetVis(this.listbox,bNormalVis)
IFObj_fnSetVis(this.columnheaders,bNormalVis)
-- IFObj_fnSetVis(this.buttons,bNormalVis and this.bShellActive)
end
-- Sets the hilight on the listbox, create button given a hilight
function ifs_mp_lobby_SetHilight(this,aListIndex)
lobby_listbox_layout.SelectedIdx = aListIndex
if(gPlatformStr ~= "PC") then
lobby_listbox_layout.CursorIdx = aListIndex
end
ListManager_fnFillContents(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
-- this recalculates the boot flag and the vote button visibility
function ifs_mp_lobby_DoTestCanBoot( selected_idx, force_boot )
local this = ifs_mp_lobby
if (not force_boot) then
-- default to visible
local BootVisible = 1
if(selected_idx) then
-- the currently selected player
local Selection = ifs_mp_lobby_listbox_contents[selected_idx]
if(not Selection) then
return nil
end
local bIsMe = Selection.bIsLocal
local muted,friend,bCanBoot,bIsGuest,bCanAddFriend = ScriptCB_GetLobbyPlayerFlags(Selection.namestr, Selection.indexstr)
--print( "++++1++++bIsMe = ", bIsMe, " bCanBoot = ", bCanBoot, " BootVisible = ", BootVisible, " Selection.indexstr =", Selection.indexstr )
if(ScriptCB_GetAmHost()) then
BootVisible = nil -- bugs # 14579, 145780
-- don't let host "vote to boot" as he has the option to force boot
else
-- Not host. Set client options
BootVisible = not ScriptCB_IsInShell()
if( bIsMe ) then
BootVisible = nil -- can't kick self
end
-- won't boot if players are different team
local NumEntries = table.getn(ifs_mp_lobby_listbox_contents)
local bIsSameTeam = nil
for i = 1, NumEntries do
if( ifs_mp_lobby_listbox_contents[i].bIsLocal and
Selection.iTeam == ifs_mp_lobby_listbox_contents[i].iTeam ) then
bIsSameTeam = 1
end
end
if( not bIsSameTeam ) then
BootVisible = nil
end
end
--print( "++++2++++BootVisible = ", BootVisible )
-- global can you boot this person?
if(not bCanBoot) then
BootVisible = nil
end
else
-- nobody home, hidden
BootVisible = nil
end
--print( "++++3++++BootVisible = ", BootVisible )
return BootVisible
else
-- default to invisible
local ForceBootVisible = nil
if(lobby_listbox_layout.SelectedIdx) then
-- the currently selected player
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
ForceBootVisible = nil
else
local bIsMe = Selection.bIsLocal
if(ScriptCB_GetAmHost()) then
ForceBootVisible = not bIsMe -- can't kick self
else
ForceBootVisible = nil
end
end
else
-- nobody home, hidden
ForceBootVisible = nil
end
return ForceBootVisible
end
end
-- this recalculates the boot flag and the vote button visibility
function ifs_mp_lobby_CalcCanBoot()
local this = ifs_mp_lobby
this.BootVisible = ifs_mp_lobby_DoTestCanBoot( lobby_listbox_layout.SelectedIdx, nil )
-- show/hide the boot button
IFObj_fnSetVis(this.Helptext_Misc,this.BootVisible)
end
-- this recalculates the boot flag and the vote button visibility
function ifs_mp_lobby_CalcCanForceBoot()
local this = ifs_mp_lobby
this.ForceBootVisible = ifs_mp_lobby_DoTestCanBoot( lobby_listbox_layout.SelectedIdx, true )
-- show/hide the boot button
IFObj_fnSetVis(this.Helptext_ForceBoot,this.ForceBootVisible)
if(this.ForceBootVisible) then
if (this.Helptext_ForceBoot.helpstr) then
IFText_fnSetString(this.Helptext_ForceBoot.helpstr, "ifs.onlinelobby.forceboot")
end
end
end
-- bringup vote to boot popup
function ifs_mp_lobby_DoPopupVootBoot( force_boot )
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
return
end
Popup_Vote.CurButton = "no" -- default
Popup_Vote.SelectedIdx = lobby_listbox_layout.SelectedIdx
Popup_Vote.force_boot = force_boot
Popup_Vote:fnActivate(1)
end
function ifs_mp_lobby_IsBandwidthVisible(this)
return nil
--return this.bCanAdjustBW and ScriptCB_GetAmHost() and (gOnlineServiceStr ~= "LAN")
end
function ifs_mp_lobby_UpdateBandwidth(this, value)
IFText_fnSetUString( this.Bandwidth,
ScriptCB_usprintf("ifs.mp.bandwidth",
ScriptCB_tounicode( string.format("%d",value) )))
end
ifs_mp_lobby = NewIFShellScreen {
nologo = 1,
bDimBackdrop = 1,
bg_texture = "iface_bgmeta_space",
flashTimeElapsed = 0.0,
flashNextTime = 0.0,
flashInterval = 1.0,
bIdiotMode = nil,
launchflag = nil,
title = NewIFText {
-- string = "common.mp.lobby",
font = "meu_myriadpro_large",
y = 0,
textw = 460, -- center on screen. Fixme: do real centering!
ScreenRelativeX = 0.5, -- center
ScreenRelativeY = 0, -- top
nocreatebackground = 1,
},
-- Vote helptext
IPAddr = NewIFText {
-- string = "ifs.mp.connection.title",
font = "meu_myriadpro_small",
textw = 460,
halign = "right",
ScreenRelativeX = 1.0, -- right
ScreenRelativeY = 1.0, -- near bottom
y = -90,
x = -460,
nocreatebackground = 1,
},
ServerName = NewIFText {
-- string = "ifs.mp.connection.title",
font = "meu_myriadpro_small",
textw = 460,
halign = "left",
ScreenRelativeX = 0, -- left
ScreenRelativeY = 1.0, -- near bottom
y = -90,
x = 25,
nocreatebackground = 1,
},
Bandwidth = NewIFText {
font = "meu_myriadpro_small",
textw = 460,
halign = "left",
ScreenRelativeX = 0, -- left
ScreenRelativeY = 1.0, -- near bottom
y = -60,
x = 25,
-- nocreatebackground = 1,
},
Enter = function(this, bFwd)
-- Always call base class
gIFShellScreenTemplate_fnEnter(this, bFwd)
-- gHelptext_fnMoveIcon(this.Helptext_Misc2)
-- Added chunk for error handling...
if(not bFwd) then
local ErrorLevel,ErrorMessage = ScriptCB_GetError()
if(ErrorLevel >= 6) then -- session or login error, must keep going further
ScriptCB_PopScreen()
end
end
this.bCanAdjustBW = not gFinalBuild
this.bShellActive = ScriptCB_GetShellActive()
if(this.Helptext_Accept) then
IFText_fnSetString(this.Helptext_Accept.helpstr,"ifs.onlinelobby.playeropts")
gHelptext_fnMoveIcon(this.Helptext_Accept)
end
if(gPlatformStr == "XBox") then
IFText_fnSetString(this.title, "game.pause.playerlist")
else
this.bAmHost = ScriptCB_GetAmHost()
if(this.bAmHost) then
IFText_fnSetString(this.title, "ifs.mplobby.host_title")
else
IFText_fnSetString(this.title, "ifs.mplobby.client_title")
end
end
-- Reset listbox, show it. [Remember, Lua starts at 1!]
lobby_listbox_layout.FirstShownIdx = 1
lobby_listbox_layout.SelectedIdx = 1
lobby_listbox_layout.CursorIdx = 1
if(bFwd) then
ScriptCB_BeginLobby()
else
-- force an update, NOW. (we zapped everything leaving this screen, gotta
-- restore it on re-entry)
ScriptCB_UpdateLobby(1)
end
ListManager_fnFillContents(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
ifs_mp_lobby_SetHilight(this,1)
ifs_mp_lobby_fnShowHideItems(this,1)
IFText_fnSetString(this.IPAddr,"IP: " .. ScriptCB_GetIPAddr())
IFText_fnSetString(this.ServerName,ScriptCB_GetGameName())
IFObj_fnSetVis(this.IPAddr, (gOnlineServiceStr ~= "XLive") and (not ifs_mp_lobby.bE3Mode) and (not gFinalBuild))
-- Show server name all the time, request from Brad - NM 8/24/05
IFObj_fnSetVis(this.ServerName, 1) -- (gOnlineServiceStr ~= "XLive") and (not ifs_mp_lobby.bE3Mode) and (not gFinalBuild))
-- IFObj_fnSetVis(this.Helptext_Misc2,not ifs_mp_lobby.bE3Mode)
if ( ifs_mp_lobby_IsBandwidthVisible(this) ) then
IFObj_fnSetVis(this.Bandwidth, 1)
ifs_mp_lobby_UpdateBandwidth( this, ScriptCB_GetBandwidth() )
else
IFObj_fnSetVis(this.Bandwidth, nil)
end
if((this.bAutoLaunch) or (this.bHideOnEntry)) then
-- Hide everything ASAP
IFObj_fnSetVis(this.title,nil)
-- IFObj_fnSetVis(this.Helptext_Misc2,nil)
if(this.Helptext_Accept) then
IFObj_fnSetVis(this.Helptext_Accept,nil)
end
if(this.Helptext_Back) then
IFObj_fnSetVis(this.Helptext_Back,nil)
end
IFObj_fnSetVis(this.IPAddr,nil)
IFObj_fnSetVis(this.ServerName,nil)
IFObj_fnSetVis(this.listbox,nil)
IFObj_fnSetVis(this.columnheaders,nil)
this.bHideOnEntry = nil -- clear flag
end
-- set the visibility of the boot button
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
Exit = function(this, bFwd)
if(bFwd) then -- going to string.sub-screen
else
ScriptCB_CancelLobby() -- going back to create opts (host) or sessionlist (client)
end
-- Clear out glyph cache
gBlankListbox = 1
if(ifs_mp_lobby_listbox_contents) then
ListManager_fnFillContents(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
gBlankListbox = nil
ifs_mp_lobby_listbox_contents = {} -- clear this from memory also.
end,
Input_Accept = function(this)
if(gShellScreen_fnDefaultInputAccept(this)) then
local bExitNow = 1
if(gMouseListBox) then
if(gMouseListBox.Layout.SelectedIdx == gMouseListBox.Layout.CursorIdx) then
if(this.fDoubleClickTimer < 0.01) then
this.fDoubleClickTimer = 0.4
else
bExitNow = nil
end -- timer
else
-- Selected index changed.
gMouseListBox.Layout.SelectedIdx = gMouseListBox.Layout.CursorIdx
end
end -- gMouseListBox is valid
-- print("mp_lobby. Default accept handled, returning.")
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
if(bExitNow) then
return
end
end
if (this.CurButton == "voteboot") then
-- make sure this is updated
ifs_mp_lobby_CalcCanBoot()
if( nil ) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(this.BootVisible and Selection) then
ScriptCB_LobbyAction(Selection.indexstr, Selection.namestr, "boot")
end
else
if( this.BootVisible) then
ifs_mp_lobby_DoPopupVootBoot( nil )
end
end
-- hide the button, since we just voted
ifs_mp_lobby_CalcCanBoot()
elseif (this.CurButton == "forceboot") then
-- make sure this is updated
ifs_mp_lobby_CalcCanForceBoot()
if( nil ) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(this.ForceBootVisible and Selection) then
ScriptCB_LobbyAction(Selection.indexstr, Selection.namestr, "forceboot")
end
else
if( this.ForceBootVisible ) then
ifs_mp_lobby_DoPopupVootBoot( 1 )
end
end
-- hide the button, since we just voted
ifs_mp_lobby_CalcCanForceBoot()
else -- SM 7-Feb-05 -- if (gPlatformStr ~= "PC") then
if(lobby_listbox_layout.SelectedIdx) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
return
end
IFText_fnSetString(Popup_LobbyOpts.title,Selection.namestr)
Popup_LobbyOpts.bIsMe = Selection.bIsLocal and (Selection.iViewport == ScriptCB_GetPausingViewport())
-- print("bIsMe = ", Popup_LobbyOpts.bIsMe, " from ", Selection.bIsLocal, Selection.iViewport ,ScriptCB_GetPausingViewport())
local NumEntries = table.getn(ifs_mp_lobby_listbox_contents)
Popup_LobbyOpts.bIsSameTeam = nil
for i = 1, NumEntries do
--print("+++i=", i, Selection.iTeam, ifs_mp_lobby_listbox_contents[i].bIsLocal, ifs_mp_lobby_listbox_contents[i].namestr, ifs_mp_lobby_listbox_contents[i].iTeam )
if( ifs_mp_lobby_listbox_contents[i].bIsLocal ) then
if( Selection.iTeam == ifs_mp_lobby_listbox_contents[i].iTeam ) then
--print("+++x=", i, Selection.iTeam, ifs_mp_lobby_listbox_contents[i].bIsLocal, ifs_mp_lobby_listbox_contents[i].namestr, ifs_mp_lobby_listbox_contents[i].iTeam )
Popup_LobbyOpts.bIsSameTeam = 1
end
end
end
ifelm_shellscreen_fnPlaySound(this.acceptSound)
-- Get their muted, friend flags.
-- also get the boot flag. says if we could boot this player if we wanted to.
-- this is not absolute, there are other conditions that could hide the "boot"
-- option. all this tells us is that someone else isn't currently nominated
-- for a boot
Popup_LobbyOpts.bIsMuted,
Popup_LobbyOpts.bIsFriend,
Popup_LobbyOpts.bCanBoot,
Popup_LobbyOpts.bIsGuest,
Popup_LobbyOpts.bCanAddFriend =
ScriptCB_GetLobbyPlayerFlags(Selection.namestr, Selection.indexstr)
Popup_LobbyOpts.bOnlyForPlayer = 1
Popup_LobbyOpts.fnDone = ifs_mp_lobby_fnLobbyOptionsPopupDone;
Popup_LobbyOpts.playerIndex = Selection.indexstr
Popup_LobbyOpts:fnActivate(1)
end -- selectedidx is valid
end -- (SM 7-Feb-05 NOT) not PC
end,
Input_Back = function(this)
if(this.bShellActive) then
ifelm_shellscreen_fnPlaySound(this.exitSound)
-- Shell is active. Must prompt before backing out of screen
ifs_mp_lobby_fnShowHideItems(this,nil)
Popup_YesNo.CurButton = "no" -- default
Popup_YesNo.fnDone = ifs_mp_lobby_fnLeavePopupDone
Popup_YesNo:fnActivate(1)
if(this.bAmHost) then
gPopup_fnSetTitleStr(Popup_YesNo,"ifs.onlinelobby.cancelsession")
else
gPopup_fnSetTitleStr(Popup_YesNo,"ifs.onlinelobby.leavesession")
end
ifs_mp_lobby_fnShowHideItems(this, nil)
else
-- Game is active. Just back up to pausemenu
ScriptCB_PopScreen()
end
end,
Input_Misc = function(this)
if(gPlatformStr ~= "PC") then
-- make sure this is updated
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
if(this.ForceBootVisible) then
if( nil ) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
return
end
ScriptCB_LobbyAction(Selection.indexstr, Selection.namestr, "forceboot")
else
ifs_mp_lobby_DoPopupVootBoot( 1 )
end
elseif(this.BootVisible) then
if( nil ) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
return
end
ScriptCB_LobbyAction(Selection.indexstr, Selection.namestr, "boot")
else
ifs_mp_lobby_DoPopupVootBoot( nil )
end
end
end
end,
Input_Start = function(this)
-- if(lobby_listbox_layout.SelectedIdx ) then
-- local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
-- ScriptCB_VoteKick(Selection.namestr )
-- ifelm_shellscreen_fnPlaySound(this.acceptSound)
-- end
end,
Input_GeneralUp = function(this)
if(lobby_listbox_layout.SelectedIdx) then
ListManager_fnNavUp(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
Input_GeneralDown = function(this)
if(lobby_listbox_layout.SelectedIdx) then
ListManager_fnNavDown(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
Input_LTrigger = function(this)
if(lobby_listbox_layout.SelectedIdx) then
ListManager_fnPageUp(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
Input_RTrigger = function(this)
if(lobby_listbox_layout.SelectedIdx) then
ListManager_fnPageDown(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
-- update bandwidth
Input_GeneralLeft = function(this)
if ( ifs_mp_lobby_IsBandwidthVisible(this) ) then
local new_value = ScriptCB_GetBandwidth() - 10
if ( new_value < 10 ) then
new_value = 10
end
ifs_mp_lobby_UpdateBandwidth( this, new_value )
ScriptCB_SetBandwidth( new_value )
end
-- ScriptCB_PreviousHost()
end,
Input_GeneralRight = function(this)
if ( ifs_mp_lobby_IsBandwidthVisible(this) ) then
local new_value = ScriptCB_GetBandwidth() + 10
if ( new_value > 100 ) then
new_value = 100
end
ifs_mp_lobby_UpdateBandwidth( this, new_value )
ScriptCB_SetBandwidth( new_value )
end
-- ScriptCB_NextHost()