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
|
untyped
global function InitEditPilotLoadoutsMenu
struct
{
var menu
var loadoutPanel
var[NUM_PERSISTENT_PILOT_LOADOUTS] loadoutHeaders
var[NUM_PERSISTENT_PILOT_LOADOUTS] activateButtons
bool enteringEdit = false
var unlockReq
} file
void function InitEditPilotLoadoutsMenu()
{
file.menu = GetMenu( "EditPilotLoadoutsMenu" )
var menu = file.menu
AddMenuEventHandler( menu, eUIEvent.MENU_OPEN, OnPilotLoadoutsMenu_Open )
AddMenuEventHandler( menu, eUIEvent.MENU_CLOSE, OnPilotLoadoutsMenu_Close )
AddMenuEventHandler( menu, eUIEvent.MENU_INPUT_MODE_CHANGED, OnPilotLoadoutsMenu_InputModeChanged )
for ( int i = 0; i < NUM_PERSISTENT_PILOT_LOADOUTS; i++ )
{
var activateButton = Hud_GetChild( menu, "Button" + i )
activateButton.s.rowIndex <- i
Hud_SetVisible( activateButton, true )
Hud_AddEventHandler( activateButton, UIE_CLICK, OnLoadoutButton_Activate )
Hud_AddEventHandler( activateButton, UIE_GET_FOCUS, OnLoadoutButton_Focused )
Hud_AddEventHandler( activateButton, UIE_LOSE_FOCUS, OnLoadoutButton_LostFocus )
file.activateButtons[i] = activateButton
}
Hud_SetFocused( file.activateButtons[0] )
file.loadoutPanel = Hud_GetChild( menu, "PilotLoadoutDisplay" )
file.unlockReq = Hud_GetChild( menu, "UnlockReq" )
AddMenuFooterOption( menu, BUTTON_A, "#A_BUTTON_SELECT" )
AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" )
}
void function OnPilotLoadoutsMenu_Open()
{
entity player = GetUIPlayer()
if ( player == null )
return
RunMenuClientFunction( "ClearEditingPilotLoadoutIndex" )
int loadoutIndex = uiGlobal.pilotSpawnLoadoutIndex
UpdatePilotLoadoutButtons( loadoutIndex, file.activateButtons )
UpdatePilotLoadoutPanel( file.loadoutPanel, GetCachedPilotLoadout( loadoutIndex ) )
UI_SetPresentationType( ePresentationType.PILOT )
RefreshCreditsAvailable()
}
void function OnPilotLoadoutsMenu_Close()
{
entity player = GetUIPlayer()
if ( player == null )
return
foreach ( i, button in file.activateButtons )
{
string pilotLoadoutRef = "pilot_loadout_" + ( i + 1 )
if ( !IsItemNew( player, pilotLoadoutRef ) )
continue
ClearNewStatus( button, pilotLoadoutRef )
}
}
void function OnPilotLoadoutsMenu_InputModeChanged()
{
UpdatePilotLoadoutPanelBinds( file.loadoutPanel )
}
void function OnLoadoutButton_Focused( var button )
{
int index = expect int( button.s.rowIndex )
UpdatePilotLoadout( index )
string pilotLoadoutRef = "pilot_loadout_" + ( index + 1 )
string unlockReq = GetItemUnlockReqText( pilotLoadoutRef )
RHud_SetText( file.unlockReq, unlockReq )
}
void function UpdatePilotLoadout( int loadoutIndex )
{
PilotLoadoutDef loadout = GetCachedPilotLoadout( loadoutIndex )
UpdatePilotLoadoutPanel( file.loadoutPanel, loadout )
RunMenuClientFunction( "UpdatePilotModel", loadoutIndex )
}
void function OnLoadoutButton_Activate( var button )
{
if ( !IsFullyConnected() )
return
if ( Hud_IsLocked( button ) )
{
int index = expect int ( button.s.rowIndex )
string pilotLoadoutRef = "pilot_loadout_" + ( index + 1 )
array<var> buttons
foreach ( button in file.activateButtons )
{
buttons.append( button )
}
OpenBuyItemDialog( buttons, button, GetItemName( pilotLoadoutRef ), pilotLoadoutRef )
return
}
int loadoutIndex = expect int ( button.s.rowIndex )
SetEditLoadout( "pilot", loadoutIndex )
if ( EDIT_LOADOUT_SELECTS )
{
bool indexChanged = loadoutIndex != uiGlobal.pilotSpawnLoadoutIndex
if ( indexChanged )
{
EmitUISound( "Menu_LoadOut_Pilot_Select" )
if ( !IsLobby() )
uiGlobal.updatePilotSpawnLoadout = true
}
uiGlobal.pilotSpawnLoadoutIndex = loadoutIndex
ClientCommand( "RequestPilotLoadout " + loadoutIndex )
}
if ( PRE_RELEASE_DEMO && loadoutIndex < 3 )
{
UpdatePilotLoadoutButtons( loadoutIndex, file.activateButtons )
return
}
RunMenuClientFunction( "SetEditingPilotLoadoutIndex", loadoutIndex )
AdvanceMenu( GetMenu( "EditPilotLoadoutMenu" ) )
}
void function OnLoadoutButton_LostFocus( var button )
{
entity player = GetUIPlayer()
if ( !IsValid( player ) )
return
int loadoutIndex = expect int ( button.s.rowIndex )
string pilotLoadoutRef = "pilot_loadout_" + ( loadoutIndex + 1 )
ClearNewStatus( button, pilotLoadoutRef )
if ( IsItemLocked( player, pilotLoadoutRef ) )
return
PilotLoadoutDef loadout = GetCachedPilotLoadout( loadoutIndex )
if ( (RefHasAnyNewSubitem( player, loadout.primary ) || RefHasAnyNewSubitem( player, loadout.secondary ) || RefHasAnyNewSubitem( player, loadout.weapon3 )) )
Hud_SetNew( button, true )
}
|