@@ -55,7 +55,7 @@ void idMenuScreen_Shell_SystemOptions::Initialize( idMenuHandler* data )
5555
5656 SetSpritePath ( " menuSystemOptions" );
5757
58- options = new ( TAG_SWF ) idMenuWidget_DynamicList ();
58+ options = new ( TAG_SWF ) idMenuWidget_SystemOptionsList (); // RB: allow more options than defined in the SWF
5959 options->SetNumVisibleOptions ( NUM_SYSTEM_OPTIONS_OPTIONS );
6060 options->SetSpritePath ( GetSpritePath (), " info" , " options" );
6161 options->SetWrappingAllowed ( true );
@@ -104,6 +104,7 @@ void idMenuScreen_Shell_SystemOptions::Initialize( idMenuHandler* data )
104104 control->AddEventAction ( WIDGET_EVENT_PRESS ).Set ( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_ANTIALIASING );
105105 options->AddChild ( control );
106106
107+ // RB begin
107108 control = new ( TAG_SWF ) idMenuWidget_ControlButton ();
108109 control->SetOptionType ( OPTION_SLIDER_TEXT );
109110 control->SetLabel ( " Filmic VFX" );
@@ -112,7 +113,6 @@ void idMenuScreen_Shell_SystemOptions::Initialize( idMenuHandler* data )
112113 control->AddEventAction ( WIDGET_EVENT_PRESS ).Set ( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_POSTFX );
113114 options->AddChild ( control );
114115
115- // RB begin
116116 control = new ( TAG_SWF ) idMenuWidget_ControlButton ();
117117 control->SetOptionType ( OPTION_SLIDER_TEXT );
118118 control->SetLabel ( " Soft Shadows" );
@@ -121,13 +121,30 @@ void idMenuScreen_Shell_SystemOptions::Initialize( idMenuHandler* data )
121121 control->AddEventAction ( WIDGET_EVENT_PRESS ).Set ( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_SHADOWMAPPING );
122122 options->AddChild ( control );
123123
124+ control = new ( TAG_SWF ) idMenuWidget_ControlButton ();
125+ control->SetOptionType ( OPTION_SLIDER_TEXT );
126+ control->SetLabel ( " SSAO" );
127+ control->SetDataSource ( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_SSAO );
128+ control->SetupEvents ( DEFAULT_REPEAT_TIME, options->GetChildren ().Num () );
129+ control->AddEventAction ( WIDGET_EVENT_PRESS ).Set ( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_SSAO );
130+ options->AddChild ( control );
131+
124132 /* control = new( TAG_SWF ) idMenuWidget_ControlButton();
125133 control->SetOptionType( OPTION_SLIDER_BAR );
126134 control->SetLabel( "#str_swf_lodbias" );
127135 control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_LODBIAS );
128136 control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
129137 control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_LODBIAS );
130138 options->AddChild( control );*/
139+
140+ control = new ( TAG_SWF ) idMenuWidget_ControlButton ();
141+ control->SetOptionType ( OPTION_SLIDER_BAR );
142+ control->SetLabel ( " Ambient Lighting" );
143+ control->SetDescription ( " Sets the amount of indirect lighting. Needed for modern PBR reflections" );
144+ control->SetDataSource ( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_AMBIENT_BRIGHTNESS );
145+ control->SetupEvents ( 2 , options->GetChildren ().Num () );
146+ control->AddEventAction ( WIDGET_EVENT_PRESS ).Set ( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_SSAO );
147+ options->AddChild ( control );
131148 // RB end
132149
133150 control = new ( TAG_SWF ) idMenuWidget_ControlButton ();
@@ -392,12 +409,14 @@ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData
392409{
393410 originalFramerate = com_engineHz.GetInteger ();
394411 originalAntialias = r_antiAliasing.GetInteger ();
395- originalPostProcessing = r_useFilmicPostProcessing.GetInteger ();
396412 originalVsync = r_swapInterval.GetInteger ();
397413 originalBrightness = r_exposure.GetFloat ();
398414 originalVolume = s_volume_dB.GetFloat ();
399415 // RB begin
400416 originalShadowMapping = r_useShadowMapping.GetInteger ();
417+ originalSSAO = r_useSSAO.GetInteger ();
418+ originalAmbientBrightness = r_forceAmbient.GetFloat ();
419+ originalPostProcessing = r_useFilmicPostProcessing.GetInteger ();
401420 // RB end
402421
403422 const int fullscreen = r_fullscreen.GetInteger ();
@@ -522,15 +541,14 @@ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustFi
522541 r_antiAliasing.SetInteger ( AdjustOption ( r_antiAliasing.GetInteger (), values, numValues, adjustAmount ) );
523542 break ;
524543 }
544+ // RB begin
525545 case SYSTEM_FIELD_POSTFX:
526546 {
527547 static const int numValues = 2 ;
528548 static const int values[numValues] = { 0 , 1 };
529- // static const int values[numValues] = { 0, 2, 3, 4, 5 };
530549 r_useFilmicPostProcessing.SetInteger ( AdjustOption ( r_useFilmicPostProcessing.GetInteger (), values, numValues, adjustAmount ) );
531550 break ;
532551 }
533- // RB begin
534552 case SYSTEM_FIELD_SHADOWMAPPING:
535553 {
536554 static const int numValues = 2 ;
@@ -546,14 +564,30 @@ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustFi
546564 r_lodBias.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, -1.0f, 1.0f ) );
547565 break;
548566 }*/
567+ case SYSTEM_FIELD_SSAO:
568+ {
569+ static const int numValues = 2 ;
570+ static const int values[numValues] = { 0 , 1 };
571+ r_useSSAO.SetInteger ( AdjustOption ( r_useSSAO.GetInteger (), values, numValues, adjustAmount ) );
572+ break ;
573+ }
574+ case SYSTEM_FIELD_AMBIENT_BRIGHTNESS:
575+ {
576+ const float percent = LinearAdjust ( r_forceAmbient.GetFloat (), 0 .0f , 1 .0f , 0 .0f , 100 .0f );
577+ const float adjusted = percent + ( float )adjustAmount;
578+ const float clamped = idMath::ClampFloat ( 0 .0f , 100 .0f , adjusted );
579+
580+ r_forceAmbient.SetFloat ( LinearAdjust ( clamped, 0 .0f , 100 .0f , 0 .0f , 1 .0f ) );
581+ break ;
582+ }
549583 // RB end
550584 case SYSTEM_FIELD_BRIGHTNESS:
551585 {
552586 const float percent = LinearAdjust ( r_exposure.GetFloat (), 0 .0f , 1 .0f , 0 .0f , 100 .0f );
553587 const float adjusted = percent + ( float )adjustAmount;
554588 const float clamped = idMath::ClampFloat ( 0 .0f , 100 .0f , adjusted );
555589
556- r_exposure.SetFloat ( LinearAdjust ( clamped, 0 .0f , 100 .0f , 0 .0f , 1 .0f ) );
590+ r_exposure.SetFloat ( LinearAdjust ( clamped, 0 .0f , 100 .0f , 0 .0f , 1 .0f ) ); // RB
557591 r_lightScale.SetFloat ( LinearAdjust ( clamped, 0 .0f , 100 .0f , 2 .0f , 4 .0f ) );
558592 break ;
559593 }
@@ -599,8 +633,10 @@ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings
599633 return va ( " %4i x %4i @ %dhz" , modeList[vidmode].width , modeList[vidmode].height , modeList[vidmode].displayHz );
600634 }
601635 }
636+
602637 case SYSTEM_FIELD_FRAMERATE:
603638 return va ( " %d FPS" , com_engineHz.GetInteger () );
639+
604640 case SYSTEM_FIELD_VSYNC:
605641 if ( r_swapInterval.GetInteger () == 1 )
606642 {
@@ -614,6 +650,7 @@ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings
614650 {
615651 return " #str_swf_disabled" ;
616652 }
653+
617654 case SYSTEM_FIELD_ANTIALIASING:
618655 {
619656 if ( r_antiAliasing.GetInteger () == 0 )
@@ -646,6 +683,7 @@ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings
646683 }
647684 // return va( "%dx", idMath::IPow( 2, r_motionBlur.GetInteger() ) );
648685 // RB begin
686+
649687 case SYSTEM_FIELD_SHADOWMAPPING:
650688 if ( r_useShadowMapping.GetInteger () == 1 )
651689 {
@@ -655,11 +693,27 @@ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings
655693 {
656694 return " #str_swf_disabled" ;
657695 }
696+
658697 // case SYSTEM_FIELD_LODBIAS:
659698 // return LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f );
699+
700+ case SYSTEM_FIELD_SSAO:
701+ if ( r_useSSAO.GetInteger () == 1 )
702+ {
703+ return " #str_swf_enabled" ;
704+ }
705+ else
706+ {
707+ return " #str_swf_disabled" ;
708+ }
709+
710+ case SYSTEM_FIELD_AMBIENT_BRIGHTNESS:
711+ return LinearAdjust ( r_forceAmbient.GetFloat (), 0 .0f , 1 .0f , 0 .0f , 100 .0f );
660712 // RB end
713+
661714 case SYSTEM_FIELD_BRIGHTNESS:
662715 return LinearAdjust ( r_exposure.GetFloat (), 0 .0f , 1 .0f , 0 .0f , 100 .0f );
716+
663717 case SYSTEM_FIELD_VOLUME:
664718 {
665719 return 100 .0f * Square ( 1 .0f - ( s_volume_dB.GetFloat () / DB_SILENCE ) );
@@ -679,31 +733,167 @@ bool idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsDataCh
679733 {
680734 return true ;
681735 }
736+
682737 if ( originalAntialias != r_antiAliasing.GetInteger () )
683738 {
684739 return true ;
685740 }
741+
742+ if ( originalVsync != r_swapInterval.GetInteger () )
743+ {
744+ return true ;
745+ }
746+
747+ if ( originalShadowMapping != r_useShadowMapping.GetInteger () )
748+ {
749+ return true ;
750+ }
751+
752+ if ( originalSSAO != r_useSSAO.GetInteger () )
753+ {
754+ return true ;
755+ }
756+
686757 if ( originalPostProcessing != r_useFilmicPostProcessing.GetInteger () )
687758 {
688759 return true ;
689760 }
690- if ( originalVsync != r_swapInterval.GetInteger () )
761+
762+ if ( originalAmbientBrightness != r_forceAmbient.GetFloat () )
691763 {
692764 return true ;
693765 }
766+
694767 if ( originalBrightness != r_exposure.GetFloat () )
695768 {
696769 return true ;
697770 }
771+
698772 if ( originalVolume != s_volume_dB.GetFloat () )
699773 {
700774 return true ;
701775 }
702- // RB begin
703- if ( originalShadowMapping != r_useShadowMapping.GetInteger () )
776+
777+ return false ;
778+ }
779+
780+ // RB begin
781+ void idMenuWidget_SystemOptionsList::Update ()
782+ {
783+ if ( GetSWFObject () == NULL )
704784 {
705- return true ;
785+ return ;
706786 }
707- // RB end
708- return false ;
787+
788+ idSWFScriptObject& root = GetSWFObject ()->GetRootObject ();
789+
790+ if ( !BindSprite ( root ) )
791+ {
792+ return ;
793+ }
794+
795+ // idLib::Printf( "SystemOptionsList::Update( offset = %i )\n", GetViewOffset() );
796+
797+ // clear old sprites and rebuild the options
798+ for ( int childIndex = 0 ; childIndex < GetTotalNumberOfOptions (); ++childIndex )
799+ {
800+ idMenuWidget& child = GetChildByIndex ( childIndex );
801+
802+ child.ClearSprite ();
803+ }
804+
805+ for ( int optionIndex = 0 ; optionIndex < GetNumVisibleOptions (); ++optionIndex )
806+ {
807+ if ( optionIndex >= children.Num () )
808+ {
809+ // not enough children
810+ idSWFSpriteInstance* item = GetSprite ()->GetScriptObject ()->GetNestedSprite ( va ( " item%d" , optionIndex ) );
811+ if ( item != NULL )
812+ {
813+ item->SetVisible ( false );
814+ continue ;
815+ }
816+ }
817+
818+ // account view offset and total number of options
819+ const int childIndex = ( GetViewOffset () + optionIndex ) % GetTotalNumberOfOptions ();
820+ idMenuWidget& child = GetChildByIndex ( childIndex );
821+
822+ child.SetSpritePath ( GetSpritePath (), va ( " item%d" , optionIndex ) );
823+ if ( child.BindSprite ( root ) )
824+ {
825+ if ( optionIndex >= GetTotalNumberOfOptions () )
826+ {
827+ child.ClearSprite ();
828+ continue ;
829+ }
830+
831+ child.Update ();
832+
833+ if ( optionIndex == focusIndex )
834+ {
835+ child.SetState ( WIDGET_STATE_SELECTING );
836+ }
837+ else
838+ {
839+ child.SetState ( WIDGET_STATE_NORMAL );
840+ }
841+ }
842+ }
843+
844+ idSWFSpriteInstance* const upSprite = GetSprite ()->GetScriptObject ()->GetSprite ( " upIndicator" );
845+ if ( upSprite != NULL )
846+ {
847+ upSprite->SetVisible ( GetViewOffset () > 0 );
848+ }
849+
850+ idSWFSpriteInstance* const downSprite = GetSprite ()->GetScriptObject ()->GetSprite ( " downIndicator" );
851+ if ( downSprite != NULL )
852+ {
853+ downSprite->SetVisible ( GetViewOffset () + GetNumVisibleOptions () < GetTotalNumberOfOptions () );
854+ }
855+ }
856+
857+ void idMenuWidget_SystemOptionsList::Scroll ( const int scrollAmount, const bool wrapAround )
858+ {
859+ if ( GetTotalNumberOfOptions () == 0 )
860+ {
861+ return ;
862+ }
863+
864+ int newIndex, newOffset;
865+
866+ // RB: always wrap around
867+ CalculatePositionFromIndexDelta ( newIndex, newOffset, GetViewIndex (), GetViewOffset (), GetNumVisibleOptions (), GetTotalNumberOfOptions (), scrollAmount, IsWrappingAllowed (), true ); // wrapAround );
868+
869+ // int oldViewIndex = GetViewIndex();
870+ // int oldViewOffset = GetViewOffset();
871+ int oldFocusIndex = GetFocusIndex ();
872+
873+ if ( newOffset != GetViewOffset () )
874+ {
875+ SetViewOffset ( newOffset );
876+ if ( menuData != NULL )
877+ {
878+ menuData->PlaySound ( GUI_SOUND_FOCUS );
879+ }
880+
881+ // RB: HACK and I don't like it.
882+ // focusIndex is used here for the visible state and not for event handling.
883+ focusIndex = newIndex;
884+ Update ();
885+ focusIndex = oldFocusIndex;
886+ }
887+
888+ if ( newIndex != GetViewIndex () )
889+ {
890+ SetViewIndex ( newIndex );
891+
892+ // trigger focus/unfocus sprite actions
893+ SetFocusIndex ( newIndex );// - newOffset );
894+ }
895+
896+ // idLib::Printf( "scroll = %i, index = %i -> %i, offset = %i -> %i, focus = %i -> %i\n", scrollAmount, oldViewIndex, newIndex, oldViewOffset, newOffset, oldFocusIndex, GetFocusIndex() );
709897}
898+ // RB end
899+
0 commit comments