aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/ui/menu_private_match.nut
blob: e3c1f268eda72504aea631b110369bcc5b142d01 (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
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
untyped

global function MenuPrivateMatch_Init

global function InitPrivateMatchMenu

global function HandleLockedCustomMenuItem
global function GetMapImageForMapName

struct
{
	var menu

	array matchStatusRuis

	array MMDevStringElems

	array teamSlotBackgrounds
	array teamSlotBackgroundsNeutral

	var enemyTeamBackgroundPanel
	var friendlyTeamBackgroundPanel
	var enemyTeamBackground
	var friendlyTeamBackground
	var enemyPlayersPanel
	var friendlyPlayersPanel

	var listFriendlies
	var listEnemies

	var nextMapNameLabel
	var nextGameModeLabel

	var inviteRoomButton
	var inviteFriendsButton

	int inboxHeaderIndex

	int customizeHeaderIndex
	var pilotButton
	var titanButton
	var boostsButton
	var storeButton
	var factionButton
	var bannerButton
	var patchButton
	var statsButton
	var dpadCommsButton

	var playHeader
	var customizeHeader
	var callsignHeader
	var storeHeader

	var startMatchButton
	var selectMapButton
	var selectModeButton
	var matchSettingsButton

	var callsignCard

	var spectatorLabel

	var matchSettingsPanel

	ComboStruct &lobbyComboStruct
} file

const table<asset> mapImages =
{
	mp_forwardbase_kodai = $"loadscreens/mp_forwardbase_kodai_lobby",
	mp_grave = $"loadscreens/mp_grave_lobby",
	mp_homestead = $"loadscreens/mp_homestead_lobby",
	mp_thaw = $"loadscreens/mp_thaw_lobby",
	mp_black_water_canal = $"loadscreens/mp_black_water_canal_lobby",
	mp_eden = $"loadscreens/mp_eden_lobby",
	mp_drydock = $"loadscreens/mp_drydock_lobby",
	mp_crashsite3 = $"loadscreens/mp_crashsite3_lobby",
	mp_complex3 = $"loadscreens/mp_complex3_lobby",
	mp_angel_city = $"loadscreens/mp_angle_city_r2_lobby",
	mp_colony02 = $"loadscreens/mp_colony02_lobby",
	mp_glitch = $"loadscreens/mp_glitch_lobby",
	mp_lf_stacks = $"loadscreens/mp_stacks_lobby",
	mp_lf_meadow = $"loadscreens/mp_meadow_lobby",
	mp_lf_deck = $"loadscreens/mp_lf_deck_lobby",
	mp_lf_traffic = $"loadscreens/mp_lf_traffic_lobby",
	mp_coliseum = $"loadscreens/mp_coliseum_lobby",
	mp_coliseum_column = $"loadscreens/mp_coliseum_column_lobby",
	mp_relic02 = $"loadscreens/mp_relic02_lobby",
	mp_wargames = $"loadscreens/mp_wargames_lobby",
	mp_rise = $"loadscreens/mp_rise_lobby",
	mp_lf_township = $"loadscreens/mp_lf_township_lobby",
	mp_lf_uma = $"loadscreens/mp_lf_uma_lobby",
	
	// not really sure if this should be here, whatever
	// might be good to make this modular in the future?
	sp_training = $"rui/menu/level_select/level_image1",
	sp_crashsite = $"rui/menu/level_select/level_image2",
	sp_sewers1 = $"rui/menu/level_select/level_image3",
	sp_boomtown_start = $"rui/menu/level_select/level_image4",
	sp_hub_timeshift = $"rui/menu/level_select/level_image5",
	sp_beacon = $"rui/menu/level_select/level_image6",
	sp_tday = $"rui/menu/level_select/level_image7",
	sp_s2s = $"rui/menu/level_select/level_image8",
	sp_skyway_v1 = $"rui/menu/level_select/level_image9",

	// mp converted variants
	mp_training = $"rui/menu/level_select/level_image1",
	mp_crashsite = $"rui/menu/level_select/level_image2",
	mp_sewers1 = $"rui/menu/level_select/level_image3",
	mp_boomtown_start = $"rui/menu/level_select/level_image4",
	mp_hub_timeshift = $"rui/menu/level_select/level_image5",
	mp_beacon = $"rui/menu/level_select/level_image6",
	mp_tday = $"rui/menu/level_select/level_image7",
	mp_s2s = $"rui/menu/level_select/level_image8",
	mp_skyway_v1 = $"rui/menu/level_select/level_image9",
}

void function MenuPrivateMatch_Init()
{
	PrecacheHUDMaterial( $"ui/menu/common/menu_background_neutral" )
	PrecacheHUDMaterial( $"ui/menu/common/menu_background_imc" )
	PrecacheHUDMaterial( $"ui/menu/common/menu_background_militia" )
	PrecacheHUDMaterial( $"ui/menu/common/menu_background_imc_blur" )
	PrecacheHUDMaterial( $"ui/menu/common/menu_background_militia_blur" )
	PrecacheHUDMaterial( $"ui/menu/common/menu_background_neutral_blur" )
	PrecacheHUDMaterial( $"ui/menu/common/menu_background_blackMarket" )
	PrecacheHUDMaterial( $"ui/menu/rank_menus/ranked_FE_background" )

	PrecacheHUDMaterial( $"ui/menu/lobby/friendly_slot" )
	PrecacheHUDMaterial( $"ui/menu/lobby/friendly_player" )
	PrecacheHUDMaterial( $"ui/menu/lobby/enemy_slot" )
	PrecacheHUDMaterial( $"ui/menu/lobby/enemy_player" )
	PrecacheHUDMaterial( $"ui/menu/lobby/neutral_slot" )
	PrecacheHUDMaterial( $"ui/menu/lobby/neutral_player" )
	PrecacheHUDMaterial( $"ui/menu/lobby/player_hover" )
	PrecacheHUDMaterial( $"ui/menu/main_menu/motd_background" )
	PrecacheHUDMaterial( $"ui/menu/main_menu/motd_background_happyhour" )

	AddUICallback_OnLevelInit( OnPrivateLobbyLevelInit )
}

asset function GetMapImageForMapName( string mapName )
{
	if ( mapName in mapImages )
		return mapImages[mapName]
		
	// no way to convert string => asset for dynamic stuff so
	// pain
	return expect asset ( compilestring( "return $\"loadscreens/" + mapName + "_lobby\"" )() )
}


void function InitPrivateMatchMenu()
{
	var menu = GetMenu( "PrivateLobbyMenu" )
	file.menu = menu

	AddMenuEventHandler( menu, eUIEvent.MENU_OPEN, OnPrivateMatchMenu_Open )
	AddMenuEventHandler( menu, eUIEvent.MENU_CLOSE, OnLobbyMenu_Close )
	AddMenuEventHandler( menu, eUIEvent.MENU_NAVIGATE_BACK, OnLobbyMenu_NavigateBack )

	file.startMatchButton = Hud_GetChild( menu, "StartMatchButton" )
	Hud_AddEventHandler( file.startMatchButton, UIE_CLICK, OnStartMatchButton_Activate )

	RegisterUIVarChangeCallback( "privatematch_map", Privatematch_map_Changed )
	RegisterUIVarChangeCallback( "privatematch_mode", Privatematch_mode_Changed )
	RegisterUIVarChangeCallback( "privatematch_starting", Privatematch_starting_Changed )
	RegisterUIVarChangeCallback( "gameStartTime", GameStartTime_Changed )

	file.matchStatusRuis = GetElementsByClassnameForMenus( "MatchmakingStatusRui", uiGlobal.allMenus )
	file.MMDevStringElems = GetElementsByClassnameForMenus( "MMDevStringClass", uiGlobal.allMenus )

	file.friendlyPlayersPanel = Hud_GetChild( menu, "MatchFriendliesPanel" )
	file.enemyPlayersPanel = Hud_GetChild( menu, "MatchEnemiesPanel" )

	file.listFriendlies = Hud_GetChild( file.friendlyPlayersPanel, "ListFriendlies" )
	file.listEnemies = Hud_GetChild( file.enemyPlayersPanel, "ListEnemies" )

	file.friendlyTeamBackgroundPanel = Hud_GetChild( file.friendlyPlayersPanel, "LobbyFriendlyTeamBackground" )
	file.enemyTeamBackgroundPanel = Hud_GetChild( file.enemyPlayersPanel, "LobbyEnemyTeamBackground" )

#if PC_PROG
	var panelSize = Hud_GetSize( file.enemyPlayersPanel )
	Hud_SetSize( Hud_GetChild( menu, "LobbyChatBox" ), panelSize[0], panelSize[1] )
#endif // #if PC_PROG

	file.friendlyTeamBackground = Hud_GetChild( file.friendlyTeamBackgroundPanel, "TeamBackground" )
	file.enemyTeamBackground = Hud_GetChild( file.enemyTeamBackgroundPanel, "TeamBackground" )

	file.teamSlotBackgrounds = GetElementsByClassnameForMenus( "LobbyTeamSlotBackgroundClass", uiGlobal.allMenus )
	file.teamSlotBackgroundsNeutral = GetElementsByClassnameForMenus( "LobbyTeamSlotBackgroundNeutralClass", uiGlobal.allMenus )

	file.nextMapNameLabel = Hud_GetChild( menu, "NextMapName" )
	file.nextGameModeLabel = Hud_GetChild( menu, "NextGameModeName" )

	file.callsignCard = Hud_GetChild( menu, "CallsignCard" )

	file.spectatorLabel = Hud_GetChild( menu, "SpectatorLabel" )

	file.matchSettingsPanel = Hud_GetChild( menu, "MatchSettings" )

	SetupComboButtons( menu, file.startMatchButton, file.listFriendlies )

	AddMenuFooterOption( menu, BUTTON_A, "#A_BUTTON_SELECT", "" )
	AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" )

	AddMenuFooterOption( menu, BUTTON_Y, "#Y_BUTTON_SWITCH_TEAMS", "#SWITCH_TEAMS", PCSwitchTeamsButton_Activate, CanSwitchTeams )
	AddMenuFooterOption( menu, BUTTON_X, "#X_BUTTON_MUTE", "#MOUSE2_MUTE", null, CanMute )
	AddMenuFooterOption( menu, BUTTON_SHOULDER_RIGHT, "#RB_TRIGGER_TOGGLE_SPECTATE", "#SPECTATE_TEAM", PCToggleSpectateButton_Activate, CanSwitchTeams )

	AddMenuVarChangeHandler( "focus", UpdateFooterOptions )
	AddMenuVarChangeHandler( "isFullyConnected", UpdateFooterOptions )
	AddMenuVarChangeHandler( "isPartyLeader", UpdateFooterOptions )
	AddMenuVarChangeHandler( "isPrivateMatch", UpdateFooterOptions )
	#if DURANGO_PROG
		AddMenuVarChangeHandler( "DURANGO_canInviteFriends", UpdateFooterOptions )
		AddMenuVarChangeHandler( "DURANGO_isJoinable", UpdateFooterOptions )
		AddMenuVarChangeHandler( "DURANGO_isGameFullyInstalled", UpdateFooterOptions )
	#elseif PS4_PROG
		AddMenuVarChangeHandler( "PS4_canInviteFriends", UpdateFooterOptions )
	#elseif PC_PROG
		AddMenuVarChangeHandler( "ORIGIN_isEnabled", UpdateFooterOptions )
		AddMenuVarChangeHandler( "ORIGIN_isJoinable", UpdateFooterOptions )
	#endif
}


void function OnSelectMapButton_Activate( var button )
{
	if ( Hud_IsLocked( button ) )
		return

	AdvanceMenu( GetMenu( "MapsMenu" ) )
}

void function OnSelectModeButton_Activate( var button )
{
	if ( Hud_IsLocked( button ) )
		return

	AdvanceMenu( GetMenu( "ModesMenu" ) )
}

void function OnSelectMatchSettings_Activate( var button )
{
	if ( Hud_IsLocked( button ) )
		return

	AdvanceMenu( GetMenu( "CustomMatchSettingsCategoryMenu" ) )
}

void function SetupComboButtons( var menu, var navUpButton, var navDownButton  )
{
	ComboStruct comboStruct = ComboButtons_Create( menu )
	file.lobbyComboStruct = comboStruct

	comboStruct.navUpButton = navUpButton
	comboStruct.navDownButton = navDownButton

	int headerIndex = 0
	int buttonIndex = 0
	file.playHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_PRIVATE_MATCH" )
	var selectModeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_SELECT_MODE" )
	file.selectModeButton = selectModeButton
	Hud_AddEventHandler( selectModeButton, UIE_CLICK, OnSelectModeButton_Activate )
	var selectMapButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_SELECT_MAP" )
	file.selectMapButton = selectMapButton
	Hud_AddEventHandler( selectMapButton, UIE_CLICK, OnSelectMapButton_Activate )

	file.matchSettingsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_MATCH_SETTINGS" )
	Hud_AddEventHandler( file.matchSettingsButton, UIE_CLICK, OnSelectMatchSettings_Activate )

	headerIndex++
	buttonIndex = 0
	file.customizeHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_LOADOUTS" )
	file.customizeHeaderIndex = headerIndex
	var pilotButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_PILOT" )
	file.pilotButton = pilotButton

	Hud_AddEventHandler( pilotButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "EditPilotLoadoutsMenu" ) ) )
	var titanButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_TITAN" )
	file.titanButton = titanButton
	Hud_AddEventHandler( titanButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "EditTitanLoadoutsMenu" ) ) )
	file.boostsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_BOOSTS" )
	Hud_AddEventHandler( file.boostsButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "BurnCardMenu" ) ) )
	file.dpadCommsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_COMMS" )
	Hud_AddEventHandler( file.dpadCommsButton, UIE_CLICK, OnDpadCommsButton_Activate )

	headerIndex++
	buttonIndex = 0
	file.callsignHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_CALLSIGN" )
	file.bannerButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_BANNER" )
	Hud_AddEventHandler( file.bannerButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "CallsignCardSelectMenu" ) ) )
	file.patchButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_PATCH" )
	Hud_AddEventHandler( file.patchButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "CallsignIconSelectMenu" ) ) )
	file.factionButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_FACTION" )
	Hud_AddEventHandler( file.factionButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "FactionChoiceMenu" ) ) )
	file.statsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_STATS" )
	Hud_AddEventHandler( file.statsButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "ViewStatsMenu" ) ) )

	file.callsignCard = Hud_GetChild( menu, "CallsignCard" )

	headerIndex++
	buttonIndex = 0
	file.storeHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_STORE" )
	file.storeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_STORE_BROWSE" )
	Hud_AddEventHandler( file.storeButton, UIE_CLICK, OnStoreButton_Activate )
	var storeNewReleasesButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_STORE_NEW_RELEASES" )
	Hud_AddEventHandler( storeNewReleasesButton, UIE_CLICK, OnStoreNewReleasesButton_Activate )
	var storeBundlesButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_STORE_BUNDLES" )
	Hud_AddEventHandler( storeBundlesButton, UIE_CLICK, OnStoreBundlesButton_Activate )

	headerIndex++
	buttonIndex = 0
	var settingsHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_SETTINGS" )
	var controlsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_CONTROLS" )
	Hud_AddEventHandler( controlsButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "ControlsMenu" ) ) )
	#if CONSOLE_PROG
		var avButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#AUDIO_VIDEO" )
		Hud_AddEventHandler( avButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "AudioVideoMenu" ) ) )
	#elseif PC_PROG
		var videoButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#AUDIO" )
		Hud_AddEventHandler( videoButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "AudioMenu" ) ) )
		var soundButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#VIDEO" )
		Hud_AddEventHandler( soundButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "VideoMenu" ) ) )
	#endif
	var knbButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#KNB_MENU_HEADER" )
	Hud_AddEventHandler( knbButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "KnowledgeBaseMenu" ) ) )

	ComboButtons_Finalize( comboStruct )
}


bool function IsPlayerListFocused()
{
	var focusedItem = GetFocus()

	// The check for GetScriptID existing isn't ideal, but if the text chat text output element has focus it will script error otherwise
	return ( (focusedItem != null) && ("GetScriptID" in focusedItem) && (Hud_GetScriptID( focusedItem ) == "PlayerListButton") )
}

bool function MatchResultsExist()
{
	return true // TODO
}

bool function CanSwitchTeams()
{
	return ( GetMenuVarBool( "isPrivateMatch" ) && ( level.ui.privatematch_starting != ePrivateMatchStartState.STARTING ) )
}

bool function CanMute()
{
	return IsPlayerListFocused()
}

void function OnLobbyMenu_Open()
{
	Assert( IsConnected() )

	UpdatePrivateMatchButtons()

	thread UpdateLobbyUI()
	thread LobbyMenuUpdate( GetMenu( "PrivateLobbyMenu" ) )

	if ( uiGlobal.activeMenu == GetMenu( "PrivateLobbyMenu" ) )
		UI_SetPresentationType( ePresentationType.NO_MODELS )

	if ( IsFullyConnected() )
	{
		entity player = GetUIPlayer()
		if ( !IsValid( player ) )
			return

		while ( player.GetPersistentVarAsInt( "initializedVersion" ) < PERSISTENCE_INIT_VERSION )
		{
			WaitFrame()
		}

		UpdateCallsignElement( file.callsignCard )
		RefreshCreditsAvailable()

		bool emotesAreEnabled = EmotesEnabled()
		// "Customize"
		{
			bool anyNewPilotItems = HasAnyNewPilotItems( player )
			bool anyNewTitanItems = HasAnyNewTitanItems( player )
			bool anyNewBoosts = HasAnyNewBoosts( player )
			bool anyNewCommsIcons = false // emotesAreEnabled ? HasAnyNewDpadCommsIcons( player ) : false
			bool anyNewCustomizeHeader = (anyNewPilotItems || anyNewTitanItems || anyNewBoosts || anyNewCommsIcons)

			RuiSetBool( Hud_GetRui( file.customizeHeader ), "isNew", anyNewCustomizeHeader )
			ComboButton_SetNew( file.pilotButton, anyNewPilotItems )
			ComboButton_SetNew( file.titanButton, anyNewTitanItems )
			ComboButton_SetNew( file.boostsButton, anyNewBoosts )
			ComboButton_SetNew( file.dpadCommsButton, anyNewCommsIcons )

			if ( !emotesAreEnabled )
			{
				Hud_Hide( file.dpadCommsButton )
				ComboButtons_ResetColumnFocus( file.lobbyComboStruct )
			}
			else
			{
				Hud_Show( file.dpadCommsButton )
			}
		}

		// "Store"
		{
			bool storeIsNew = DLCStoreShouldBeMarkedAsNew()
			RuiSetBool( Hud_GetRui( file.storeHeader ), "isNew", storeIsNew )
			ComboButton_SetNew( file.storeButton, storeIsNew )
		}

		// "Callsign"
		{
			bool anyNewBanners = HasAnyNewCallsignBanners( player )
			bool anyNewPatches = HasAnyNewCallsignPatches( player )
			bool anyNewFactions = HasAnyNewFactions( player )
			bool anyNewCallsignHeader = (anyNewBanners || anyNewPatches || anyNewFactions)

			RuiSetBool( Hud_GetRui( file.callsignHeader ), "isNew", anyNewCallsignHeader )
			ComboButton_SetNew( file.bannerButton, anyNewBanners )
			ComboButton_SetNew( file.patchButton, anyNewPatches )
			ComboButton_SetNew( file.factionButton, anyNewFactions )
		}
	}
}

void function LobbyMenuUpdate( var menu )
{
	EndSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )

	while ( GetTopNonDialogMenu() == menu )
	{
		WaitFrame()
	}
}



void function OnLobbyMenu_Close()
{
	Signal( uiGlobal.signalDummy, "OnCloseLobbyMenu" )
}

void function OnLobbyMenu_NavigateBack()
{
	LeaveDialog()
}

function GameStartTime_Changed()
{
	printt( "GameStartTime_Changed", level.ui.gameStartTime )
	UpdateGameStartTimeCounter()
}

function UpdateGameStartTimeCounter()
{
	if ( level.ui.gameStartTime == null )
	{
		MatchmakingSetSearchText( "" )
		MatchmakingSetCountdownTimer( 0.0 )
		HideMatchmakingStatusIcons()
		return
	}

	MatchmakingSetSearchText( "#STARTING_IN_LOBBY" )
	MatchmakingSetCountdownTimer( expect float( level.ui.gameStartTime + 0.0 ) )
	ShowMatchmakingStatusIcons()
}

function UpdateDebugStatus()
{
	EndSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )

	OnThreadEnd(
		function() : ()
		{
			foreach ( elem in file.MMDevStringElems )
				Hud_Hide( elem )
		}
	)

	foreach ( elem in file.MMDevStringElems )
		Hud_Show( elem )

	while ( true )
	{
		local strstr = GetLobbyDevString()
		foreach ( elem in file.MMDevStringElems )
			Hud_SetText( elem, strstr )

		WaitFrameOrUntilLevelLoaded()
	}
}

void function SetMapInfo( string mapName )
{
	var nextMapImage = Hud_GetChild( file.menu, "NextMapImage" )

	asset mapImage = GetMapImageForMapName( mapName )
	RuiSetImage( Hud_GetRui( nextMapImage ), "basicImage", mapImage )
	Hud_Show( nextMapImage )

	Hud_SetText( file.nextMapNameLabel, GetMapDisplayName( mapName ) )
}

void function SetModeInfo( string modeName )
{
	var nextModeIcon = Hud_GetChild( file.menu, "NextModeIcon" )
	RuiSetImage( Hud_GetRui( nextModeIcon ), "basicImage", GetPlaylistThumbnailImage( modeName ) )
	Hud_Show( nextModeIcon )

	Hud_SetText( file.nextGameModeLabel, GetGameModeDisplayName( modeName ) )
}

function Privatematch_map_Changed()
{
	if ( !IsPrivateMatch() )
		return
	if ( !IsLobby() )
		return

	string mapName = PrivateMatch_GetSelectedMap()
	SetMapInfo( mapName )
}

function Privatematch_mode_Changed()
{
	if ( !IsPrivateMatch() )
		return
	if ( !IsLobby() )
		return

	string modeName = PrivateMatch_GetSelectedMode()
	SetModeInfo( modeName )

	UpdatePrivateMatchButtons()
	UpdateMatchSettingsForGamemode()
}


function Privatematch_starting_Changed()
{
	if ( !IsPrivateMatch() )
		return
	if ( !IsLobby() )
		return

	UpdatePrivateMatchButtons()
	UpdateFooterOptions()
}


function UpdatePrivateMatchButtons()
{
	var menu = file.menu

	if ( level.ui.privatematch_starting == ePrivateMatchStartState.STARTING )
	{
		RHud_SetText( file.startMatchButton, "#STOP_MATCH" )
		Hud_SetLocked( file.selectMapButton, true )
		Hud_SetLocked( file.selectModeButton, true )
		Hud_SetLocked( file.matchSettingsButton, true )
	}
	else
	{
		RHud_SetText( file.startMatchButton, "#START_MATCH" )
		Hud_SetLocked( file.selectMapButton, false )
		Hud_SetLocked( file.selectModeButton, false )

		string modeName = PrivateMatch_GetSelectedMode()
		bool settingsLocked = IsFDMode( modeName )

		if ( settingsLocked && uiGlobal.activeMenu == GetMenu( "MatchSettingsMenu" ) )
			CloseActiveMenu()

		Hud_SetLocked( file.matchSettingsButton, settingsLocked )
	}
}

function UpdateLobbyUI()
{
	if ( uiGlobal.updatingLobbyUI )
		return
	uiGlobal.updatingLobbyUI = true

	thread UpdateLobby()
	thread UpdateDebugStatus()
	thread UpdatePlayerInfo()

	if ( uiGlobal.EOGOpenInLobby )
		EOGOpen()

	WaitSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )
	uiGlobal.updatingLobbyUI = false
}

function UpdateLobby()
{
	EndSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )

	var menu = file.menu

	WaitFrameOrUntilLevelLoaded()

	while ( true )
	{
		if ( !IsConnected() )
		{
			WaitFrameOrUntilLevelLoaded()
			continue
		}

		menu.RunAnimationScript( "PrivateMatchLobby" )
		// Force the animation scripts (which have zero duration) to complete before anything can cancel them.
		ForceUpdateHUDAnimations()

		UpdatePrivateMatchButtons()

		int gamemodeIdx = expect int( level.ui.privatematch_mode )
		int numPlaylistOverrides = GetPlaylistVarOverridesCount()
		string playlistOverridesDesc = ""
		for ( int varIdx = 0; varIdx < numPlaylistOverrides; ++varIdx )
		{	
			// temp fix for playlistoverrides that aren't handled by private match
			string varName = GetPlaylistVarOverrideNameByIndex( varIdx )
			
			if ( varName in MatchSettings_PlaylistVarLabels )
			{
				float varOrigVal = float( GetCurrentPlaylistGamemodeByIndexVar( gamemodeIdx, varName, false ) )
				float varOverrideVal = float( GetCurrentPlaylistGamemodeByIndexVar( gamemodeIdx, varName, true ) )
				if ( varOrigVal == varOverrideVal ) // stuff seems to break outside of northstar servers since we dont always use private_match playlist
					continue
	
				string label = Localize( MatchSettings_PlaylistVarLabels[varName] ) + ": "
				string value = MatchSettings_FormatPlaylistVarValue( varName, varOverrideVal )
				playlistOverridesDesc = playlistOverridesDesc + label + "`2" + value + " `0\n"
			}
			else
			{
				bool shouldBreak = false
				
				foreach ( string category in GetPrivateMatchSettingCategories( true ) )
				{
					foreach ( CustomMatchSettingContainer setting in GetPrivateMatchCustomSettingsForCategory( category ) )
					{
						if ( setting.playlistVar == varName )
						{
							if ( setting.isEnumSetting )
								playlistOverridesDesc += Localize( setting.localizedName ) + ": `2" + Localize( setting.enumNames[ setting.enumValues.find( expect string ( GetCurrentPlaylistVar( varName ) ) ) ] ) + "`0\n"
							else
								playlistOverridesDesc += Localize( setting.localizedName ) + ": `2" + GetCurrentPlaylistVar( varName ) + "`0\n"
							
							shouldBreak = true
							break
						}
					}
					
					if ( shouldBreak )
						break
				}
			}
		}

		if ( playlistOverridesDesc.len() )
		{
			RuiSetString( Hud_GetRui( file.matchSettingsPanel ), "description", playlistOverridesDesc )
			Hud_Show( file.matchSettingsPanel )
		}
		else
		{
			Hud_Hide( file.matchSettingsPanel )
		}

		if ( GetUIPlayer() && GetPersistentVar( "privateMatchState" ) == 1 )
			Hud_SetVisible( file.spectatorLabel, true )
		else
			Hud_SetVisible( file.spectatorLabel, false )

		WaitFrameOrUntilLevelLoaded()
	}
}

void function OnSettingsButton_Activate( var button )
{
	if ( level.ui.privatematch_starting == ePrivateMatchStartState.STARTING )
		return

	AdvanceMenu( GetMenu( "MatchSettingsMenu" ) )
}


void function OnPrivateMatchButton_Activate( var button )
{
	ShowPrivateMatchConnectDialog()
	ClientCommand( "match_playlist private_match" )
	ClientCommand( "StartPrivateMatchSearch" )
}

void function OnStartMatchButton_Activate( var button )
{
	if ( AmIPartyLeader() || GetPartySize() == 1 )
		ClientCommand( "PrivateMatchLaunch" )
}

function HandleLockedCustomMenuItem( menu, button, tipInfo, hideTip = false )
{
	array<var> elements = GetElementsByClassname( menu, "HideWhenLocked" )
	var buttonTooltip = Hud_GetChild( menu, "ButtonTooltip" )
	var toolTipLabel = Hud_GetChild( buttonTooltip, "Label" )

	if ( Hud_IsLocked( button ) && !hideTip )
	{
		foreach( elem in elements )
			Hud_Hide( elem )

		local tipArray = clone tipInfo
		tipInfo.resize( 6, null )

		Hud_SetText( toolTipLabel, tipInfo[0], tipInfo[1], tipInfo[2], tipInfo[3], tipInfo[4], tipInfo[5] )

		local buttonPos = button.GetAbsPos()
		local buttonHeight = button.GetHeight()
		local tooltipHeight = buttonTooltip.GetHeight()
		local yOffset = ( tooltipHeight - buttonHeight ) / 2.0

		buttonTooltip.SetPos( buttonPos[0] + button.GetWidth() * 0.9, buttonPos[1] - yOffset )
		Hud_Show( buttonTooltip )

		return true
	}
	else
	{
		foreach( elem in elements )
			Hud_Show( elem )
		Hud_Hide( buttonTooltip )
	}
	return false
}

void function PrivateMatchSwitchTeams( button )
{
	if ( !IsPrivateMatch() )
		return

	if ( !IsConnected() )
		return

	if ( uiGlobal.activeMenu != file.menu )
		return

	EmitUISound( "Menu_GameSummary_ScreenSlideIn" )

	ClientCommand( "PrivateMatchSwitchTeams" )
}

void function HideMatchmakingStatusIcons()
{
	foreach ( element in file.matchStatusRuis )
		RuiSetBool( Hud_GetRui( element ), "iconVisible", false )
}

void function ShowMatchmakingStatusIcons()
{
	foreach ( element in file.matchStatusRuis )
		RuiSetBool( Hud_GetRui( element ), "iconVisible", true )
}

void function MatchmakingSetSearchText( string searchText, var param1 = "", var param2 = "", var param3 = "", var param4 = "" )
{
	foreach ( element in file.matchStatusRuis )
	{
		RuiSetBool( Hud_GetRui( element ), "statusHasText", searchText != "" )

		RuiSetString( Hud_GetRui( element ), "statusText", Localize( searchText, param1, param2, param3, param4 ) )
	}
}


void function MatchmakingSetCountdownTimer( float time )
{
	foreach ( element in file.matchStatusRuis )
	{
		RuiSetBool( Hud_GetRui( element ), "timerHasText", time != 0.0 )
		RuiSetGameTime( Hud_GetRui( element ), "timerEndTime", time )
	}
}


void function OnPrivateLobbyLevelInit()
{
	UpdateCallsignElement( file.callsignCard )
	RefreshCreditsAvailable()
}


function UpdatePlayerInfo()
{
	EndSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )

	var menu = file.menu

	WaitFrameOrUntilLevelLoaded()

	while ( true )
	{
		RefreshCreditsAvailable()
		WaitFrame()
	}
}

void function OnPrivateMatchMenu_Open()
{
	Lobby_SetFDMode( false )
	OnLobbyMenu_Open()
}