-
Notifications
You must be signed in to change notification settings - Fork 1
/
ifs_sideselect.lua
360 lines (305 loc) · 9.95 KB
/
ifs_sideselect.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
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
ifs_sideselect_vbutton_layout = {
xWidth = 205,
width = 205,
xSpacing = 6,
ySpacing = 5,
font = gMenuButtonFont,
buttonlist = {
{ tag = "team1", string = "ifs.sideselect.spectate", },
{ tag = "team2", string = "ifs.sideselect.spectate", },
{ tag = "auto", string = "ifs.sideselect.autoassign", },
{ tag = "spec", string = "ifs.sideselect.spectate", },
},
title = "ifs.sideselect.chooseteam",
bBlackBackdrop = 1,
}
function ifs_sideselect_fnBuildScreen(this, mode)
local w,h = ScriptCB_GetSafeScreenInfo() -- of the usable screen
--BradR 7/27/05- removing this element
-- this.title = NewIFText {
-- string = "ifs.missionselect.pickside",
-- font = gMenuButtonFont,
-- y = 15,
-- textw = 300, -- center on screen. Fixme: do real centering!
-- ScreenRelativeX = 0.5, -- center
-- ScreenRelativeY = 0, -- top
-- inert = 1, -- delete out of Lua mem when pushed to C
-- nocreatebackground = 1,
-- }
-- Make a container that's aligned to the left-top of the screen
-- to shove our stuff into
this.Info = NewIFContainer {
ScreenRelativeX = 0.0,
ScreenRelativeY = 0.0,
inert = 1, -- delete from Lua memory once pushed to C
}
this.buttons = NewIFContainer {
ScreenRelativeX = 0.75, -- right
ScreenRelativeY = 0.5, -- center
y = 30, -- offset slightly down
x = -30,
--rotY = -30,
--rotX = -20,
--rotZ = 1,
}
-- Clamp button widths to keep them onscreen
ifs_sideselect_vbutton_layout.HardWidthMax = (w * 2 * (1.0 - this.buttons.ScreenRelativeX)) - 32
if(not ScriptCB_IsSplitscreen()) then
elseif (ScriptCB_GetNumCameras() > 2) then
-- 3/4 way splitscreen. Shrink stuff more
this.buttons.ScreenRelativeX = 0.675
ifs_sideselect_vbutton_layout.HardWidthMax = (w * (1.0 - this.buttons.ScreenRelativeX)) - 32
this.buttons.y = -10
ifs_sideselect_vbutton_layout.font = gPopupTinyTextFont
else
-- 2-way splitscreen
this.buttons.y = -15
ifs_sideselect_vbutton_layout.font = gMenuButtonFont
end
AddVerticalButtons(this.buttons,ifs_sideselect_vbutton_layout)
end
function ifs_sideselect_fnEnter(this, bFwd)
-- Default fnEnter doesn't know about the multi-viewport active buttons. So,
-- clear out varbs it uses to keep from bouncing multiple buttons at once
-- NM 8/6/05
if(this.Viewport) then
gCurScreenTable = this
SetCurButton(nil, this)
this.CurButton = nil
end
gIFShellScreenTemplate_fnEnter(this, bFwd) -- call default enter function
if(bFwd) then
local bteam1, bteam2, bauto, bspec = ScriptCB_GetSideSelectButtonSetting()
if( bteam1 == 0 ) then
this.buttons.team1.hidden = 1
this.buttons.team1.bDimmed = nil
elseif( bteam1 == 1 ) then
this.buttons.team1.hidden = nil
this.buttons.team1.bDimmed = 1
else
this.buttons.team1.hidden = nil
this.buttons.team1.bDimmed = nil
end
if( bteam2 == 0 ) then
this.buttons.team2.hidden = 1
this.buttons.team2.bDimmed = nil
elseif( bteam2 == 1 ) then
this.buttons.team2.hidden = nil
this.buttons.team2.bDimmed = 1
else
this.buttons.team2.hidden = nil
this.buttons.team2.bDimmed = nil
end
if( bauto == 0 ) then
this.buttons.auto.hidden = 1
this.buttons.auto.bDimmed = nil
elseif( bauto == 1 ) then
this.buttons.auto.hidden = nil
this.buttons.auto.bDimmed = 1
else
this.buttons.auto.hidden = nil
this.buttons.auto.bDimmed = nil
end
if( bspec == 0 ) then
this.buttons.spec.hidden = 1
this.buttons.spec.bDimmed = nil
elseif( bspec == 1 ) then
this.buttons.spec.hidden = nil
this.buttons.spec.bDimmed = 1
else
this.buttons.spec.hidden = nil
this.buttons.spec.bDimmed = nil
end
end
this.CurButton = ShowHideVerticalButtons(this.buttons, ifs_sideselect_vbutton_layout)
if(this.Viewport) then
SetCurButton(this.CurButton, this)
else
SetCurButton(this.CurButton)
end
end
ifs_sideselect1 = NewIFShellScreen {
nologo = 1,
bNohelptext_back = 1,
bNohelptext_backPC = 1,
bAcceptIsSelect = 1,
bDimBackdrop = 1,
-- Actual contents are created in ifs_sideselect_fnBuildScreen
-- Note: for now, the exe is handling all the inputs/events, so this
-- screen has no Enter/Exit/Update/Input handlers. It does have an
-- Input_Back handler to override the base class's default functionality
-- (go to previous screen)
Input_Back = function(this)
end,
Input_GeneralLeft = function(this,bFromAI)
end,
Input_GeneralRight = function(this,bFromAI)
end,
Enter = function(this, bFwd)
ifs_sideselect_fnEnter(this, bFwd)
end
}
ifs_sideselect2 = NewIFShellScreen {
nologo = 1,
bNohelptext_back = 1,
bNohelptext_backPC = 1,
bAcceptIsSelect = 1,
bDimBackdrop = 1,
-- Actual contents are created in ifs_sideselect_fnBuildScreen
-- Note: for now, the exe is handling all the inputs/events, so this
-- screen has no Enter/Exit/Update/Input handlers. It does have an
-- Input_Back handler to override the base class's default functionality
-- (go to previous screen)
Input_Back = function(this)
end,
Input_GeneralLeft = function(this,bFromAI)
end,
Input_GeneralRight = function(this,bFromAI)
end,
Enter = function(this, bFwd)
ifs_sideselect_fnEnter(this, bFwd)
end,
Input_GeneralUp = function(this)
-- If base class handled this work, then we're done
if(gShellScreen_fnDefaultInputUp(this)) then
return
end
if(this.buttons) then
this.CurButton = FollowButtonLink(this.buttons,this.CurButton,"link_up")
SetCurButton(this.CurButton, this)
end
end,
Input_GeneralDown = function(this)
-- If base class handled this work, then we're done
if(gShellScreen_fnDefaultInputUp(this)) then
return
end
if(this.buttons) then
this.CurButton = FollowButtonLink(this.buttons,this.CurButton,"link_down")
SetCurButton(this.CurButton, this)
end
end,
}
ifs_sideselect3 = NewIFShellScreen {
nologo = 1,
bNohelptext_back = 1,
bNohelptext_backPC = 1,
bAcceptIsSelect = 1,
bDimBackdrop = 1,
-- Actual contents are created in ifs_sideselect_fnBuildScreen
-- Note: for now, the exe is handling all the inputs/events, so this
-- screen has no Enter/Exit/Update/Input handlers. It does have an
-- Input_Back handler to override the base class's default functionality
-- (go to previous screen)
Input_Back = function(this)
end,
Input_GeneralLeft = function(this,bFromAI)
end,
Input_GeneralRight = function(this,bFromAI)
end,
Enter = function(this, bFwd)
ifs_sideselect_fnEnter(this, bFwd)
end,
Input_GeneralUp = function(this)
-- If base class handled this work, then we're done
if(gShellScreen_fnDefaultInputUp(this)) then
return
end
if(this.buttons) then
this.CurButton = FollowButtonLink(this.buttons,this.CurButton,"link_up")
SetCurButton(this.CurButton, this)
end
end,
Input_GeneralDown = function(this)
-- If base class handled this work, then we're done
if(gShellScreen_fnDefaultInputUp(this)) then
return
end
if(this.buttons) then
this.CurButton = FollowButtonLink(this.buttons,this.CurButton,"link_down")
SetCurButton(this.CurButton, this)
end
end,
}
ifs_sideselect4 = NewIFShellScreen {
nologo = 1,
bNohelptext_back = 1,
bNohelptext_backPC = 1,
bAcceptIsSelect = 1,
bDimBackdrop = 1,
-- Actual contents are created in ifs_sideselect_fnBuildScreen
-- Note: for now, the exe is handling all the inputs/events, so this
-- screen has no Enter/Exit/Update/Input handlers. It does have an
-- Input_Back handler to override the base class's default functionality
-- (go to previous screen)
Input_Back = function(this)
end,
Input_GeneralLeft = function(this,bFromAI)
end,
Input_GeneralRight = function(this,bFromAI)
end,
Enter = function(this, bFwd)
ifs_sideselect_fnEnter(this, bFwd)
end,
Input_GeneralUp = function(this)
-- If base class handled this work, then we're done
if(gShellScreen_fnDefaultInputUp(this)) then
return
end
if(this.buttons) then
this.CurButton = FollowButtonLink(this.buttons,this.CurButton,"link_up")
SetCurButton(this.CurButton, this)
end
end,
Input_GeneralDown = function(this)
-- If base class handled this work, then we're done
if(gShellScreen_fnDefaultInputUp(this)) then
return
end
if(this.buttons) then
this.CurButton = FollowButtonLink(this.buttons,this.CurButton,"link_down")
SetCurButton(this.CurButton, this)
end
end,
}
if(not ScriptCB_IsSplitscreen()) then
-- print("SingleScreen")
--its not splitscreen do it normally
ifs_sideselect_fnBuildScreen(ifs_sideselect1, 0)
AddIFScreen(ifs_sideselect1,"ifs_sideselect1")
ifs_sideselect2 = nil -- flush from memory
ifs_sideselect3 = nil -- flush from memory
ifs_sideselect4 = nil -- flush from memory
else
-- is splitscreen. Rearrange things
-- print("Splitscreen")
if(ScriptCB_GetNumCameras() > 2) then
local w,h = ScriptCB_GetSafeScreenInfo() -- of the usable screen
ifs_sideselect_vbutton_layout.HardWidthMax = w * 0.45
end
ifs_sideselect_fnBuildScreen(ifs_sideselect1, 1)
ifs_sideselect1.Viewport = 0
AddIFScreen(ifs_sideselect1,"ifs_sideselect1")
ifs_sideselect_fnBuildScreen(ifs_sideselect2, 1)
ifs_sideselect2.Viewport = 1
AddIFScreen(ifs_sideselect2,"ifs_sideselect2")
ifs_sideselect2 = DoPostDelete(ifs_sideselect2)
if(gPlatformStr == "XBox") then
ifs_sideselect_fnBuildScreen(ifs_sideselect3, 1)
ifs_sideselect3.Viewport = 2
AddIFScreen(ifs_sideselect3,"ifs_sideselect3")
ifs_sideselect3 = DoPostDelete(ifs_sideselect3)
ifs_sideselect_fnBuildScreen(ifs_sideselect4, 1)
ifs_sideselect4.Viewport = 3
AddIFScreen(ifs_sideselect4,"ifs_sideselect4")
ifs_sideselect4 = DoPostDelete(ifs_sideselect4)
else
ifs_sideselect3 = nil -- flush from memory
ifs_sideselect4 = nil -- flush from memory
end
end
ifs_sideselect_fnBuildScreen = nil -- free up memory
ifs_sideselect1 = DoPostDelete(ifs_sideselect1)