## XIDInterf
Class XIIIMenuInGameControlsWindow

source: C:\XIII\XIDInterf\Classes\XIIIMenuInGameControlsWindow.uc

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent
             |
             +--GUI.GUIMultiComponent
                |
                +--GUI.GUIPage
                   |
                   +--XIDInterf.XIIIWindow
                      |
                      +--XIDInterf.XIIIMenuInGameControlsWindow

Direct Known Subclasses:None

class XIIIMenuInGameControlsWindow
extends XIDInterf.XIIIWindow

Variables
`float` | `ControlOffset`
`XIIILabel` | `InfoLabel`
`AutoAimButton,` | `InvPadButton`
`int` | `LSpeed`
`int` | `LocalPadConfig`
`XIIIHSliderControl` | `LookSpeedSlider`
`int` | `NbPadConfig`
`XIIIComboControl` | `PadConfigButton`
`SaveQuestionText,` | `SaveQuestionTitle`
`bMemoAutoAim,` | `bMemoInvPad`
`float` | `memoLookSpeed`
`int` | `memoPadConfig`
`sYes,` | `sNo`

Function Summary
`void` | `AutoAimChanged()`
    //_____________________________________________________________________________
`void` | `Created()`
    //_____________________________________________________________________________
`bool` | `HadPadConfigChanged()`
`void` | `InitValues()`
    //_____________________________________________________________________________
`bool` | `InternalOnKeyEvent(out byte, out byte, float delta)`
    //_____________________________________________________________________________
`void` | `InvPadChanged()`
    //_____________________________________________________________________________
`void` | `LookSpeedChanged()`
    //_____________________________________________________________________________
`void` | `PadConfigChanged()`
    //_____________________________________________________________________________
`void` | `Paint(Canvas C, float X, float Y)`
    //_____________________________________________________________________________
`void` | `RestoreConfig( )`
`void` | `RumbleChanged()`
    /*
`void` | `SaveMsgBoxReturn(byte bButton)`
`void` | `SavePadConfig()`
`void` | `ShowWindow()`
    //_____________________________________________________________________________

Source Code

    00001	class XIIIMenuInGameControlsWindow extends XIIIWindow;
    00002
    00003	var XIIIComboControl PadConfigButton;
    00004	var XIIIHSliderControl LookSpeedSlider;
    00005	var XIIIComboControl RumbleButton, AutoAimButton, InvPadButton;
    00006
    00007	var localized string RumbleText, AutoAimText, LSpeedText, InvPadText, PadConfigXBoxText[4],  SaveQuestionText, SaveQuestionTitle;
    00008
    00009	var int NbPadConfig;
    00010
    00011	var int LocalPadConfig;
    00012
    00013	var localized string sYes, sNo;
    00014
    00015	var float ControlOffset;
    00016	var int LSpeed;
    00017
    00018	var XIIILabel InfoLabel;
    00019	VAR bool bMemoUseRumble, bMemoAutoAim, bMemoInvPad;
    00020	VAR int memoPadConfig;
    00021	VAR float memoLookSpeed;
    00022
    00023	FUNCTION SavePadConfig()
    00024	{
    00025		bMemoUseRumble = GetPlayerOwner().bUseRumble;
    00026		memoLookSpeed=GetPlayerOwner().fLookSpeed;
    00027			bMemoAutoAim = bool(GetPlayerOwner().iAutoAimMode);
    00028		bMemoInvPad = GetPlayerOwner().bInverseLook;
    00029		memoPadConfig = Clamp(GetPlayerOwner().UserPadConfig,0,NbPadConfig - 1);
    00030	}
    00031
    00032	FUNCTION bool HadPadConfigChanged()
    00033	{
    00034		return
    00035			(
    00036				( memoPadConfig != PadConfigButton.GetSelectedIndex( ) )
    00037			||	( memoLookSpeed != 0.7f + LookSpeedSlider.GetValue()*0.1f )
    00038			||	( bMemoUseRumble != bool(1-RumbleButton.GetSelectedIndex( ) ) )
    00039			||	( bMemoInvPad != bool(1-InvPadButton.GetSelectedIndex( ) ) )
    00040			||	( bMemoAutoAim != bool(1-AutoAimButton.GetSelectedIndex( ) ) )
    00041			);
    00042	}
    00043
    00044	//_____________________________________________________________________________
    00045	function Created()
    00046	{
    00047	    local int i;
    00048
    00049	    Super.Created();
    00050
    00051		SavePadConfig();
    00052
    00053	    ControlOffset += 125;
    00054	    PadConfigButton = XIIIComboControl(CreateControl(class'XIIIComboControl', 210, (ControlOffset - 4)*fScaleTo, 240, 40*fScaleTo));
    00055		PadConfigButton.bArrows = true;
    00056		for (i=0;i<NbPadConfig;i++)
    00057			PadConfigButton.AddItem(PadConfigXBoxText[i]);
    00058		PadConfigButton.bShowBordersOnlyWhenFocused=true;
    00059
    00060	    ControlOffset += 40;
    00061		RumbleButton = XIIIComboControl(CreateControl(class'XIIIComboControl',210,ControlOffset*fScaleTo,240,29*fScaleTo));
    00062		RumbleButton.Text = RumbleText;
    00063		RumbleButton.bArrows = true;
    00064		RumbleButton.bCalculateSize = false;
    00065		RumbleButton.FirstBoxWidth = 180;
    00066		RumbleButton.AddItem(sYes);
    00067		RumbleButton.AddItem(sNo);
    00068		RumbleButton.SetSelectedIndex( int(!bMemoUseRumble) );
    00069		RumbleButton.bShowBordersOnlyWhenFocused=true;
    00070
    00071	    ControlOffset += 40;
    00072		AutoAimButton = XIIIComboControl(CreateControl(class'XIIIComboControl',210,ControlOffset*fScaleTo,240,29*fScaleTo));
    00073		AutoAimButton.Text = AutoAimText;
    00074		AutoAimButton.bArrows = true;
    00075		AutoAimButton.bCalculateSize = false;
    00076		AutoAimButton.FirstBoxWidth = 180;
    00077		AutoAimButton.AddItem(sYes);
    00078		AutoAimButton.AddItem(sNo);
    00079		AutoAimButton.SetSelectedIndex( int(!bMemoAutoAim) );
    00080		AutoAimButton.bShowBordersOnlyWhenFocused=true;
    00081
    00082	    ControlOffset += 40;
    00083		InvPadButton = XIIIComboControl(CreateControl(class'XIIIComboControl',210,ControlOffset*fScaleTo,240,29*fScaleTo));
    00084		InvPadButton.Text = InvPadText;
    00085		InvPadButton.bArrows = true;
    00086		InvPadButton.bCalculateSize = false;
    00087		InvPadButton.FirstBoxWidth = 180;
    00088		InvPadButton.AddItem(sYes);
    00089		InvPadButton.AddItem(sNo);
    00090		InvPadButton.SetSelectedIndex( int(!bMemoInvPad) );
    00091		InvPadButton.bShowBordersOnlyWhenFocused=true;
    00092
    00093	    // Create Look speed slider
    00094	    ControlOffset += 40;
    00095	    LookSpeedSlider = XIIIHSliderControl(CreateControl(class'XIIIHSliderControl', 210, ControlOffset*fScaleTo, 240, 29*fScaleTo));
    00096	    LookSpeedSlider.SetRange(0, 10, 1, 150);
    00097	    LookSpeedSlider.Text = LSpeedText;
    00098		LookSpeedSlider.bShowBordersOnlyWhenFocused=true;
    00099
    00100	    Controls[0] = PadConfigButton;
    00101	    Controls[1] = RumbleButton;
    00102	    Controls[2] = AutoAimButton;
    00103	    Controls[3] = InvPadButton;
    00104	    Controls[4] = LookSpeedSlider;
    00105
    00106		LocalPadConfig = memoPadConfig;
    00107
    00108		PadConfigButton.SetSelectedIndex(LocalPadConfig);
    00109	}
    00110
    00111	//_____________________________________________________________________________
    00112	function ShowWindow()
    00113	{
    00114	    InitValues();
    00115
    00116	    Super.ShowWindow();
    00117
    00118	    bShowCCL = true;
    00119		bShowACC = true;
    00120	}
    00121
    00122
    00123	//_____________________________________________________________________________
    00124	function InitValues()
    00125	{
    00126	    local int i;
    00127
    00128	    LSpeed = int( ( ( memoLookSpeed-0.7 ) * 10.0 ) + 0.1 ); // FUCK the innacurate floats
    00129
    00130	    LookSpeedSlider.SetValue(LSpeed);
    00131	}
    00132
    00133
    00134	//_____________________________________________________________________________
    00135	function Paint(Canvas C, float X, float Y)
    00136	{
    00137	    local string sVersion;
    00138	    local int i;
    00139	    local float fScale, W, H;
    00140
    00141	    Super.Paint(C,X,Y);
    00142
    00143	    // background
    00144	    if (myRoot.GetLevel().bCineFrame)
    00145		{
    00146		    C.Style = 5;
    00147			C.DrawColor = BlackColor;
    00148			C.DrawColor.A = 192;
    00149		    DrawStretchedTexture(C, 0, 0, WinWidth*C.ClipX, WinHeight*C.ClipY, myRoot.FondMenu);
    00150			C.Style = 1;
    00151		}
    00152		C.DrawMsgboxBackground(false, 190*fRatioX, 130*fRatioY*fScaleTo, 10, 10, 280*fRatioX, 230*fRatioY*fScaleTo);
    00153
    00154		// restore old param
    00155		C.DrawColor = WhiteColor;
    00156	    C.DrawColor.A = 255;
    00157		C.Style = 1;
    00158		C.bUseBorder = false;
    00159
    00160	}
    00161
    00162	function SaveMsgBoxReturn(byte bButton)
    00163	{
    00164		if ( (bButton & QBTN_Yes) != 0)
    00165		{
    00166			GetPlayerOwner().UserPadConfig = LocalPadConfig;
    00167			PadConfigChanged();
    00168			LookSpeedChanged();
    00169	//		RumbleChanged();
    00170			GetPlayerOwner().bUseRumble= !bool(RumbleButton.GetSelectedIndex());
    00171			AutoAimChanged();
    00172			InvPadChanged();
    00173
    00174			SaveConfigs();
    00175		}
    00176		else
    00177		{
    00178			RestoreConfig( );
    00179			myRoot.CloseMenu( true );
    00180		}
    00181	}
    00182
    00183	function RestoreConfig( )
    00184	{
    00185		if ( bMemoUseRumble )
    00186		{
    00187			if ( !GetPlayerOwner().bUseRumble )
    00188			{
    00189				XIIIPlayerController( GetPlayerOwner( ) ).SetRumbleFX( true );
    00190				GetPlayerOwner().bUseRumble = true;
    00191				XIIIPlayerController(GetPlayerOwner()).RumbleFX(13);
    00192			}
    00193		}
    00194		else
    00195		{
    00196			if ( GetPlayerOwner().bUseRumble )
    00197			{
    00198				XIIIPlayerController( GetPlayerOwner( ) ).SetRumbleFX( false );
    00199				GetPlayerOwner().bUseRumble = false;
    00200			}
    00201		}
    00202	}
    00203	//_____________________________________________________________________________
    00204	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
    00205	{
    00206		LOCAL XIIIMsgBox MsgBox;
    00207	    local int i;
    00208
    00209		if ((State==1) || (State==2))// IST_Press // to avoid auto-repeat
    00210	    {
    00211	        if (Key==0x0D/*IK_Enter*/)
    00212		    {
    00213				if ( HadPadConfigChanged() )
    00214				{
    00215					myRoot.OpenMenu("XIDInterf.XIIIMsgBox");
    00216					MsgBox = XIIIMsgBox(myRoot.ActivePage);
    00217					MsgBox.InitBox(190*fRatioX, 130*fRatioY*fScaleTo, 10, 10, 280*fRatioX, 230*fRatioY*fScaleTo);
    00218					MsgBox.SetupQuestion( SaveQuestionText, QBTN_Yes | QBTN_No, QBTN_Yes, SaveQuestionTitle);
    00219					MsgBox.OnButtonClick = SaveMsgBoxReturn;
    00220				}
    00221				else
    00222					myRoot.CloseMenu( true );
    00223	            return true;
    00224		    }
    00225		    if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B))
    00226		    {
    00227				RestoreConfig( );
    00228		        myRoot.CloseMenu(true);
    00229	    	    return true;
    00230		    }
    00231		    if (Key==0x26/*IK_Up*/)
    00232		    {
    00233		        PrevControl(FocusedControl);
    00234	    	    return true;
    00235		    }
    00236		    if (Key==0x28/*IK_Down*/)
    00237		    {
    00238		        NextControl(FocusedControl);
    00239	    	    return true;
    00240		    }
    00241		    if ((Key==0x25/*IK_Left*/) || (Key==0x27/*IK_Right*/))
    00242		    {
    00243	            if (FocusedControl == Controls[0])
    00244		        {
    00245
if (Key==0x25) LocalPadConfig--; 00246 if (Key==0x27) LocalPadConfig++; 00247 LocalPadConfig = Clamp(LocalPadConfig,0,NbPadConfig - 1); 00248 00249 PadConfigButton.SetSelectedIndex(LocalPadConfig); 00250 } 00251 else if (FocusedControl == Controls[1]) 00252 { 00253 if (Key==0x25) 00254 { 00255 if ( RumbleButton.GetSelectedIndex()!=0 ) 00256 { 00257 RumbleButton.SetSelectedIndex( 0 ); 00258 XIIIPlayerController( GetPlayerOwner( ) ).SetRumbleFX( true ); 00259 GetPlayerOwner().bUseRumble = true; 00260 XIIIPlayerController(GetPlayerOwner()).RumbleFX(13); 00261 } 00262 } 00263 else if (Key==0x27) 00264 { 00265 if ( RumbleButton.GetSelectedIndex()!=1 ) 00266 { 00267 RumbleButton.SetSelectedIndex( 1 ); 00268 XIIIPlayerController( GetPlayerOwner( ) ).SetRumbleFX( false ); 00269 GetPlayerOwner().bUseRumble = false; 00270 } 00271 } 00272 } 00273 else if (FocusedControl == Controls[2]) 00274 { 00275 if (Key==0x27) AutoAimButton.SetSelectedIndex(1); 00276 else if (Key==0x25) AutoAimButton.SetSelectedIndex(0); 00277 } 00278 else if (FocusedControl == Controls[3]) 00279 { 00280 if (Key==0x27) InvPadButton.SetSelectedIndex(1); 00281 else if (Key==0x25) InvPadButton.SetSelectedIndex(0); 00282 } 00283 return true; 00284 } 00285 00286 } 00287 return super.InternalOnKeyEvent(Key, state, delta); 00288 } 00289 00290 //_____________________________________________________________________________ 00291 function PadConfigChanged() 00292 { 00293 00294 switch ( LocalPadConfig ) 00295 { 00296 case 0: 00297 // specific inputs for classic halo 00298 GetPlayerOwner().ConsoleCommand("SET XIIIPlayerController ConfigType CT_StrafeLookNotSameAxis"); 00299 GetPlayerOwner().ConsoleCommand("SET Input Joy1 Jump"); 00300 GetPlayerOwner().ConsoleCommand("SET Input Joy3 Grab"); 00301 GetPlayerOwner().ConsoleCommand("SET Input Joy4 PrevWeapon"); 00302 GetPlayerOwner().ConsoleCommand("SET Input Joy7 AltFire | onrelease UnFire"); 00303 GetPlayerOwner().ConsoleCommand("SET Input JoyX Axis aStrafe SpeedBase=1.0 DeadZone=0.4"); 00304 GetPlayerOwner().ConsoleCommand("SET Input JoyU Axis aTurn SpeedBase=1.0 DeadZone=0.4"); 00305 break; 00306 case 1: 00307 // specific inputs for goofy halo 00308 GetPlayerOwner().ConsoleCommand("SET XIIIPlayerController ConfigType CT_StrafeLookSameAxis"); 00309 GetPlayerOwner().ConsoleCommand("SET Input Joy1 Jump"); 00310 GetPlayerOwner().ConsoleCommand("SET Input Joy3 Grab"); 00311 GetPlayerOwner().ConsoleCommand("SET Input Joy4 PrevWeapon"); 00312 GetPlayerOwner().ConsoleCommand("SET Input Joy7 AltFire | onrelease UnFire"); 00313 GetPlayerOwner().ConsoleCommand("SET Input JoyX Axis aTurn SpeedBase=1.0 DeadZone=0.4"); 00314 GetPlayerOwner().ConsoleCommand("SET Input JoyU Axis aStrafe SpeedBase=1.0 DeadZone=0.4"); 00315 break; 00316 case 2: 00317 // specific inputs for classic XIII 00318 GetPlayerOwner().ConsoleCommand("SET XIIIPlayerController ConfigType CT_StrafeLookNotSameAxis"); 00319 GetPlayerOwner().ConsoleCommand("SET Input Joy1 Grab"); 00320 GetPlayerOwner().ConsoleCommand("SET Input Joy3 PrevWeapon"); 00321 GetPlayerOwner().ConsoleCommand("SET Input Joy4 AltFire | onrelease UnFire"); 00322 GetPlayerOwner().ConsoleCommand("SET Input Joy7 Jump"); 00323 GetPlayerOwner().ConsoleCommand("SET Input JoyX Axis aStrafe SpeedBase=1.0 DeadZone=0.4"); 00324 GetPlayerOwner().ConsoleCommand("SET Input JoyU Axis aTurn SpeedBase=1.0 DeadZone=0.4"); 00325 break; 00326 case 3: 00327 // specific inputs for goofy XIII 00328 GetPlayerOwner().ConsoleCommand("SET XIIIPlayerController ConfigType CT_StrafeLookSameAxis"); 00329 GetPlayerOwner().ConsoleCommand("SET Input Joy1 Grab"); 00330 GetPlayerOwner().ConsoleCommand("SET Input Joy3 PrevWeapon"); 00331 GetPlayerOwner().ConsoleCommand("SET Input Joy4 AltFire | onrelease UnFire"); 00332 GetPlayerOwner().ConsoleCommand("SET Input Joy7 Jump"); 00333 GetPlayerOwner().ConsoleCommand("SET Input JoyX Axis aTurn SpeedBase=1.0 DeadZone=0.4"); 00334 GetPlayerOwner().ConsoleCommand("SET Input JoyU Axis aStrafe SpeedBase=1.0 DeadZone=0.4"); 00335 break; 00336 } 00337 00338 GetPlayerOwner().OptimizeInputBindings(); 00339 } 00340 00341 00342 //_____________________________________________________________________________ 00343 /* 00344 function RumbleChanged() 00345 { 00346 GetPlayerOwner().bUseRumble = bool(RumbleButton.GetSelectedIndex()); 00347 XIIIPlayerController(GetPlayerOwner()).SetRumbleFX( GetPlayerOwner().bUseRumble ); 00348 XIIIPlayerController(GetPlayerOwner()).RumbleFX(15); 00349 } 00350 */ 00351 00352 //_____________________________________________________________________________ 00353 function LookSpeedChanged() 00354 { 00355 local float f; 00356 00357 LSpeed = LookSpeedSlider.GetValue(); 00358 f = 0.7+float(LSpeed)/10.0; 00359 00360 GetPlayerOwner().fLookSpeed = f; 00361 } 00362 00363 00364 //_____________________________________________________________________________ 00365 function InvPadChanged() 00366 { 00367 GetPlayerOwner().bInverseLook = !bool(InvPadButton.GetSelectedIndex()); 00368 } 00369 00370 //_____________________________________________________________________________ 00371 function AutoAimChanged() 00372 { 00373 GetPlayerOwner().iAutoAimMode = 1-AutoAimButton.GetSelectedIndex(); 00374 } 00375 00376 00377

End Source Code