## XIDInterf
Class XIIIMenuDifficultyWindow

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

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

Direct Known Subclasses:None

class XIIIMenuDifficultyWindow
extends XIDInterf.XIIIWindow

Variables
`MediumButton,` | `HardButton`
`MediumText,` | `HardText`
`YOrg,` | `LineSpace`
`tBackGround[4],` | `tHighLight`

Function Summary
`void` | `Created()`
    //VAR XIIILabel TitleLabel;
`bool` | `InternalOnKeyEvent(out byte, out byte, float delta)`
`void` | `Paint(Canvas C, float X, float Y)`
`void` | `ShowWindow()`

Source Code

    00001
    00002	class XIIIMenuDifficultyWindow extends XIIIWindow;
    00003
    00004	VAR XIIIButton EasyButton, MediumButton, HardButton;
    00005	VAR localized string TitleText, EasyText, MediumText, HardText;
    00006	VAR texture tBackGround[4], tHighLight;
    00007	VAR int YOrg, LineSpace;
    00008
    00009	//VAR XIIILabel TitleLabel;
    00010
    00011	function Created()
    00012	{
    00013	    local int CtrlIndex;
    00014
    00015	    Super.Created();
    00016
    00017		CONST nbItems=3;
    00018		LineSpace=29+(370-(nbItems*29))/(nbItems+1);
    00019		YOrg=27+LineSpace;
    00020
    00021		EasyButton = XIIIbutton(CreateControl(class'XIIIbutton', 308, YOrg*fScaleTo, 270, 29*fScaleTo));
    00022	    EasyButton.Text=EasyText;
    00023		Controls[CtrlIndex] = EasyButton;
    00024		CtrlIndex++;
    00025
    00026		MediumButton = XIIIbutton(CreateControl(class'XIIIbutton', 308, (YOrg+LineSpace)*fScaleTo, 270, 29*fScaleTo));
    00027	    MediumButton.Text=MediumText;
    00028		Controls[CtrlIndex] = MediumButton;
    00029		CtrlIndex++;
    00030
    00031		HardButton = XIIIbutton(CreateControl(class'XIIIbutton', 308, (YOrg+LineSpace*2)*fScaleTo, 270, 29*fScaleTo));
    00032	    HardButton.Text=HardText;
    00033		Controls[CtrlIndex] = HardButton;
    00034		CtrlIndex++;
    00035	}
    00036
    00037
    00038	function Paint(Canvas C, float X, float Y)
    00039	{
    00040		LOCAL float W, H;
    00041
    00042		SUPER.Paint(C, X, Y);
    00043
    00044		CONST ImageW=350;
    00045		CONST ImageH=370;
    00046
    00047		DrawStretchedTexture(C, (610-ImageW-2)*fRatioX, ( 425 - ImageH - 2 )*fScaleTo*fRatioY, (ImageW+4)*fRatioX, (ImageH+4)*fRatioY*fScaleTo, myRoot.tFondNoir);
    00048
    00049		DrawStretchedTexture(C, (610-ImageW)*fRatioX, ( 425 - ImageH )*fScaleTo*fRatioY, ImageW*fRatioX, 370*fScaleTo*fRatioY, tBackGround[0]);
    00050
    00051		OnMenu = FindComponentIndex(FocusedControl);
    00052		C.Style = 5;
    00053		C.DrawColor.A = 180;
    00054		DrawStretchedTexture(C, (610-ImageW)*fRatioX, ((Yorg-5+OnMenu*LineSpace)*fScaleTo)*fRatioY, ImageW*fRatioX, 40*fRatioY, tHighlight);
    00055		C.DrawColor.A = 255;
    00056
    00057		DrawStretchedTexture(C, (610-ImageW-116)*fRatioX, ( 438 - 186 )*fScaleTo*fRatioY, 186*fRatioX, 186*fScaleTo*fRatioY, tBackGround[2]);
    00058		DrawStretchedTexture(C, (610-ImageW-116)*fRatioX, ( 438 - 186 - 186 )*fScaleTo*fRatioY, 186*fRatioX, 186*fScaleTo*fRatioY, tBackGround[1]);
    00059		DrawStretchedTexture(C, (610-186-ImageW-116)*fRatioX, ( 438 - 93 )*fScaleTo*fRatioY, 186*fRatioX, 93*fScaleTo*fRatioY, tBackGround[3]);
    00060		C.Style = 1;
    00061
    00062		C.bUseBorder = true;
    00063		DrawStretchedTexture(C, 150*fRatioX, 30*fRatioY, 170*fRatioX, 35*fRatioY, myRoot.FondMenu);
    00064		C.TextSize(TitleText, W, H);
    00065		C.DrawColor = BlackColor;
    00066		C.SetPos((150 + (160-W)/2)*fRatioX, (47.5-H/2)*fRatioY);
    00067		C.DrawText(TitleText, false);
    00068		C.bUseBorder = false;
    00069		C.DrawColor = WhiteColor;
    00070	}
    00071
    00072
    00073	function ShowWindow()
    00074	{
    00075		local string strLevel;
    00076		local int Level;
    00077
    00078		log("SHOWWINDOW DIFF");
    00079		strLevel = GetPlayerOwner().ConsoleCommand("Get GameInfo Difficulty");
    00080		Level = int( strLevel );
    00081
    00082		myRoot.bFired = false;
    00083
    00084		switch(Level)
    00085		{
    00086		case 0:
    00087			OnMenu = 0;
    00088			MediumButton.MouseLeave(); HardButton.MouseLeave();
    00089			EasyButton.MouseEnter(); SetFocus(EasyButton);
    00090			break;
    00091		case 1:
    00092			OnMenu = 1;
    00093			EasyButton.MouseLeave(); HardButton.MouseLeave();
    00094			MediumButton.MouseEnter(); SetFocus(MediumButton);
    00095			break;
    00096		case 2:
    00097			OnMenu = 2;
    00098			EasyButton.MouseLeave(); MediumButton.MouseLeave();
    00099			HardButton.MouseEnter(); SetFocus(HardButton);
    00100			break;
    00101		}
    00102
    00103		Super.ShowWindow();
    00104		bShowCCL = true;
    00105		bShowSEL = true;
    00106	}
    00107
    00108
    00109	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
    00110	{
    00111		if (State==1)// IST_Press // to avoid auto-repeat
    00112		{
    00113			if (Key==0x0D/*IK_Enter*/||Key==0x01)
    00114			{
    00115				Controller.FocusedControl.OnClick(Self);
    00116				switch( FocusedControl )
    00117				{
    00118				case EasyButton:
    00119					GetPlayerOwner().ConsoleCommand("set GameInfo Difficulty 0");
    00120					break;
    00121				case MediumButton: GetPlayerOwner().ConsoleCommand("set GameInfo Difficulty 1");
    00122					break;
    00123				case HardButton: GetPlayerOwner().ConsoleCommand("set GameInfo Difficulty 2");
    00124					break;
    00125				}
    00126	//			SaveConfigs();
    00127				myRoot.CloseMenu(false);
    00128				return true;
    00129			}
    00130			if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B))
    00131			{
    00132				myRoot.CloseMenu(true);
    00133				return true;
    00134			}
    00135			if (Key==0x26/*IK_Up*/)
    00136			{
    00137				PrevControl(FocusedControl);
    00138				OnMenu = FindComponentIndex(FocusedControl);
    00139				return true;
    00140			}
    00141			if (Key==0x28/*IK_Down*/)
    00142			{
    00143				NextControl(FocusedControl);
    00144				OnMenu = FindComponentIndex(FocusedControl);
    00145				return true;
    00146			}
    00147	/*		if (Key==0x01)
    00148			{
    00149				OnMenu = FindComponentIndex(FocusedControl);
    00150				return true;
    00151			}*/
    00152			//return false;
    00153		}
    00154		return super.InternalOnKeyEvent(Key, state, delta);
    00155	}
    00156
    00157
    00158
    00159
    00160	defaultproperties
    00161	{
    00162	     TitleText="Difficulty"
    00163	     EasyText="Arcade"
    00164	     MediumText="Normal"
    00165	     HardText="Realistic"
    00166	     VeryHardText="XXX"
    00167	     tBackGround(0)=Texture'XIIIMenuStart.interface_options.difficultydecor2'
    00168	     tBackGround(1)=Texture'XIIIMenuStart.Difficulty.difficultyjones01A'
    00169	     tBackGround(2)=Texture'XIIIMenuStart.Difficulty.difficultyjones02A'
    00170	     tBackGround(3)=Texture'XIIIMenuStart.Difficulty.difficultyjones03A'
    00171	     tHighlight=Texture'XIIIMenuStart.Control_Console_advanced.barreselectmenuoptadv'
    00172	}

End Source Code