-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathifs_opt_sound.lua
More file actions
1405 lines (1209 loc) · 51.5 KB
/
ifs_opt_sound.lua
File metadata and controls
1405 lines (1209 loc) · 51.5 KB
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.
--
-- Helper function, sets text of
local output_modelist_content = {
{ string = "ifs.soundopt.outputmode.mono", },
{ string = "ifs.soundopt.outputmode.headphones", },
{ string = "ifs.soundopt.outputmode.stereo", },
-- { string = "ifs.soundopt.outputmode.dolby", },
{ string = "ifs.soundopt.outputmode.surround", },
{ string = "ifs.soundopt.outputmode.4point0", },
{ string = "ifs.soundopt.outputmode.5point1", },
{ string = "ifs.soundopt.outputmode.7point1", },
}
local mixerlist_content_hw = {
{ string = "ifs.soundopt.mixconfig.software", },
{ string = "ifs.soundopt.mixconfig.hardware", },
{ string = "ifs.soundopt.mixconfig.disabled", },
}
local mixerlist_content_nohw = {
{ string = "ifs.soundopt.mixconfig.software", },
{ string = "ifs.soundopt.mixconfig.disabled", },
}
----------------------------------------------------------------------------------------
-- save the profile in slot 1
----------------------------------------------------------------------------------------
function ifs_opt_sound_StartSaveProfile()
-- print("ifs_opt_top_StartSaveProfile")
ifs_saveop.doOp = "SaveProfile"
ifs_saveop.OnSuccess = ifs_opt_sound_SaveProfileSuccess
ifs_saveop.OnCancel = ifs_opt_sound_SaveProfileCancel
local iProfileIdx = 1 + ScriptCB_GetPrimaryController()
ifs_saveop.saveName = ScriptCB_GetProfileName(iProfileIdx)
ifs_saveop.saveProfileNum = iProfileIdx
ifs_movietrans_PushScreen(ifs_saveop)
end
function ifs_opt_sound_SaveProfileSuccess()
-- print("ifs_opt_top_SaveProfileSuccess")
local this = ifs_opt_sound
-- exit ifs_saveop
ScriptCB_PopScreen()
-- Replace current screen with next screen from tabs
if(this.NextScreen ~= -1) then
ScriptCB_SetIFScreen(this.NextScreen)
else
this:Input_Back(1)
end
this.NextScreen = nil
end
function ifs_opt_sound_SaveProfileCancel()
-- print("ifs_opt_top_SaveProfileCancel")
local this = ifs_opt_sound
-- exit ifs_saveop
ScriptCB_PopScreen()
-- Replace current screen with next screen from tabs
if(this.NextScreen ~= -1) then
ScriptCB_SetIFScreen(this.NextScreen)
else
this:Input_Back(1)
end
this.NextScreen = nil
end
function ModeList_CreateItem(layout)
-- Make a coordinate system pegged to the top-left of where the cursor would go.
local tinyH=ScriptCB_GetFontHeight("meu_myriadpro_small")
local Temp = NewIFContainer {
x = layout.x - 0.5 * layout.width, y=layout.y,
}
local YPos = layout.height * -0.5 + 3
Temp.text = NewIFText {
x = 10, y = YPos,
textw = layout.width - 20, texth = layout.height,
halign = "left", font = "meu_myriadpro_small", nocreatebackground=1,
}
return Temp
end
function ModeList_PopulateItem(Dest,Data)
if (Data) then
IFText_fnSetString(Dest.text,Data.string)
IFObj_fnSetVis(Dest.text,1)
else
IFObj_fnSetVis(Dest.text,nil)
end
end
outputmodelist_layout = {
showcount = 7,
width = 240,
totalheight = 120,
yHeight = 15,
ySpacing = 2,
x = 0,
y = -5,
slider = nil, -- not with 3 items
CreateFn = ModeList_CreateItem,
PopulateFn = ModeList_PopulateItem,
}
mixerlist_layout = {
showcount = 3,
width = 240,
totalheight = 50,
yHeight = 15,
ySpacing = 2,
x = 0,
y = -5,
slider = nil, -- not with 3 items
CreateFn = ModeList_CreateItem,
PopulateFn = ModeList_PopulateItem,
}
function ifs_opt_sound_fnAddOutputMode(this)
local offset_x = 85
local offset_y = 230
-- dropdown box
this.res_dropdown_btn = NewPCDropDownButton {
ScreenRelativeX = 0.5,
ScreenRelativeY = 0,
x = offset_x,
y = offset_y,
btnw = ifs_opt_sound_getBarSize(this), -- made wider to fix 9173 - NM 8/25/04
btnh = 20,
font = "meu_myriadpro_small",
tag = "_mode_btn",
string = "",
}
-- source listbox
this.modelist_listbox = NewButtonWindow {
ZPos = 100,
x = offset_x,
y = offset_y + outputmodelist_layout.totalheight / 2 + 15,
ScreenRelativeX = 0.5,
ScreenRelativeY = 0,
bg_texture = "border_dropdown",
width = ifs_opt_sound_getBarSize(this), --outputmodelist_layout.width,
height = outputmodelist_layout.totalheight + 10,
}
ListManager_fnInitList(this.modelist_listbox,outputmodelist_layout)
ListManager_fnFillContents(this.modelist_listbox,output_modelist_content,outputmodelist_layout)
local offset_x1 = 85
local offset_y1 = 300
-- dropdown box
this.mixer_dropdown_btn = NewPCDropDownButton {
ScreenRelativeX = 0.5,
ScreenRelativeY = 0,
x = offset_x1,
y = offset_y1,
btnw = ifs_opt_sound_getBarSize(this), -- made wider to fix 9173 - NM 8/25/04
btnh = 20,
font = "meu_myriadpro_small",
tag = "_mixer_btn",
string = "",
}
-- source listbox
this.mixerlist_listbox = NewButtonWindow {
ZPos = 100,
x = offset_x1,
y = offset_y1 + mixerlist_layout.totalheight / 2 + 15,
ScreenRelativeX = 0.5,
ScreenRelativeY = 0,
bg_texture = "border_dropdown",
width = ifs_opt_sound_getBarSize(this), --mixerlist_layout.width,
height = mixerlist_layout.totalheight + 10,
}
ListManager_fnInitList(this.mixerlist_listbox,mixerlist_layout)
local hweffects, hwmixing = ScriptCB_HWSupport()
local mixerlist_content
if ( hwmixing ) then
mixerlist_content = mixerlist_content_hw
else
mixerlist_content = mixerlist_content_nohw
end
ListManager_fnFillContents(this.mixerlist_listbox,mixerlist_content,mixerlist_layout)
end
function ifs_opt_sound_fnShowDropbox( this, enable )
IFObj_fnSetVis(this.modelist_listbox, enable)
this.bModeDropBoxesOpen = enable
end
function ifs_opt_sound_fnShowMixerDropbox( this, enable )
IFObj_fnSetVis(this.mixerlist_listbox, enable)
this.bMixerDropBoxesOpen = enable
end
function ifs_opt_sound_fnClickModeButtons( this )
--print( "this.bSourceDropBoxesOpen =", this.bSourceDropBoxesOpen )
--print( "this.CurButton =", this.CurButton )
if( this.bModeDropBoxesOpen ) then
--print( "gMouseListBox =", gMouseListBox )
--print( "this.source_listbox =", this.source_listbox )
if( gMouseListBox == this.modelist_listbox ) then
if( gMouseListBox.Layout.CursorIdx ) then
ScriptCB_SetOutputMode( gMouseListBox.Layout.CursorIdx )
end
gMouseListBox.Layout.SelectedIdx = gMouseListBox.Layout.CursorIdx
print( "gMouseListBox.Layout.CursorIdx = ", gMouseListBox.Layout.CursorIdx )
end
ifs_opt_sound_fnShowDropbox( this, nil )
IFObj_fnSetVis(this.mixer_dropdown_btn, 1)
elseif( this.bMixerDropBoxesOpen ) then
if( gMouseListBox == this.mixerlist_listbox ) then
if( gMouseListBox.Layout.CursorIdx ) then
ScriptCB_SetMixConfig( gMouseListBox.Layout.CursorIdx )
end
gMouseListBox.Layout.SelectedIdx = gMouseListBox.Layout.CursorIdx
print( "111gMouseListBox.Layout.CursorIdx = ", gMouseListBox.Layout.CursorIdx )
end
ifs_opt_sound_fnShowMixerDropbox( this, nil )
IFObj_fnSetVis(this.res_dropdown_btn, 1)
else
-- open the drop box
if( this.CurButton == "_mode_btn" ) then
ifs_opt_sound_fnShowDropbox( this, 1 )
IFObj_fnSetVis(this.mixer_dropdown_btn, nil)
elseif( this.CurButton == "_mixer_btn" ) then
ifs_opt_sound_fnShowMixerDropbox( this, 1 )
end
end
end
function ifs_opt_sound_fnUpdateSliders(this)
-- print("curbutton=",this.CurButton )
local VolMusic, VolSfx, VolVoice, VolBattleVoice, MaxVol, VolMaster = ScriptCB_GetVolumes()
this.sliders.master.thumbposn = (VolMaster / MaxVol)
HSlider_MoveThumb(this.sliders.master)
this.sliders.music.thumbposn = (VolMusic / MaxVol)
HSlider_MoveThumb(this.sliders.music)
this.sliders.sfx.thumbposn = (VolSfx / MaxVol)
HSlider_MoveThumb(this.sliders.sfx)
this.sliders.voice.thumbposn = (VolVoice / MaxVol)
HSlider_MoveThumb(this.sliders.voice)
this.sliders.battlevoice.thumbposn = (VolBattleVoice / MaxVol)
HSlider_MoveThumb(this.sliders.battlevoice)
if(MaxVol == 10) then
-- #%)(#%( rounding errors on PS2. This is a shortcut that seems to work
-- better than divide by 10, multiply by 100
RoundIFButtonLabel_fnSetUString(this.buttons.master, ScriptCB_tounicode(string.format("%d%%",VolMaster * 10)))
RoundIFButtonLabel_fnSetUString(this.buttons.music, ScriptCB_tounicode(string.format("%d%%",VolMusic * 10)))
RoundIFButtonLabel_fnSetUString(this.buttons.sfx, ScriptCB_tounicode(string.format("%d%%",VolSfx * 10)))
RoundIFButtonLabel_fnSetUString(this.buttons.voice, ScriptCB_tounicode(string.format("%d%%",VolVoice * 10)))
RoundIFButtonLabel_fnSetUString(this.buttons.battlevoice, ScriptCB_tounicode(string.format("%d%%",VolBattleVoice * 10)))
else
RoundIFButtonLabel_fnSetUString(this.buttons.master, ScriptCB_tounicode(string.format("%d%%",(VolMaster / MaxVol) * 100)))
RoundIFButtonLabel_fnSetUString(this.buttons.music, ScriptCB_tounicode(string.format("%d%%",VolMusic / MaxVol * 100)))
RoundIFButtonLabel_fnSetUString(this.buttons.sfx, ScriptCB_tounicode(string.format("%d%%",VolSfx / MaxVol * 100)))
RoundIFButtonLabel_fnSetUString(this.buttons.voice, ScriptCB_tounicode(string.format("%d%%",VolVoice / MaxVol * 100)))
RoundIFButtonLabel_fnSetUString(this.buttons.battlevoice, ScriptCB_tounicode(string.format("%d%%",VolBattleVoice / MaxVol * 100)))
end
if(gPlatformStr == "PC") and this.bShellMode then
IFObj_fnSetVis(this.cancelbutton, ScriptCB_HasProfileChanged())
end
end
function ifs_opt_sound_fnUpdateRadios(this)
if (ScriptCB_EffectsEnabled()) then
ifelem_SelectRadioButton(this.radiobuttons.effects, 2, true)
else
ifelem_SelectRadioButton(this.radiobuttons.effects, 1, true)
end
if (ScriptCB_GetBassManagement()) then
ifelem_SelectRadioButton(this.radiobuttons.bassmang, 2, true)
else
ifelem_SelectRadioButton(this.radiobuttons.bassmang, 1, true)
end
end
function ifs_opt_sound_fnIsASlider(button)
return (button == "master" or
button == "music" or
button == "sfx" or
button == "voice" or
button == "battlevoice")
end
function ifs_opt_sound_getBarSize(this)
-- Ask game for screen size, used to make sliders
local w
local h
w,h = ScriptCB_GetSafeScreenInfo()
this.sliders.ScreenRelativeX = this.buttonlabels.ScreenRelativeX
local SizeOfBar = 0.75 - this.buttonlabels.ScreenRelativeX
return w * SizeOfBar
end
function ifs_opt_sound_updateLogo(this)
if (gPlatformStr == "PC") then
local shellActive = ScriptCB_GetShellActive()
if (shellActive) then
local EAXversion = ScriptCB_GetEAXVersion()
-- display eax logo
if (EAXversion < 3) then
IFImage_fnSetTexture(this.soundlogo, "eax_logo")
else
IFImage_fnSetTexture(this.soundlogo, "eaxhd_logo")
end
-- if EAX is enabled
if (EAXversion > 0) then
IFObj_fnSetAlpha(this.soundlogo, 1) -- bright
if (EAXversion >= 3) then
IFObj_fnSetAlpha(this.logoInfos.envmorphing, 1)
--IFObj_fnSetAlpha(this.logoInfos.envpanning, 1)
-- don't support environmental panning
IFObj_fnSetVis(this.logoInfos.envpanning, nil)
end
if (EAXversion >= 2) then
IFObj_fnSetAlpha(this.logoInfos.occulsion, 1)
end
if (EAXversion >= 1) then
IFObj_fnSetAlpha(this.logoInfos.reverb, 1)
end
else
IFObj_fnSetAlpha(this.soundlogo, 0.3) -- dim
IFObj_fnSetAlpha(this.logoInfos.envmorphing, 0.3)
--IFObj_fnSetAlpha(this.logoInfos.envpanning, 0.3)
-- don't support environmental panning
IFObj_fnSetVis(this.logoInfos.envpanning, nil)
IFObj_fnSetAlpha(this.logoInfos.occulsion, 0.3)
IFObj_fnSetAlpha(this.logoInfos.reverb, 0.3)
end
else
IFObj_fnSetVis(this.soundlogo, nil)
IFObj_fnSetVis(this.logoInfos.envmorphing, nil)
IFObj_fnSetVis(this.logoInfos.envpanning, nil)
IFObj_fnSetVis(this.logoInfos.occulsion, nil)
IFObj_fnSetVis(this.logoInfos.reverb, nil)
end
else
IFObj_fnSetVis(this.soundlogo, nil)
end
end
function ifs_opt_sound_closeShellSound(this)
-- movie player depends upon the sound engine
ScriptCB_CloseMovie()
end
function ifs_opt_sound_restoreShellSound(bgMovie)
-- read sound data
ReadDataFileInGame("sound\\shell.lvl")
-- open voice over stream
gVoiceOverStream = OpenAudioStream("sound\\shell.lvl", "shell_vo")
-- open music stream
gMusicStream = OpenAudioStream("sound\\shell.lvl", "shell_music")
-- open movie stream
ScriptCB_OpenMovie(gMovieStream, "")
ScriptCB_SetMovieAudioBus("shellmovies")
-- set playback interval to 0
ScriptCB_SetShellMusicInterval()
-- restart background movie
if (bgMovie) then
ifelem_shellscreen_fnStartMovie(bgMovie, 0, nil, 1)
end
end
-- Updates buttons, hilighlights, etc. To be called when something changes.
function ifs_opt_sound_fnUpdateButtons(this)
local OutputMode = ScriptCB_GetOutputMode()
local MixConfig = ScriptCB_GetMixConfig()
-- setup the other text
-- see enum SpeakerConfig in sndenginebase.h for values
if (OutputMode == 1) then
RoundIFButtonLabel_fnSetString(this.buttons.output, "ifs.soundopt.outputmode.mono")
elseif (OutputMode == 2) then
RoundIFButtonLabel_fnSetString(this.buttons.output, "ifs.soundopt.outputmode.headphones")
elseif (OutputMode == 3) then
RoundIFButtonLabel_fnSetString(this.buttons.output, "ifs.soundopt.outputmode.stereo")
elseif (OutputMode == 4) then
if (MixConfig == 1 or gPlatformStr == "PS2") then
RoundIFButtonLabel_fnSetString(this.buttons.output, "ifs.soundopt.outputmode.dolby")
else
RoundIFButtonLabel_fnSetString(this.buttons.output, "ifs.soundopt.outputmode.surround")
end
elseif (OutputMode == 5) then
RoundIFButtonLabel_fnSetString(this.buttons.output, "ifs.soundopt.outputmode.4point0")
elseif (OutputMode == 6) then
RoundIFButtonLabel_fnSetString(this.buttons.output, "ifs.soundopt.outputmode.5point1")
elseif (OutputMode == 7) then
RoundIFButtonLabel_fnSetString(this.buttons.output, "ifs.soundopt.outputmode.7point1")
end
-- set output mode string
if( OutputMode > 0 and ScriptCB_GetShellActive() ) then
RoundIFButtonLabel_fnSetString( this.res_dropdown_btn, output_modelist_content[OutputMode].string )
if( outputmodelist_layout.SelectedIdx ~= OutputMode ) then
--print("outputmodelist_layout.SelectedIdx = ", OutputMode)
outputmodelist_layout.SelectedIdx = OutputMode
outputmodelist_layout.CursorIdx = OutputMode
ListManager_fnMoveCursor(this.modelist_listbox, outputmodelist_layout)
end
end
-- highlight / dim bass management option
if ((MixConfig == 2) and (OutputMode >= 6)) then
IFObj_fnSetAlpha(this.buttons.bassmang.label, 1.0)
IFObj_fnSetAlpha(this.radiobuttons.bassmang[1].radiotext, 1.0)
IFObj_fnSetAlpha(this.radiobuttons.bassmang[2].radiotext, 1.0)
this.buttons.bassmang.hidden = nil
else
IFObj_fnSetAlpha(this.buttons.bassmang.label, 0.5)
IFObj_fnSetAlpha(this.radiobuttons.bassmang[1].radiotext, 0.5)
IFObj_fnSetAlpha(this.radiobuttons.bassmang[2].radiotext, 0.5)
this.buttons.bassmang.hidden = 1
end
-- highlight / dim effects depending on support
local hweffects, hwmixing = ScriptCB_HWSupport()
if ( (MixConfig == 2 and hweffects) or MixConfig == 1 ) then
IFObj_fnSetAlpha(this.buttons.effects.label, 1.0)
IFObj_fnSetAlpha(this.radiobuttons.effects[1].radiotext, 1.0)
IFObj_fnSetAlpha(this.radiobuttons.effects[2].radiotext, 1.0)
this.buttons.effects.hidden = nil
else
IFObj_fnSetAlpha(this.buttons.effects.label, 0.5)
IFObj_fnSetAlpha(this.radiobuttons.effects[1].radiotext, 0.5)
IFObj_fnSetAlpha(this.radiobuttons.effects[2].radiotext, 0.5)
this.buttons.effects.hidden = 1
end
-- highlight / dim mixing configuration depending on support
if (hwmixing) then
IFObj_fnSetAlpha(this.buttons.mixconfig.label, 1.0)
this.buttons.mixconfig.hidden = nil
else
IFObj_fnSetAlpha(this.buttons.mixconfig.label, 0.5)
this.buttons.mixconfig.hidden = 1
end
-- see enum MixConfig in win/sndengine.h for values
if (MixConfig == 1 or MixConfig == 3) then
RoundIFButtonLabel_fnSetString(this.buttons.mixconfig, "ifs.soundopt.mixconfig.software")
if( ScriptCB_GetShellActive() ) then
RoundIFButtonLabel_fnSetString( this.mixer_dropdown_btn, "ifs.soundopt.mixconfig.software" )
mixerlist_layout.SelectedIdx = 1
mixerlist_layout.CursorIdx = 1
ListManager_fnMoveCursor(this.mixerlist_listbox, mixerlist_layout)
end
elseif (MixConfig == 2) then
RoundIFButtonLabel_fnSetString(this.buttons.mixconfig, "ifs.soundopt.mixconfig.hardware")
if( ScriptCB_GetShellActive() ) then
RoundIFButtonLabel_fnSetString( this.mixer_dropdown_btn, "ifs.soundopt.mixconfig.hardware" )
mixerlist_layout.SelectedIdx = 2
mixerlist_layout.CursorIdx = 2
ListManager_fnMoveCursor(this.mixerlist_listbox, mixerlist_layout)
end
elseif (MixConfig == 4) then
RoundIFButtonLabel_fnSetString(this.buttons.mixconfig, "ifs.soundopt.mixconfig.disabled")
if( ScriptCB_GetShellActive() ) then
RoundIFButtonLabel_fnSetString( this.mixer_dropdown_btn, "ifs.soundopt.mixconfig.disabled" )
mixerlist_layout.SelectedIdx = 3
mixerlist_layout.CursorIdx = 3
ListManager_fnMoveCursor(this.mixerlist_listbox, mixerlist_layout)
end
end
if (ScriptCB_EffectsEnabled()) then
RoundIFButtonLabel_fnSetString(this.buttons.effects, "ifs.soundopt.effects.on")
else
RoundIFButtonLabel_fnSetString(this.buttons.effects, "ifs.soundopt.effects.off")
end
if (ScriptCB_GetBassManagement()) then
RoundIFButtonLabel_fnSetString(this.buttons.bassmang, "ifs.soundopt.effects.on")
else
RoundIFButtonLabel_fnSetString(this.buttons.bassmang, "ifs.soundopt.effects.off")
end
ifs_opt_sound_updateLogo(this)
if(gPlatformStr == "PC") and this.bShellMode then
IFObj_fnSetVis(this.cancelbutton, ScriptCB_HasProfileChanged())
end
end
-- Left (button/trigger) pressed. Update things. iAmount will be 1 if dpad
-- left, 10 if trigger
function ifs_opt_sound_fnLeft(this, iAmount)
local VolMusic, VolSfx, VolVoice, VolBattleVoice, MaxVol, VolMaster = ScriptCB_GetVolumes()
if (this.CurButton == "master") then
VolMaster = math.max(VolMaster - iAmount, 0)
elseif(this.CurButton == "music") then
VolMusic = math.max(VolMusic - iAmount, 0)
elseif (this.CurButton == "sfx") then
VolSfx = math.max(VolSfx - iAmount, 0)
elseif (this.CurButton == "voice") then
VolVoice = math.max(VolVoice - iAmount, 0)
elseif (this.CurButton == "battlevoice") then
VolBattleVoice = math.max(VolBattleVoice - iAmount, 0)
elseif (this.CurButton == "mixconfig") then
ifelm_shellscreen_fnPlaySound(this.acceptSound)
ScriptCB_PreviousMixConfig()
elseif (this.CurButton == "output") then
ifelm_shellscreen_fnPlaySound(this.acceptSound)
ScriptCB_PreviousOutputMode()
elseif (this.CurButton == "effects") then
ifelm_shellscreen_fnPlaySound(this.acceptSound)
ScriptCB_ToggleEffects()
end
if (ScriptCB_GetMixConfigChanged()) then
ifs_opt_sound_closeShellSound()
ifs_opt_sound_restoreShellSound(ifs_opt_top.movieBackground)
end
-- update bus gains
ScriptCB_SetVolumes(VolMusic, VolSfx, VolVoice, VolBattleVoice, VolMaster)
-- play audition SFX / voice
if (this.CurButton == "master") then
ScriptCB_ShellPlayDelayedStream("shell_auditionSFX", 0, 0.0, "Root", 0)
elseif (this.CurButton == "sfx") then
ScriptCB_ShellPlayDelayedStream("shell_auditionSFX", 0, 0.0, "soundfx", 0)
elseif (this.CurButton == "voice") then
ScriptCB_ShellPlayDelayedStream("shell_auditionVO", 0, 0.0, "voiceover", 0)
elseif (this.CurButton == "battlevoice") then
ScriptCB_ShellPlayDelayedStream("shell_auditionVO", 0, 0.0, "battlechatter", 0)
end
if (this.CurButton == "bassmang") then
if (ScriptCB_GetBassManagement()) then
ScriptCB_SetBassManagement(nil)
else
ScriptCB_SetBassManagement(1)
end
end
ifs_opt_sound_fnUpdateButtons(this)
ifs_opt_sound_fnUpdateSliders(this)
end
-- Right (button/trigger) pressed. Update things. iAmount will be 1 if dpad
-- right, 10 if trigger
function ifs_opt_sound_fnRight(this, iAmount)
local VolMusic, VolSfx, VolVoice, VolBattleVoice, MaxVol, VolMaster = ScriptCB_GetVolumes()
if (this.CurButton == "master") then
VolMaster = math.min(VolMaster + iAmount, MaxVol)
elseif(this.CurButton == "music") then
VolMusic = math.min(VolMusic + iAmount, MaxVol)
elseif (this.CurButton == "sfx") then
VolSfx = math.min(VolSfx + iAmount, MaxVol)
elseif (this.CurButton == "voice") then
VolVoice = math.min(VolVoice + iAmount, MaxVol)
elseif (this.CurButton == "battlevoice") then
VolBattleVoice = math.min(VolBattleVoice + iAmount, MaxVol)
elseif (this.CurButton == "output") then
ifelm_shellscreen_fnPlaySound(this.acceptSound)
ScriptCB_NextOutputMode()
elseif (this.CurButton == "mixconfig") then
ifelm_shellscreen_fnPlaySound(this.acceptSound)
ScriptCB_NextMixConfig()
elseif (this.CurButton == "effects") then
ifelm_shellscreen_fnPlaySound(this.acceptSound)
ScriptCB_ToggleEffects()
end
if (ScriptCB_GetMixConfigChanged()) then
ifs_opt_sound_closeShellSound()
ifs_opt_sound_restoreShellSound(ifs_opt_top.movieBackground)
end
-- update bus gains
ScriptCB_SetVolumes(VolMusic, VolSfx, VolVoice, VolBattleVoice, VolMaster)
-- play audition SFX / voice
if (this.CurButton == "master") then
ScriptCB_ShellPlayDelayedStream("shell_auditionSFX", 0, 0.0, "Root", 0)
elseif (this.CurButton == "sfx") then
ScriptCB_ShellPlayDelayedStream("shell_auditionSFX", 0, 0.0, "soundfx", 0)
elseif (this.CurButton == "voice") then
ScriptCB_ShellPlayDelayedStream("shell_auditionVO", 0, 0.0, "voiceover", 0)
elseif (this.CurButton == "battlevoice") then
ScriptCB_ShellPlayDelayedStream("shell_auditionVO", 0, 0.0, "battlechatter", 0)
end
if (this.CurButton == "bassmang") then
if (ScriptCB_GetBassManagement()) then
ScriptCB_SetBassManagement(nil)
else
ScriptCB_SetBassManagement(1)
end
end
ifs_opt_sound_fnUpdateButtons(this)
ifs_opt_sound_fnUpdateSliders(this)
end
-- Callback for when the "reset to defaults?" popup is over. If
-- bResult is true, user wanted to reset them
function ifs_opt_sound_fnAskedResetDone(bResult)
local this = ifs_opt_sound
-- Re-show UI
IFObj_fnSetVis(this.buttons, 1)
IFObj_fnSetVis(this.buttonlabels, 1)
IFObj_fnSetVis(this.sliders, 1)
if(bResult) then
ScriptCB_ResetSoundToDefault()
ifs_opt_sound_fnUpdateButtons(this)
ifs_opt_sound_fnUpdateSliders(this)
end
end
local image_background = nil
local dim_backdrop = 1
if( 1 ) then
--if( gPCBetaBuild ) then
if( ScriptCB_GetShellActive() ) then
--print("set background iface_bg_1")
image_background = "iface_bg_1"
dim_backdrop = nil
end
end
ifs_opt_sound = NewIFShellScreen {
nologo = 1,
movieIntro = nil, -- played before the screen is displayed
movieBackground = nil, -- played while the screen is displayed
bNohelptext_backPC = 1,
bDimBackdrop = dim_backdrop,
bg_texture = image_background,
-- Note: this ScreenRelativeX is used to determine the size of
-- the sliders
buttonlabels = NewIFContainer {
ScreenRelativeX = 0.4, -- right-justified to this
ScreenRelativeY = 0,
},
buttons = NewIFContainer {
ScreenRelativeX = 1, -- text right-justified within this
ScreenRelativeY = 0,
},
radiobuttons = NewIFContainer {
ScreenRelativeX = 0.4,
ScreenRelativeY = 0,
y = -3,
},
sliders = NewIFContainer {
-- ScreenRelativeX = 0.4, -- auto-copied from buttonlabels
ScreenRelativeY = 0,
},
soundlogo = NewIFImage {
-- IFObj
ScreenRelativeX = 0.2,
ScreenRelativeY = 0.72,
UseSafezone = 0,
-- IFImage
localpos_l = 0,
localpos_t = 0,
localpos_r = 212,
localpos_b = 66,
},
logoInfos = NewIFContainer {
font = "meu_myriadpro_small",
ScreenRelativeX = 0.5,
ScreenRelativeY = 0.70
},
bNohelptext_accept = 1, -- we have our own, renamed version
-- When entering this screen, check if we need to save (triggered
-- by a subscreen or something). If so, start that process.
Enter = function(this, bFwd)
ScriptCB_MarkCurrentProfile()
this.bResetProfile = nil
if(gPlatformStr == "PC") then
-- use shell mode?
this.bShellMode =
ScriptCB_GetShellActive() and
ScriptCB_GetGameRules() ~= "metagame" and
ScriptCB_GetGameRules() ~= "campaign"
-- if in the shell...
if( this.bShellMode ) then
-- hide done and cancel buttons
IFObj_fnSetVis(this.donebutton, 1)
IFObj_fnSetVis(this.cancelbutton, false)
-- show options and sound tabs
ifs_main.option_mp = nil -- set to option
ifelem_tabmanager_SetSelected(this, gPCMainTabsLayout, "_tab_options")
ifelem_tabmanager_SetSelected(this, gPCOptionsTabsLayout, "_tab_sound", 1)
-- set pc profile & title version text
UpdatePCTitleText(this)
else
-- show done and cancel buttons
IFObj_fnSetVis(this.donebutton, true)
IFObj_fnSetVis(this.cancelbutton, true)
-- show sound tabs
ifelem_tabmanager_SelectTabGroup(this, nil, 1, nil)
ifelem_tabmanager_SetSelected(this, gPCOptionsTabsLayout, "_tab_sound", 1)
-- hide PC profile & title version text
HidePCTitleText(this)
end
-- dim tabs for PC Demo
ifs_DimTabsPCDemo(this)
else
-- gHelptext_fnMoveIcon(this.Helptext_Reset)
end
-- set label visibility
local shellActive = ScriptCB_GetShellActive()
local isPC = (gPlatformStr == "PC")
this.buttonlabels.output.hidden = (gPlatformStr == "XBox") or (isPC and not shellActive)
this.buttonlabels.mixconfig.hidden = not isPC or not shellActive
this.buttonlabels.effects.hidden = not isPC or not shellActive
this.buttonlabels.reset.hidden = not isPC --or not shellActive
this.buttonlabels.bassmang.hidden = not isPC
IFObj_fnSetVis(this.buttons.bassmang, nil)
IFObj_fnSetVis(this.buttons.effects, nil)
-- hide some of the labels
if (this.buttonlabels.output.hidden) then
IFObj_fnSetVis(this.buttonlabels.output, nil)
IFObj_fnSetVis(this.buttons.output, nil)
end
if (this.buttonlabels.mixconfig.hidden) then
IFObj_fnSetVis(this.buttonlabels.mixconfig, nil)
IFObj_fnSetVis(this.buttons.mixconfig, nil)
end
if (this.buttonlabels.effects.hidden) then
IFObj_fnSetVis(this.buttonlabels.effects, nil)
IFObj_fnSetVis(this.buttons.effects, nil)
IFObj_fnSetVis(this.radiobuttons.effects, nil)
end
if (this.buttonlabels.reset.hidden) then
IFObj_fnSetVis(this.buttonlabels.reset, nil)
IFObj_fnSetVis(this.buttons.reset, nil)
end
if (this.buttonlabels.bassmang.hidden) then
IFObj_fnSetVis(this.buttonlabels.bassmang, nil)
IFObj_fnSetVis(this.buttons.bassmang, nil)
IFObj_fnSetVis(this.radiobuttons.bassmang, nil)
end
-- use new button for reset
if(gPlatformStr == "PC") then
IFObj_fnSetVis(this.resetbutton, ( not this.buttonlabels.reset.hidden ) )
IFObj_fnSetVis(this.buttonlabels.reset, nil)
IFObj_fnSetVis(this.buttons.reset, nil)
if( ScriptCB_GetShellActive() ) then
-- initialize dropdown listbox
ListManager_fnFillContents(this.modelist_listbox,output_modelist_content,outputmodelist_layout)
local hweffects, hwmixing = ScriptCB_HWSupport()
local mixerlist_content
if ( hwmixing ) then
mixerlist_content = mixerlist_content_hw
else
mixerlist_content = mixerlist_content_nohw
end
ListManager_fnFillContents(this.mixerlist_listbox,mixerlist_content,mixerlist_layout)
IFObj_fnSetVis(this.modelist_listbox, nil)
IFObj_fnSetVis(this.buttons.output, nil)
IFObj_fnSetVis(this.mixerlist_listbox, nil)
IFObj_fnSetVis(this.buttons.mixconfig, nil)
end
end
-- make sure music is constantly playing
ScriptCB_SetShellMusicInterval(0.0)
if (not shellActive) then
-- turn off in game buses
ScriptCB_SndBusFade("soundfx", 0.0, 0.0);
ScriptCB_SndBusFade("ambience", 0.0, 0.0);
ScriptCB_SndBusFade("voiceover", 0.0, 0.0);
ScriptCB_SndBusFade("battlechatter", 0.0, 0.0);
-- fade in music bus as we need to hear it for the music slider
ScriptCB_SndBusFade("ingame_spawnducked", 0.5, 1.0);
end
ifs_opt_sound_updateLogo(this)
if( ScriptCB_GetShellActive() ) then
ifs_opt_sound_fnShowMixerDropbox(this, false)
ifs_opt_sound_fnShowDropbox(this, false)
IFObj_fnSetVis(this.mixer_dropdown_btn, 1)
IFObj_fnSetVis(this.res_dropdown_btn, 1)
end
gIFShellScreenTemplate_fnEnter(this, bFwd) -- call default enter function
AnimationMgr_AddAnimation(this.buttonlabels, {fStartAlpha = 0, fEndAlpha = 1,})
AnimationMgr_AddAnimation(this.sliders, {fStartAlpha = 0, fEndAlpha = 1,})
AnimationMgr_AddAnimation(this.soundlogo, {fStartAlpha = 0, fEndAlpha = 1,})
ifs_opt_sound_fnUpdateButtons(this)
ifs_opt_sound_fnUpdateSliders(this)
ifs_opt_sound_fnUpdateRadios(this)
-- reset the current button to the first item
this.CurButton = "master"
end, -- function Enter()
Exit = function(this, bFwd)
if( this.bResetProfile ) then
ScriptCB_ReloadMarkedProfile()
if (ScriptCB_GetMixConfigChanged()) then
ifs_opt_sound_closeShellSound()
ifs_opt_sound_restoreShellSound(ifs_opt_top.movieBackground)
end
end
if(gCurHiliteButton) then
IFButton_fnSelect(gCurHiliteButton,nil)
end
-- set label visiblity
local shellActive = ScriptCB_GetShellActive()
if (not shellActive) then
-- turn on in game subbuses
ScriptCB_SndBusFade("soundfx", 1.0, 1.0);
ScriptCB_SndBusFade("ambience", 1.0, 1.0);
ScriptCB_SndBusFade("voiceover", 1.0, 1.0);
ScriptCB_SndBusFade("battlechatter", 1.0, 1.0);
-- fade out music bus
ScriptCB_SndBusFade("ingame_spawnducked", 0.5, 0.0);
end
-- reset music play interval
ScriptCB_SetShellMusicInterval(10.0)
end,
Input_Accept = function(this)
-- If the tab manager handled this event, then we're done
if(gPlatformStr == "PC") then
-- Check tabs to see if we have a hit
this.NextScreen = ifelem_tabmanager_HandleInputAccept(this, gPCOptionsTabsLayout, 1, 1)
if(not this.NextScreen) then
this.NextScreen = ifelem_tabmanager_HandleInputAccept(this, gPCMainTabsLayout, nil, 1)
end
-- If nextscreen was handled via a callback, we're done
if(this.NextScreen == -1) then
this.NextScreen = nil
return
end
if(this.NextScreen) then
if(ScriptCB_IsCurProfileDirty()) then
ifs_opt_sound_StartSaveProfile()
return
else
-- No need to save. Just jump there
ScriptCB_SetIFScreen(this.NextScreen)
this.NextScreen = nil
return
end
end -- this.Nextscreen is valid (i.e. clicked on a tab)
end -- cur platform == PC
-- Check radio buttons
if ( ifelem_HandleRadioButtonInputAccept(this) ) then
return
end
local mixConfig = ScriptCB_GetMixConfig()
local effects = ScriptCB_EffectsEnabled()
if(this.CurButton == "_back" ) then
this.bResetProfile = 1
this:Input_Back()
return
end
if(this.CurButton == "_ok" ) then -- Make PC work better - NM 8/5/04
ifelm_shellscreen_fnPlaySound(this.acceptSound)
this.bResetProfile = nil
if(ScriptCB_IsCurProfileDirty()) then
this.NextScreen = -1 -- flag special behavior
ifs_opt_sound_StartSaveProfile()
else
this:Input_Back(1)
end
return
end
if (this.CurButton == "reset" ) then
ScriptCB_ResetSoundToDefault()
if (ScriptCB_GetMixConfigChanged()) then
ifs_opt_sound_closeShellSound()
ifs_opt_sound_restoreShellSound(ifs_opt_top.movieBackground)
end
end
-- Only the PC needs to handle this input (consoles are L/R/U/D + Back) - NM 8/3/04
if(gPlatformStr ~= "PC" ) then
return
end
-- print("ifs_opt_sound Input_Accept. gMouseOverHorz = ",gMouseOverHorz)
-- if(gMouseOverHorz) then
-- print(" gMouseOverHorz.MousePercentage = ",gMouseOverHorz.MousePercentage)
-- end
if(gMouseOverHorz) then
-- Convert mouse percentage into 0..10 scale used on this screen
local VolMusic, VolSfx, VolVoice, VolBattleVoice, MaxVol, VolMaster = ScriptCB_GetVolumes()
local NewVal = math.floor(MaxVol * gMouseOverHorz.fHitX + 0.5)
NewVal = math.max(0,NewVal)
NewVal = math.min(MaxVol,NewVal)
if(gMouseOverHorz.tag == "music") then
VolMusic = NewVal
elseif (gMouseOverHorz.tag == "sfx") then
VolSfx = NewVal
elseif (gMouseOverHorz.tag == "voice") then
VolVoice = NewVal
elseif (gMouseOverHorz.tag == "battlevoice") then
VolBattleVoice = NewVal
elseif (gMouseOverHorz.tag == "master") then
VolMaster = NewVal
end
-- update bus gains
ScriptCB_SetVolumes(VolMusic, VolSfx, VolVoice, VolBattleVoice, VolMaster)
ifs_opt_sound_fnUpdateSliders(this)
if (gMouseOverHorz.tag == "master") then
ScriptCB_ShellPlayDelayedStream("shell_auditionSFX", 0, 0.0, "Root", 0)
elseif (gMouseOverHorz.tag == "sfx") then
ScriptCB_ShellPlayDelayedStream("shell_auditionSFX", 0, 0.0, "soundfx", 0)
elseif (gMouseOverHorz.tag == "voice") then
ScriptCB_ShellPlayDelayedStream("shell_auditionVO", 0, 0.0, "voiceover", 0)
elseif (gMouseOverHorz.tag == "battlevoice") then
ScriptCB_ShellPlayDelayedStream("shell_auditionVO", 0, 0.0, "battlechatter", 0)
end
ifs_opt_sound_fnUpdateButtons(this)
return
end
ifs_opt_sound_fnClickModeButtons(this)
ifs_opt_sound_fnUpdateSliders(this)
-- print("opt_sound, CurButton = ",this.CurButton)
if (this.CurButton == "output") then