-
Notifications
You must be signed in to change notification settings - Fork 1
/
ifs_opt_controller_vehunit.lua
1722 lines (1522 loc) · 64 KB
/
ifs_opt_controller_vehunit.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.
--
-- Ps2 controller setup for Vehicle/Unit mode
-- Check LuaCallbacks.cpp all the links of buttons described below to the corresponding enum is done in that file
-- Search for the
gNumButtonFunctionsPerMode = 20
gSquadCommandButtonFunction0 = 99
gAnalogButtonFunction0 = 17
gButtonNames = { -- in the same as as the listing in ifs_opt_controller_common.lua
"ifs.controls.buttons.ltrig2", -- 1
"ifs.controls.buttons.ltrig1", -- 2
"ifs.controls.buttons.dpadu", -- 3
"ifs.controls.buttons.dpadl", -- 4
"ifs.controls.buttons.dpadd", -- 5
"ifs.controls.buttons.dpadr", -- 6
"ifs.controls.buttons.lang", -- 7
"ifs.controls.buttons.bsel", -- 8
"ifs.controls.buttons.bstr", -- 9
"ifs.controls.buttons.rang", -- 10
"ifs.controls.buttons.bsqr", -- 11
"ifs.controls.buttons.bcrs", -- 12
"ifs.controls.buttons.bcir", -- 13
"ifs.controls.buttons.btri", -- 14
"ifs.controls.buttons.rtrig1", -- 15
"ifs.controls.buttons.rtrig2", -- 16
"ifs.controls.buttons.yflip", -- 17 -- not used
"ifs.controls.buttons.l3", -- 18
"ifs.controls.buttons.r3", -- 19
"ifs.controls.buttons.lookslidey", -- 20
"ifs.controls.buttons.reset", -- 21 -- not used
"ifs.controls.buttons.lookslidex" -- 22
}
gButtonFunctionStrings = {
-- GLOBAL_FUNCTION_LABEL (index implies Function_ID)
--INFANTRY LINGO (add gNumButtonFunctionsPerMode*0)
"ifs.controls.General.Sprint", -- 1
"ifs.controls.General.Crouch", -- 2
"ifs.controls.General.Jump", -- 3
"ifs.controls.General.Primary", -- 4
"ifs.controls.General.Secondary", -- 5
"ifs.controls.General.PrimaryNext", -- 6
"ifs.controls.General.SecondaryNext", -- 7
"ifs.controls.General.Enter", -- 8
"ifs.controls.General.Zoom", -- 9
"ifs.controls.General.Reload", -- 10
"ifs.controls.General.SquadCommands", -- 11
"ifs.controls.General.SquadUp", -- 12 [accept]
"ifs.controls.General.SquadDown", -- 13 [decline]
"ifs.controls.General.SquadLeft", -- 14 [Now target tracking]
"ifs.controls.General.SquadRight", -- 15
"ifs.controls.General.FirstThirdPerson", -- 16
--Axis stuff
"ifs.controls.General.Move_Strafe", -- 17
"ifs.controls.General.Move_Turn", -- 18
"ifs.controls.General.FreeLook", -- 19
"ifs.controls.General.Look_Strafe", -- 20
--VEHICLE LINGO --Same controls, just different names (just add gNumButtonFunctionsPerMode*1)
"ifs.controls.General.Boost", -- 1
"ifs.controls.General.None", -- 2 --Vehicles: No Crouch
"ifs.controls.General.Jump", -- 3 ----Vehicles: Jump -> TakeOff/Land (for Gunship)
"ifs.controls.General.Primary", -- 4
"ifs.controls.General.Secondary", -- 5
"ifs.controls.General.NextPosition", -- 6
"ifs.controls.General.None", -- 7
"ifs.controls.General.Exit", -- 8
"ifs.controls.General.Zoom", -- 9
"ifs.controls.General.None", -- 10 --Vehicles: No Reload
"ifs.controls.General.SquadCommands", -- 11
"ifs.controls.General.SquadUp", -- 12
"ifs.controls.General.SquadDown", -- 13
"ifs.controls.General.SquadLeft", -- 14
"ifs.controls.General.SquadRight", -- 15
"ifs.controls.General.FirstThirdPerson", -- 16
--Axis stuff
"ifs.controls.General.Throttle_Strafe", -- 17
"ifs.controls.General.Throttle_Turn", -- 18
"ifs.controls.General.Pitch_Turn", -- 19
"ifs.controls.General.Pitch_Strafe", -- 20
--FLYER LINGO --Same controls, just different names (just add gNumButtonFunctionsPerMode*2)
"ifs.controls.General.Boost", -- 1 --Flyers: Sprint -> Boost
"ifs.controls.General.Trick", -- 2 --Flyers: Crouch -> Trick
"ifs.controls.General.Land_Takeoff", -- 3 --Flyers: Jump -> TakeOff/Land
"ifs.controls.General.Primary", -- 4
"ifs.controls.General.Secondary", -- 5
"ifs.controls.General.NextPosition", -- 6
"ifs.controls.General.None", -- 7 --Flyers have no NextSecondary
"ifs.controls.General.Exit", -- 8
"ifs.controls.General.Zoom", -- 9
"ifs.controls.General.None", -- 10 --Flyers: No Reload
"ifs.controls.General.SquadCommands", -- 11
"ifs.controls.General.SquadUp", -- 12
"ifs.controls.General.SquadDown", -- 13
"ifs.controls.General.SquadLeft", -- 14
"ifs.controls.General.SquadRight", -- 15
"ifs.controls.General.FirstThirdPerson", -- 16
--Axis stuff, has no strafe
"ifs.controls.General.Throttle_Roll", -- 17
"ifs.controls.General.Throttle_Turn", -- 18
"ifs.controls.General.Pitch_Turn", -- 19
"ifs.controls.General.Pitch_Roll", -- 20
--JEDI LINGO (add gNumButtonFunctionsPerMode*0)
"ifs.controls.General.Sprint", -- 1
"ifs.controls.General.Crouch", -- 2
"ifs.controls.General.Jump", -- 3
"ifs.controls.jedi.lightsaber", -- 4
"ifs.controls.jedi.block", -- 5
"ifs.controls.General.PrimaryNext", -- 6
"ifs.controls.jedi.switchforce", -- 7
"ifs.controls.General.Enter", -- 8
"ifs.controls.General.Zoom", -- 9
"ifs.controls.jedi.forcepower", -- 10
"ifs.controls.General.SquadCommands", -- 11
"ifs.controls.General.SquadUp", -- 12
"ifs.controls.General.SquadDown", -- 13
"ifs.controls.General.SquadLeft", -- 14 [Now target tracking]
"ifs.controls.General.SquadRight", -- 15
"ifs.controls.General.FirstThirdPerson", -- 16
--Axis stuff
"ifs.controls.General.Move_Strafe", -- 17
"ifs.controls.General.Move_Turn", -- 18
"ifs.controls.General.FreeLook", -- 19
"ifs.controls.General.Look_Strafe", -- 20
--TURRET LINGO --Same controls, just different names (just add gNumButtonFunctionsPerMode*1)
"ifs.controls.General.None", -- 1 --Turrets: No Sprint
"ifs.controls.General.None", -- 2 --Turrets: No Crouch
"ifs.controls.General.Land_Takeoff", -- 3 --Turrets: Jump -> TakeOff/Land (for Gunship)
"ifs.controls.General.Primary", -- 4
"ifs.controls.General.Secondary", -- 5
"ifs.controls.General.None", -- 6 --Turrets: No NextPosition
"ifs.controls.General.None", -- 7
"ifs.controls.General.Exit", -- 8
"ifs.controls.General.Zoom", -- 9
"ifs.controls.General.NextPosition", -- 10 --Turrets: No Reload
"ifs.controls.General.SquadCommands", -- 11 --Turrets: No SquadCommands
"ifs.controls.General.SquadUp", -- 12 --accept
"ifs.controls.General.SquadDown", -- 13 --decline
"ifs.controls.General.SquadLeft", -- 14
"ifs.controls.General.SquadRight", -- 15
"ifs.controls.General.FirstThirdPerson", -- 16
--Axis stuff
"ifs.controls.General.Zoom_Level", -- 17
"ifs.controls.General.Move_Turn", -- 18
"ifs.controls.General.FreeLook", -- 19
"ifs.controls.General.Look_Strafe", -- 20
}
--renaming things so that they actually convey some meaning..functype_t? wtf is that?
contents_functype_infantry_button = {
{ showidx = 0, },
{ showidx = 1, }, --showstr = "ifs.controls.General.Sprint", },
{ showidx = 2, }, --showstr = "ifs.controls.General.Crouch", },
{ showidx = 3, }, --showstr = "ifs.controls.General.Jump", },
{ showidx = 4, }, --showstr = "ifs.controls.General.Primary", },
{ showidx = 5, }, --showstr = "ifs.controls.General.Secondary", },
{ showidx = 6, }, --showstr = "ifs.controls.General.PrimaryNext", },
{ showidx = 7, }, --showstr = "ifs.controls.General.SecondaryNext", },
{ showidx = 8, }, --showstr = "ifs.controls.General.Action", },
{ showidx = 9, }, --showstr = "ifs.controls.General.Zoom", },
{ showidx = 10, }, --showstr = "ifs.controls.General.Reload", },
{ showidx = 11, }, --showstr = "ifs.controls.General.SquadCommands", },
{ showidx = 14, }, --showstr = "ifs.controls.General.SquadLeft", }, -> Target Tracking
--{ showidx = 16, }, --showstr = "ifs.controls.General.FirstThirdPerson", },
}
--Eventually may prove unneccesary if people decide to do things with the xtra buttons
contents_functype_vehicle_button = {
{ showidx = 0, },
{ showidx = 1, }, --showstr = "ifs.controls.General.Boost", }, --currently no sprinting
--{ showidx = 2, }, --showstr = "ifs.controls.General.None", }, --currently no crouching
{ showidx = 3, }, --showstr = "ifs.controls.General.Land_Takeoff", },
{ showidx = 4, }, --showstr = "ifs.controls.General.Primary", },
{ showidx = 5, }, --showstr = "ifs.controls.General.Secondary", },
{ showidx = 6, }, --showstr = "ifs.controls.General.PrimaryNext", },
--{ showidx = 7, }, --showstr = "ifs.controls.General.None", }, --currently no SecondaryNext
{ showidx = 8, }, --showstr = "ifs.controls.General.Action", },
{ showidx = 9, }, --showstr = "ifs.controls.General.Zoom", },
--{ showidx = 10, }, --showstr = "ifs.controls.General.Reload", },
{ showidx = 11, }, --showstr = "ifs.controls.General.SquadCommands", },
{ showidx = 14, }, --showstr = "ifs.controls.General.SquadLeft", }, -> Target Tracking
--{ showidx = 16, }, --showstr = "ifs.controls.General.FirstThirdPerson", },
}
--PS2 version
contents_functype_vehicle_buttonPS2 = {
{ showidx = 0, },
{ showidx = 1, }, --showstr = "ifs.controls.General.Boost", }, --currently no sprinting
--{ showidx = 2, }, --showstr = "ifs.controls.General.None", }, --currently no crouching
{ showidx = 3, }, --showstr = "ifs.controls.General.Land_Takeoff", },
{ showidx = 4, }, --showstr = "ifs.controls.General.Primary", },
{ showidx = 5, }, --showstr = "ifs.controls.General.Secondary", },
{ showidx = 6, }, --showstr = "ifs.controls.General.PrimaryNext", },
--{ showidx = 7, }, --showstr = "ifs.controls.General.None", }, --currently no SecondaryNext
{ showidx = 8, }, --showstr = "ifs.controls.General.Action", },
{ showidx = 9, }, --showstr = "ifs.controls.General.Zoom", },
--{ showidx = 10, }, --showstr = "ifs.controls.General.Reload", },
{ showidx = 11, }, --showstr = "ifs.controls.General.SquadCommands", },
{ showidx = 14, }, --showstr = "ifs.controls.General.SquadLeft", }, -> Target Tracking
--{ showidx = 16, }, --showstr = "ifs.controls.General.FirstThirdPerson", },
}
--Eventually may prove unneccesary if people decide to do things with the xtra buttons
contents_functype_flyer_button = {
{ showidx = 0, },
{ showidx = 1, }, --showstr = "ifs.controls.General.Boost", },
{ showidx = 2, }, --showstr = "ifs.controls.General.Trick", },
{ showidx = 3, }, --showstr = "ifs.controls.General.Land_Takeoff", },
{ showidx = 4, }, --showstr = "ifs.controls.General.Primary", },
{ showidx = 5, }, --showstr = "ifs.controls.General.Secondary", },
{ showidx = 6, }, --showstr = "ifs.controls.General.PrimaryNext", },
--{ showidx = 7, }, --showstr = "ifs.controls.General.None", }, --currently no SecondaryNext
{ showidx = 8, }, --showstr = "ifs.controls.General.Action", },
{ showidx = 9, }, --showstr = "ifs.controls.General.Zoom", },
--{ showidx = 10, }, --showstr = "ifs.controls.General.Reload", },
{ showidx = 11, }, --showstr = "ifs.controls.General.SquadCommands", },
{ showidx = 14, }, -- showstr = "ifs.controls.General.SquadLeft", }, -- currently target tracking
--{ showidx = 16, }, --showstr = "ifs.controls.General.FirstThirdPerson", },
}
contents_functype_flyer_buttonPS2 = {
{ showidx = 0, },
{ showidx = 1, }, --showstr = "ifs.controls.General.Boost", },
{ showidx = 2, }, --showstr = "ifs.controls.General.Trick", },
{ showidx = 3, }, --showstr = "ifs.controls.General.Land_Takeoff", },
{ showidx = 4, }, --showstr = "ifs.controls.General.Primary", },
{ showidx = 5, }, --showstr = "ifs.controls.General.Secondary", },
{ showidx = 6, }, --showstr = "ifs.controls.General.PrimaryNext", },
--{ showidx = 7, }, --showstr = "ifs.controls.General.None", }, --currently no SecondaryNext
{ showidx = 8, }, --showstr = "ifs.controls.General.Action", },
{ showidx = 9, }, --showstr = "ifs.controls.General.Zoom", },
--{ showidx = 10, }, --showstr = "ifs.controls.General.Reload", },
{ showidx = 11, }, --showstr = "ifs.controls.General.SquadCommands", },
{ showidx = 14, }, -- showstr = "ifs.controls.General.SquadLeft", }, -- currently target tracking
--{ showidx = 16, }, --showstr = "ifs.controls.General.FirstThirdPerson", },
}
contents_functype_jedi_button = {
{ showidx = 0, },
{ showidx = 1, }, --showstr = "ifs.controls.General.Sprint", },
{ showidx = 2, }, --showstr = "ifs.controls.General.Crouch", },
{ showidx = 3, }, --showstr = "ifs.controls.General.Jump", },
{ showidx = 4, }, --showstr = "ifs.controls.General.Primary", },
{ showidx = 5, }, --showstr = "ifs.controls.General.Secondary", },
{ showidx = 6, }, --showstr = "ifs.controls.General.PrimaryNext", },
{ showidx = 7, }, --showstr = "ifs.controls.General.SecondaryNext", },
{ showidx = 8, }, --showstr = "ifs.controls.General.Action", },
{ showidx = 9, }, --showstr = "ifs.controls.General.Zoom", },
{ showidx = 10, }, --showstr = "ifs.controls.General.Reload", },
{ showidx = 11, }, --showstr = "ifs.controls.General.SquadCommands", },
{ showidx = 14, }, --showstr = "ifs.controls.General.SquadLeft", }, -> Target Tracking
--{ showidx = 16, }, --showstr = "ifs.controls.General.FirstThirdPerson", },
}
contents_functype_turret_button = {
{ showidx = 0, },
--{ showidx = 1, }, --showstr = "ifs.controls.General.None", }, --currently no sprinting
--{ showidx = 2, }, --showstr = "ifs.controls.General.None", }, --currently no crouching
--{ showidx = 3, }, --showstr = "ifs.controls.General.Land_Takeoff", },
{ showidx = 4, }, --showstr = "ifs.controls.General.Primary", },
--{ showidx = 5, }, --showstr = "ifs.controls.General.Secondary", },
{ showidx = 6, }, --showstr = "ifs.controls.General.PrimaryNext", },
--{ showidx = 7, }, --showstr = "ifs.controls.General.None", }, --currently no SecondaryNext
{ showidx = 8, }, --showstr = "ifs.controls.General.Action", },
{ showidx = 9, }, --showstr = "ifs.controls.General.Zoom", },
--{ showidx = 10, }, --showstr = "ifs.controls.General.Reload", },
{ showidx = 11, }, --showstr = "ifs.controls.General.SquadCommands", },
--{ showidx = 16, }, --showstr = "ifs.controls.General.FirstThirdPerson", },
}
contents_functype_infantry_stick = {
{ showidx = gAnalogButtonFunction0+0, }, --showstr = "ifs.controls.General.Move_Strafe", },
{ showidx = gAnalogButtonFunction0+1, }, --showstr = "ifs.controls.General.Move_Turn", },
{ showidx = gAnalogButtonFunction0+2, }, --showstr = "iifs.controls.General.FreeLook, },
{ showidx = gAnalogButtonFunction0+3, }, --showstr = "iifs.controls.General.Look_Strafe, },
}
contents_functype_vehicle_stick = {
{ showidx = gAnalogButtonFunction0+0, }, --showstr = "ifs.controls.General.Throttle_Strafe", },
{ showidx = gAnalogButtonFunction0+1, }, --showstr = "ifs.controls.General.Throttle_Turn", },
{ showidx = gAnalogButtonFunction0+2, }, --showstr = "iifs.controls.General.Pitch_Turn, },
{ showidx = gAnalogButtonFunction0+3, }, --showstr = "iifs.controls.General.Pitch_Strafe, },
}
contents_functype_flyer_stick = {
{ showidx = gAnalogButtonFunction0+0, }, --showstr = "ifs.controls.General.Throttle_Roll", },
{ showidx = gAnalogButtonFunction0+1, }, --showstr = "ifs.controls.General.Throttle_Turn", },
{ showidx = gAnalogButtonFunction0+2, }, --showstr = "iifs.controls.General.Pitch_Turn", },
{ showidx = gAnalogButtonFunction0+3, }, --showstr = "iifs.controls.General.Pitch_Roll", },
}
contents_functype_jedi_stick = {
{ showidx = gAnalogButtonFunction0+0, }, --showstr = "ifs.controls.General.Move_Strafe", },
{ showidx = gAnalogButtonFunction0+1, }, --showstr = "ifs.controls.General.Move_Turn", },
{ showidx = gAnalogButtonFunction0+2, }, --showstr = "iifs.controls.General.FreeLook, },
{ showidx = gAnalogButtonFunction0+3, }, --showstr = "iifs.controls.General.Look_Strafe, },
}
contents_functype_turret_stick = {
{ showidx = gAnalogButtonFunction0+0, }, --showstr = "ifs.controls.General.Move_Strafe", },
-- { showidx = gAnalogButtonFunction0+1, }, --showstr = "ifs.controls.General.Move_Turn", },
{ showidx = gAnalogButtonFunction0+2, }, --showstr = "iifs.controls.General.FreeLook, },
-- { showidx = gAnalogButtonFunction0+3, }, --showstr = "iifs.controls.General.Look_Strafe, },
}
-- *******************************
-- UTILITY FUNCTIONS FOR THIS MENU
-- *******************************
-- Shows/hides all lines on this screen. ShowTable is an optional
-- parameter, shown even if the rest aren't.
function ifs_opt_controller_SetLineVisibility(this,vis,ShowTable)
local k,v
for k,v in Platform_btn_map do
local UseVis = vis
--if((k == 3) or (k == 5) or (k == 6)) then
--if((k == 4) or (k == 6)) then -- disable l and r dpad lines
-- UseVis = nil
--end
if(v.type == 99) then
-- IFObj_fnSetVis(this.lines[k],nil)
elseif (v.type ~= 5) then
IFObj_fnSetVis(this.lines[k],UseVis)
-- this.lines[k]
end
end
IFObj_fnSetVis(this.flipStatus, vis)
IFObj_fnSetVis(this.SensitivityTextX, vis)
IFObj_fnSetVis(this.SensitivityTextY, vis)
-- Dim controller a bit when items aren't visible
local ContAlpha = 1.0
if(not vis) then
ContAlpha = 0.6
end
IFObj_fnSetAlpha(this.controller,ContAlpha)
if((ShowTable) and (not vis)) then
IFObj_fnSetVis(ShowTable,1)
end
end
-- Helper function. Moves the cursor to the right location
function ifs_opt_controller_fnMoveCursor(this)
local CurItem = Platform_btn_map[this.cont_element_idx]
-- Constant, extra width per box
local kBOX_EXTRA_WIDTH = 6
local BoxW
local BoxH
local fLeft, fTop, fRight, fBot
local CurText, BoxCenterY, BoxCenterX
if(this.lines[this.cont_element_idx]) then
CurText = this.lines[this.cont_element_idx].label
-- BoxCenterY, BoxH are calc'd below
elseif (CurItem.name == "yflip") then
CurText = this.flipStatus
local fLeft, fTop, fRight, fBot = IFText_fnGetDisplayRect(CurText)
BoxH = fBot - fTop + 12
local fudgefactor = 1
if ( BoxH < 32 ) then fudgefactor = 19 end
BoxCenterY = this.flipStatus.Y + (BoxH + fudgefactor) * 0.5 --13
elseif (CurItem.name == "lookslidex") then
CurText = this.SensitivityTextX
local fLeft, fTop, fRight, fBot = IFText_fnGetDisplayRect(CurText)
BoxH = fBot - fTop + 10
local fudgefactor = 1
if ( BoxH < 32 ) then fudgefactor = 19 end
BoxCenterY = this.SensitivityTextX.Y + (BoxH + fudgefactor) * 0.5 --13
elseif (CurItem.name == "lookslidey") then
CurText = this.SensitivityTextY
local fLeft, fTop, fRight, fBot = IFText_fnGetDisplayRect(CurText)
BoxH = fBot - fTop + 10
local fudgefactor = 1
if ( BoxH < 32 ) then fudgefactor = 19 end
BoxCenterY = this.SensitivityTextY.Y + (BoxH + fudgefactor) * 0.5 --13
elseif (CurItem.name == "reset") then
BoxCenterY = this.CurPresetText.Y + 12
CurText = this.CurPresetText
BoxH = 32
end
fLeft, fTop, fRight, fBot = IFText_fnGetDisplayRect(CurText)
-- print("Disp fLeft, fTop, fRight, fBot = ",fLeft, fTop, fRight, fBot)
BoxW = fRight - fLeft + kBOX_EXTRA_WIDTH + kBOX_EXTRA_WIDTH
if(this.lines[this.cont_element_idx]) then
BoxCenterY = CurItem.ly1 + 34
BoxH = fBot - fTop + 14
--local fNameLeft, fNameTop, fNameRight, fNameBot =
-- IFText_fnGetDisplayRect(this.lines[this.cont_element_idx].label)
--BoxW = BoxW + (fNameRight - fNameLeft) + 5
end
this.cursor.width = BoxW
this.cursor.w = BoxW
this.cursor.height = BoxH
this.cursor.h = BoxH
-- bottom center items are at lx1 == 0
if(CurItem.lx1 == 0) then
IFObj_fnSetPos(this.cursor,CurItem.lx1, BoxCenterY)
--elseif (CurItem.lx1 < CurItem.lx2) then
-- right side of screen
--IFObj_fnSetPos(this.cursor, CurItem.lx1 - (this.cursor.width * 0.5) + kBOX_EXTRA_WIDTH, BoxCenterY)
else
-- Left side of screen
IFObj_fnSetPos(this.cursor, CurItem.lx1 + (this.cursor.width * 0.5) - kBOX_EXTRA_WIDTH, BoxCenterY)
end
-- the 'change' button at the bottom of the screen should go away
-- if we're on one of the options that doesn't use the button to switch.
if ( this.Helptext_Accept ) then
if ( CurItem.name == "yflip" or CurItem.name == "lookslidex"
or CurItem.name == "lookslidey" or CurItem.name == "reset" ) then
IFObj_fnSetVis(this.Helptext_Accept, nil)
else
IFObj_fnSetVis(this.Helptext_Accept, 1)
end
end
end
-- items selected by the cursor turn a different color.
function ifs_opt_controller_fnSetSelectedColor(this, buttonIdx, bSelected)
local strObj = nil
if ( this.lines[buttonIdx] ) then
strObj = this.lines[buttonIdx]
elseif ( Platform_btn_map[buttonIdx].name == "yflip" ) then
strObj = this.flipStatus
elseif ( Platform_btn_map[buttonIdx].name == "reset" ) then
strObj = this.CurPresetText
elseif ( Platform_btn_map[buttonIdx].name == "lookslidex") then
strObj = this.SensitivityTextX
elseif ( Platform_btn_map[buttonIdx].name == "lookslidey") then
strObj = this.SensitivityTextY
end
if ( strObj ) then
if ( bSelected == 0 ) then
IFObj_fnSetColor(strObj, 255, 255, 255)
else
IFObj_fnSetColor(strObj, gSelectedTextColor[1], gSelectedTextColor[2], gSelectedTextColor[3])
end
end
end
-- Helper function for navigation - moves off the current button and
-- onto the next. Handles cursor, etc.
function ifs_opt_controller_fnSetNextButton(this,Next)
IFObj_fnSetAlpha(this.buttons[this.CurButton],0.0)
ifs_opt_controller_fnSetSelectedColor(this, this.CurButton, 0)
this.CurButton = Next
IFObj_fnSetAlpha(this.buttons[this.CurButton],1.0)
ifs_opt_controller_fnSetSelectedColor(this, this.CurButton, 1)
this.cont_element_idx = this.CurButton
ifs_opt_controller_fnMoveCursor(this)
end
-- Callback for when the "really reset to defaults?" popup is over.
-- If bResult is true, user wanted to do that.
function ifs_opt_controller_fnResetPopupDone(bResult)
local this = ifs_opt_controller
AnimationMgr_AddAnimation(this.controller, {fTotalTime = 0.3, fStartAlpha = 0.4, fEndAlpha = 1,})
if(bResult) then
ScriptCB_ResetControlsToDefault()
end
local this = ifs_opt_controller
-- Always refresh all buttons, turn everything back on.
ifs_opt_controller_SetLineVisibility(this,1)
ifs_opt_controller_GetAllEntries(this)
Popup_YesNo.fnDone = nil
end
-- Callback for when the "really reset to other preset?" popup is over.
-- If bResult is true, user wanted to do that.
function ifs_opt_controller_fnPresetChangedPopupDone(bResult)
local this = ifs_opt_controller
AnimationMgr_AddAnimation(this.controller, {fTotalTime = 0.3, fStartAlpha = 0.4, fEndAlpha = 1,})
if(bResult) then
-- this should already be true
this.cont_menu_state = 2
this.bApplyPresetSettingsNow = true
ifs_opt_controller_ApplyPresetSettings(this)
else
this.cont_menu_state = 0
this.bApplyPresetSettingsNow = false
end
local this = ifs_opt_controller
-- Always refresh all buttons, turn everything back on.
ifs_opt_controller_SetLineVisibility(this,1)
ifs_opt_controller_GetAllEntries(this)
Popup_YesNo.fnDone = nil
end
-- Helper function. Given a layout (x,y,width, height), returns a
-- fully-built item.
function ifs_controller_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 - 0.5 * layout.height + 1,
}
Temp.FunctionStr = NewIFText{
x = 10, y = 0,
valign = "vcenter", halign = "left",
font = "meu_myriadpro_small",
textw = layout.width - 32, texth = layout.height,
nocreatebackground = 1,
inert_all = 1,
}
return Temp
end
-- Helper function. For a destination item (previously created w/
-- CreateItem), fills it in with data, which may be nil (==blank it)
function ifs_controller_listbox_PopulateItem(Dest, Data, bSelected, iColorR, iColorG, iColorB, fAlpha)
if(Data) then
if(Data.showidx == 0) then
IFText_fnSetString(Dest.FunctionStr,"ifs.controls.General.none")
else
local ShowIdx = Data.showidx
if(ShowIdx > 0) then
ShowIdx = ShowIdx + gNumButtonFunctionsPerMode * ifs_opt_controller.iControlMode
end
IFText_fnSetString(Dest.FunctionStr,gButtonFunctionStrings[ShowIdx])
end
IFObj_fnSetColor(Dest.FunctionStr, iColorR, iColorG, iColorB)
IFObj_fnSetAlpha(Dest.FunctionStr, fAlpha)
IFObj_fnSetVis(Dest.FunctionStr,1)
else
-- Blank the data
IFText_fnSetString(Dest.FunctionStr,"")
IFObj_fnSetVis(Dest.FunctionStr,nil)
end
end
ifs_controller_listbox_layout = {
showcount = 5, -- math.max of the visible ones above
yHeight = 35,
ySpacing = 0,
width = 180,
x = 0,
slider = 1,
CreateFn = ifs_controller_listbox_CreateItem,
PopulateFn = ifs_controller_listbox_PopulateItem,
nocreatebackground = 1,
}
-- Helper function. Given a layout (x,y,width, height), returns a
-- fully-built item.
function ifs_controller_preset_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 - 0.5 * layout.height + 1,
}
Temp.ItemText = NewIFText{
x = 10, y = 0,
valign = "vcenter", halign = "left",
font = "meu_myriadpro_small",
textw = layout.width - 42, texth = layout.height,
nocreatebackground = 1,
inert_all = 1,
}
return Temp
end
-- Helper function. For a destination item (previously created w/
-- CreateItem), fills it in with data, which may be nil (==blank it)
function ifs_controller_preset_listbox_PopulateItem(Dest, Data, bSelected, iColorR, iColorG, iColorB, fAlpha)
if(Data) then
IFText_fnSetString(Dest.ItemText,Data.title)
IFObj_fnSetColor(Dest.ItemText, iColorR, iColorG, iColorB)
IFObj_fnSetAlpha(Dest.ItemText, fAlpha)
else
-- Blank the data
IFText_fnSetString(Dest.ItemText,"")
end
IFObj_fnSetVis(Dest.ItemText,Data) -- show/hide, depending on whether data is present
end
ifs_controller_preset_listbox_layout = {
showcount = 5, -- math.max of the visible ones above
yHeight = 40,
ySpacing = 0,
width = 250,
x = 0,
slider = 1,
CreateFn = ifs_controller_preset_listbox_CreateItem,
PopulateFn = ifs_controller_preset_listbox_PopulateItem,
nocreatebackground = 1,
}
function ifs_opt_controller_CreateElements(this)
if(1) then
local w
local h
w,h,v,widescreen = ScriptCB_GetScreenInfo()
this.Background = NewIFImage
{
ZPos = 254,
x = 0,
y = 0,
alpha = 1,
UseSafezone = 0,
localpos_l = 0, localpos_t = 0,
localpos_r = w*widescreen, localpos_b = h,
texture = "opaque_black",
ColorR = 0, ColorG = 0, ColorB = 0, -- black
}
end
local k,v
for k,v in Platform_btn_map do
if(v.type ~= 99) then
-- add one element to ifs_opt_controller.buttons
this.buttons[k] = NewIFImage { texture = v.hiTex, inert_all = 1, }
this.buttons[k].x = v.x
this.buttons[k].y = v.y
IFImage_fnSetTexturePos(this.buttons[k],0,0,v.w,v.h)
IFObj_fnSetAlpha(this.buttons[k],0.0)
-- don't create it for the special case y-flip item
if( v.type ~= 5 ) then
--this.lines[k] = NewSegmentLine( v.lx1,v.ly1,v.lx2,v.ly2,"")
XPos = v.lx1
local w,h = ScriptCB_GetSafeScreenInfo()
local xAdjust = XPos
if ( XPos < 0 ) then
xAdjust = w * 0.5 + XPos
end
TextW = math.max(50, (w * 0.5) - xAdjust + 10)
this.lines[k] = NewIFContainer {
--ScreenRelativeX = 0.5, -- centre
ScreenRelativeY = 0.5, -- centre
}
--this.lines[k].buttonname = NewIFText{
-- ScreenRelativeX = 0.5,
-- ScreenRelativeY = 0.5,
-- font = "meu_myriadpro_small",
-- valign = "vcenter",
-- halign = "left",
-- string = gButtonNames[k],
-- x= v.lx1,
-- y= v.ly1,
-- ColorR = 255, ColorG = 255, ColorB = 255,
-- textw = TextW, -- - 5,
-- texth = 60,
-- nocreatebackground = 1,
-- startdelay = math.random() * 0.5,
-- leading = -3
--}
this.lines[k].label = NewIFText{
--ScreenRelativeX = 0.5,
ScreenRelativeY = 0.5,
font = "meu_myriadpro_small",
valign = "vcenter",
halign = "left",
string = gButtonNames[k],
x= v.lx1, -- + IFText_fnGetExtent(this.lines[k].buttonname),
y= v.ly1,
ColorR = 255, ColorG = 255, ColorB = 255,
textw = TextW, -- - 5,
texth = 60,
nocreatebackground = 1,
startdelay = math.random() * 0.5,
leading = -3
}
end
end
end
this.CurButton = 1
-- IFObj_fnSetAlpha(this.buttons[this.CurButton],1.0)
-- Ask game for screen size, fill in values
local r,b,v,widescreen = ScriptCB_GetScreenInfo()
--this.bgTexture.localpos_r = r*widescreen
--this.bgTexture.localpos_b = b
--this.bgTexture.uvs_b = v
ListManager_fnInitList(this.listbox,ifs_controller_listbox_layout)
ListManager_fnInitList(this.presetlistbox,ifs_controller_preset_listbox_layout)
--if(gPlatformStr == "XBox") then
this.flipStatus.y = -40
this.SensitivityTextX.y = -110
this.SensitivityTextY.y = -75
--end
if (gPlatformStr == "PS2") then
this.flipStatus.x = -225
this.SensitivityTextX.x = -225
this.SensitivityTextY.x = -225
end
local w,h = ScriptCB_GetSafeScreenInfo()
this.ResetText.y = (h * -0.5) + 30 -- put at top of screen, below title
this.ResetText.x = (w * -0.5) + 10 -- put at left of screen, below title
this.CurPresetText.y = (h * -0.5) + 70 -- put at top of screen, below title
this.CurPresetText.x = 10 -- put at left of screen, below title
if(this.Helptext_Accept) then
IFText_fnSetString(this.Helptext_Accept.helpstr,"common.change")
end
-- .y will be zapped after creation. Cache for later
this.flipStatus.Y = this.flipStatus.y
this.SensitivityTextX.Y = this.SensitivityTextX.y
this.SensitivityTextY.Y = this.SensitivityTextY.y
this.ResetText.Y = this.ResetText.y
this.CurPresetText.Y = this.CurPresetText.y
if(ScriptCB_GetShellActive()) then
--this.bgTexture = nil
end
end
-- bVis is true if the presets listbox should be visible or not.
function ifs_opt_controller_ShowPresetListbox(this, bVis)
IFObj_fnSetVis(this.presetlistbox, bVis)
IFObj_fnSetVis(this.CurPresetText, not bVis)
IFObj_fnSetVis(this.cursor, not bVis)
IFObj_fnSetVis(this.flipStatus, not bVis)
IFObj_fnSetVis(this.SensitivityTextX, (not bVis)) -- and (this.iControlMode == 0))
IFObj_fnSetVis(this.SensitivityTextY, not bVis)
ifs_opt_controller_SetLineVisibility(this, not bVis)
end
-- Update positioning, info of elements
function ifs_opt_controller_SetPresetText(this)
-- Reposition items based on the width of the "Choose Preset" text entry
-- [Localization changes that] Do this the first time we enter.
if(not this.bMovedItems) then
local w,h = ScriptCB_GetSafeScreenInfo()
local TitleW = IFText_fnGetExtent(this.ResetText)
-- HACK - GetExtent seems to return 0 the first time thru. We need
-- to keep calling it until things stabilize.
this.bMovedItems = (TitleW > 2)
this.CurPresetText.X = (w * -0.5) + 10
this.CurPresetText.Y = (h * -0.5) + 50
IFObj_fnSetPos(this.CurPresetText, this.CurPresetText.X, this.CurPresetText.Y)
Platform_btn_map[21].lx1 = this.CurPresetText.X
Platform_btn_map[21].lx2 = this.CurPresetText.X
IFObj_fnSetPos(this.presetlistbox,
this.CurPresetText.X + (ifs_controller_preset_listbox_layout.width + 35) * 0.5,
this.CurPresetText.Y + ( ifs_controller_preset_listbox_layout.showcount * (ifs_controller_preset_listbox_layout.yHeight + ifs_controller_preset_listbox_layout.ySpacing) + 30) * 0.5)
ifs_opt_controller_fnMoveCursor(this)
end
-- If the cached index of preset isn't present, then determine it
if(not this.iPresetIdx) then
-- Select which set of preset to use
if (this.iControlMode == 0) then
gControllerPresets = gControllerPresets0
elseif (this.iControlMode == 1) then
gControllerPresets = gControllerPresets1
elseif (this.iControlMode == 2) then
gControllerPresets = gControllerPresets2
elseif (this.iControlMode == 3) then
gControllerPresets = gControllerPresets3
else
gControllerPresets = gControllerPresets4
end
-- print("gControllerPresets = ", gControllerPresets)
this.iNumPreset = table.getn(gControllerPresets)
this.iPresetIdx = -1 -- not found
this.bPresetIsCustom = nil
-- Try and find current mapping in the set of preset. If not found,
-- call it 'custom'.
local i,j
local k,v
for i = 1,this.iNumPreset do
local CheckMap = gControllerPresets[i].btndefs
if(CheckMap) then
j = 1
local bMatch = true -- ScriptCB_GetYAxisFlip() == gControllerPresets[i].yFlip -- flip no longer needs to match
for k,v in Platform_btn_map do
if((v.type ~= 5) and (v.type ~= 99)) then
-- Get the Global functionID assigned to this button
local iCurFunc = ScriptCB_GetFunctionIdForButtonId(k,this.iControlMode)
if(v.name == "lang") then
--get(stick,mode)
iCurFunc = gAnalogButtonFunction0 + ScriptCB_GetFunctionIdForAnalogId(0, this.iControlMode)
elseif (v.name == "rang") then
iCurFunc = gAnalogButtonFunction0 + ScriptCB_GetFunctionIdForAnalogId(1, this.iControlMode)
end
bMatch = bMatch and (CheckMap[j][2] == iCurFunc)
j = j + 1 -- move on in parallel array
end -- v.type ~= 5.
end -- k,v loop
if(bMatch) then
-- All buttons & flip matched. Set it as the current
this.iPresetIdx = i
this.bPresetIsCustom = nil
end
end -- CheckMap exists
end -- i loop over #preset
-- If we didn't find a match above, then set it to custom (last entry)
if(this.iPresetIdx < 0) then
this.iPresetIdx = this.iNumPreset
this.bPresetIsCustom = 1
end
end
IFText_fnSetString(this.CurPresetText, gControllerPresets[this.iPresetIdx].title)
-- Also, fill the contents of this listbox, but hide it
ListManager_fnFillContents(this.presetlistbox,gControllerPresets,ifs_controller_preset_listbox_layout)
IFObj_fnSetVis(this.presetlistbox, nil)
end
ifs_opt_controller = NewIFShellScreen {
nologo = 1,
movieIntro = nil, -- played before the screen is displayed
movieBackground = nil, -- played while the screen is displayed
enterSound = "",
exitSound = "",
title = NewIFText {
-- string = "ifs.controls.Ps2controllervehunittitle",
font = "meu_myriadpro_small",
textw = 460,
y = 0,
ScreenRelativeX = 0.5, -- center
ScreenRelativeY = 0, -- top
--inert = 1,
nocreatebackground = 1,
},
ResetText = NewIFText {
ScreenRelativeX = 0.5,
ScreenRelativeY = 0.5,
ZPos = 100,
string = "ifs.controls.preset",
font = "meu_myriadpro_small",
halign = "left",
textw = 380,
texth = 40,
x = 10,
ColorR = 255, ColorB = 255, ColorG = 255,
nocreatebackground = 1,
},
CurPresetText = NewIFText {
ScreenRelativeX = 0.5,
ScreenRelativeY = 0.5,
ZPos = 100,
string = "ifs.controls.preset",
font = "meu_myriadpro_small",
halign = "left",
textw = 380,
ColorR = 255, ColorB = 255, ColorG = 255,
nocreatebackground = 1,
},
cursor = NewButtonWindow {
ScreenRelativeX = 0.5,
ScreenRelativeY = 0.5,
width = 120, w = 120,
height = 42, h = 42,
ZPos = 181, -- Behind the text items
},
controller = NewIFImage {
ScreenRelativeX = 0.5,
ScreenRelativeY = 0.5,
texture = "controller",
localpos_l = -24, -- -128,
localpos_t = -214, -- -128,
localpos_r = 232, -- 128,
localpos_b = 42, -- 128,
ZPos = 200, -- behind most things
inert_all = 1,
--inert = 1,
},
flipStatus = NewIFText {
ScreenRelativeX = 0.5,
ScreenRelativeY = 0.5,
ZPos = 100,
string = "",
font = "meu_myriadpro_small",
valign = "vcenter",
halign = "left",
textw = 220, --380,
texth = 40,
x = -270,
y = 175 - 54,
ColorR = 255, ColorB = 255, ColorG = 255,
nocreatebackground = 1,
},
SensitivityTextX = NewIFText {
ScreenRelativeX = 0.5,
ScreenRelativeY = 0.5,
ZPos = 100,
-- string = "ifs.controls.looksensitivityX",
font = "meu_myriadpro_small",
valign = "vcenter",
halign = "left",
textw = 220, --380,
texth = 40,
x = -270,
y = 125 - 65,
ColorR = 255, ColorB = 255, ColorG = 255,
nocreatebackground = 1,
},
SensitivityTextY = NewIFText {
ScreenRelativeX = 0.5,
ScreenRelativeY = 0.5,
ZPos = 100,
-- string = "ifs.controls.looksensitivityY",
font = "meu_myriadpro_small",
valign = "vcenter",
halign = "left",
textw = 220, --380,
texth = 40,
x = -270,
y = 125 - 0,
ColorR = 255, ColorB = 255, ColorG = 255,
nocreatebackground = 1,
},
--bgTexture = NewIFImage {
-- ZPos = 250,
-- ScreenRelativeX = 0,
-- ScreenRelativeY = 0,
-- UseSafezone = 0,
-- texture = "opaque_black",
-- localpos_l = 0,
-- localpos_t = 0,
-- -- Size, UVs aren't fully specified here, but in NewIFShellScreen()
--
-- inert = 1, -- delete from lua memory once created.
-- inert_all = 1,
-- },
buttons = NewIFContainer {
ScreenRelativeX = 0.5, -- centre
ScreenRelativeY = 0.5, -- centre
},
lines = NewIFContainer {
ScreenRelativeX = 0.5, -- centre
ScreenRelativeY = 0.5, -- centre
},
listbox = NewButtonWindow { ZPos = 200, x=0, y = 40,
ScreenRelativeX = 0.5, -- center
ScreenRelativeY = 0.5, -- middle of screen
width = ifs_controller_listbox_layout.width + 35,
height = ifs_controller_listbox_layout.showcount * (ifs_controller_listbox_layout.yHeight + ifs_controller_listbox_layout.ySpacing) + 20
},
presetlistbox = NewButtonWindow { ZPos = 200, x=0, y = 40,
ScreenRelativeX = 0.5, -- center
ScreenRelativeY = 0.5, -- middle of screen
width = ifs_controller_preset_listbox_layout.width + 35,
height = ifs_controller_preset_listbox_layout.showcount * (ifs_controller_preset_listbox_layout.yHeight + ifs_controller_preset_listbox_layout.ySpacing) + 30
},