XIDInterf
Class XIIIMenuYesNoWindow

source: C:\XIII\XIDInterf\Classes\XIIIMenuYesNoWindow.uc
Core.Object
   |
   +--GUI.GUI
      |
      +--GUI.GUIComponent
         |
         +--GUI.GUIMultiComponent
            |
            +--GUI.GUIPage
               |
               +--XIDInterf.XIIIWindow
                  |
                  +--XIDInterf.XIIIMenuYesNoWindow
Direct Known Subclasses:None

class XIIIMenuYesNoWindow
extends XIDInterf.XIIIWindow


Variables
 RestartText, AreUText
 BackgroundWidth, BackgroundHeight
 SecondBoxPosX, BoxPosY
 YesButton, NoButton
 TextPosX, TextPosY
 bQuitGame, bAreUSure


Function Summary
 void Created()
 bool InternalOnKeyEvent(out byte, out byte, float delta)
 void Paint(Canvas C, float X, float Y)
 void ShowWindow()



Source Code


00001	class XIIIMenuYesNoWindow extends XIIIWindow;
00002	
00003	var  XIIIButton    YesButton, NoButton;
00004	var  localized string    YesText, NoText, QuitText, RestartText, AreUText;
00005	var bool bQuitGame, bAreUSure;
00006	var int BoxWidth, BoxHeight, FirstBoxPosX, SecondBoxPosX, BoxPosY;
00007	var int BackgroundPosX, BackgroundPosY, BackgroundWidth, BackgroundHeight;
00008	var int TextPosX, TextPosY;
00009	
00010	function Created()
00011	{
00012	     Super.Created();
00013	
00014		// init values
00015		BoxWidth = 70;
00016		BoxHeight = 30;
00017		FirstBoxPosX = 250;
00018		SecondBoxPosX = 340;
00019		BoxPosY = 260;
00020		BackgroundPosX = 220;
00021		BackgroundPosY = 130;
00022		BackgroundWidth = 220;
00023		BackgroundHeight = 230;
00024		TextPosX = 220;
00025		TextPosY = 200;
00026	
00027		// values update if we are in split screen mode
00028		if (( !GetPlayerOwner().Level.bLonePlayer ) && ( GetPlayerOwner().Level.Game.NumPlayers > 1 ))
00029		{
00030			BoxHeight *= 2;
00031			BackgroundPosY -= 70;
00032			BackgroundHeight = 345;
00033			TextPosY -= 40;
00034			if ( GetPlayerOwner().Level.Game.NumPlayers > 2 )
00035			{
00036				FirstBoxPosX -= 90;
00037				BoxWidth *= 2;
00038				BackgroundWidth *= 2;
00039				BackgroundPosX -= 120;
00040	
00041			}
00042		}
00043	
00044		YesButton = XIIIButton(CreateControl(class'XIIIButton', FirstBoxPosX, BoxPosY*fScaleTo, BoxWidth, BoxHeight));
00045		YesButton.NbMultiSplit = GetPlayerOwner().Level.Game.NumPlayers;
00046		YesButton.Text = YesText;
00047		YesButton.bUseBorder = true;
00048	
00049		NoButton = XIIIButton(CreateControl(class'XIIIButton', SecondBoxPosX, BoxPosY*fScaleTo, BoxWidth, BoxHeight));
00050		NoButton.NbMultiSplit = GetPlayerOwner().Level.Game.NumPlayers;
00051		NoButton.Text = NoText;
00052		NoButton.bUseBorder = true;
00053	
00054	    Controls[0] = YesButton;
00055		Controls[1] = NoButton;
00056	}
00057	
00058	
00059	function ShowWindow()
00060	{
00061	    super.ShowWindow();
00062	    NoButton.SetFocus(none);
00063	    bShowCCL = true;
00064	    bShowACC = true;
00065	}
00066	
00067	function Paint(Canvas C, float X, float Y)
00068	{
00069	    local int i;
00070	    local float W, H;
00071	
00072	    if (YesButton.bHasFocus)
00073		{
00074	        YesButton.TextColor = BlackColor;
00075			YesButton.bUseBorder = true;
00076	        NoButton.TextColor = Grey3Color;
00077			NoButton.bUseBorder = false;
00078	    }
00079	    else
00080		{
00081	        YesButton.TextColor = Grey3Color;
00082			YesButton.bUseBorder = false;
00083	        NoButton.TextColor = BlackColor;
00084			NoButton.bUseBorder = true;
00085	    }
00086	
00087	    Super.Paint(C,X,Y);
00088	
00089	    C.bUseBorder = true;
00090		C.DrawColor = WhiteColor;
00091	
00092	    DrawStretchedTexture(C, BackgroundPosX*fRatioX, BackgroundPosY*fRatioY*fScaleTo, BackgroundWidth*fRatioX, BackgroundHeight*fRatioY*fScaleTo, myRoot.FondMenu);
00093	    C.bUseBorder = false;
00094	    C.DrawColor = BlackColor;
00095	    if (bQuitGame)
00096			C.TextSize(/*Caps*/(QuitText), W, H);
00097	    else
00098			if (!bAreUSure)
00099				C.TextSize(/*Caps*/(RestartText), W, H);
00100			else
00101				C.TextSize(/*Caps*/(AreUText), W, H);
00102	
00103		C.SetPos(TextPosX*fRatioX + (220*fScaleTo*fRatioX-W)/2, TextPosY*fScaleTo*fRatioY + (60*fScaleTo*fRatioY - H)/2);
00104	
00105		if (bQuitGame)
00106			C.DrawText(/*Caps*/(QuitText), false);
00107	    else
00108			if (!bAreUSure)
00109				C.DrawText(/*Caps*/(RestartText), false);
00110			else
00111				C.DrawText(/*Caps*/(AreUText), false);
00112	    C.DrawColor = WhiteColor;
00113	}
00114	
00115	
00116	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00117	{
00118	    local int index;
00119	    local bool bLeftOrRight, bUpOrDown;
00120	
00121	    if (State==1)// IST_Press // to avoid auto-repeat
00122	    {
00123	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00124		    {
00125	//            Controller.FocusedControl.OnClick(FocusedControl);
00126	            if (FocusedControl == Controls[0])
00127	            {
00128	                myRoot.CloseMenu(true);
00129	                if (bQuitGame)
00130	                    XIIIWindow(ParentPage).bDoQuitGame = true;
00131	                else XIIIWindow(ParentPage).bDoRestartGame = true;
00132	            }
00133	            if (FocusedControl == Controls[1])
00134	            {
00135	                myRoot.CloseMenu(true);
00136	                XIIIWindow(ParentPage).bDoQuitGame = false;
00137	                XIIIWindow(ParentPage).bDoRestartGame = false;
00138	            }
00139	            return true;
00140		    }
00141		    if (Key==0x08 || Key ==0x1B/*IK_Backspace*/)
00142		    {
00143		        myRoot.CloseMenu(true);
00144	    	    return true;
00145		    }
00146		    if (Key==0x25/*IK_Left*/)
00147		    {
00148		        PrevControl(FocusedControl);
00149	    	    return true;
00150		    }
00151		    if (Key==0x27/*IK_Right*/)
00152		    {
00153		        NextControl(FocusedControl);
00154	    	    return true;
00155		    }
00156	        //return false;
00157	    }
00158	    return super.InternalOnKeyEvent(Key, state, delta);
00159	//    return false;
00160	}
00161	
00162	
00163	
00164	
00165	defaultproperties
00166	{
00167	     YesText="Yes"
00168	     NoText="No"
00169	     QuitText="Quit Game ?"
00170	     RestartText="Restart Level ?"
00171	     AreUText="Are you sure ?"
00172	     bForceHelp=True
00173	     Background=None
00174	     bCheckResolution=True
00175	     bRequire640x480=False
00176	     bAllowedAsLast=True
00177	     bHidePreviousPage=False
00178	}

End Source Code