XIDInterf
Class XIIIMenuInGame

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

class XIIIMenuInGame
extends XIDInterf.XIIIWindow

//============================================================================ // The In Game menu. // //============================================================================
Variables
 ConfirmQuitTxt, ConfirmRestartTxt
 RestartBtn, QuitBtn
 RestartTxt, QuitTxt
 iObjDecalY, timer


Function Summary
 void BeforePaint(Canvas C, float X, float Y)
 void Created()
 bool InternalOnClick(GUIComponent Sender)
     
// Called when a button is clicked
 bool InternalOnKeyEvent(out byte, out byte, float delta)
 void Paint(Canvas C, float X, float Y)
 void QuitGame()
 void QuitMsgBoxReturn(byte bButton)
 void RestartGame()
 void RestartMsgBoxReturn(byte bButton)
 void SetObjectives(Canvas C)
 void ShowWindow()



Source Code


00001	//============================================================================
00002	// The In Game menu.
00003	//
00004	//============================================================================
00005	class XIIIMenuInGame extends XIIIWindow;
00006	
00007	var XIIIButton       SaveBtn, ReturnBtn, ControlsBtn, CompetencesBtn, ItemBtn, RestartBtn, QuitBtn;
00008	var localized string SaveTxt, ReturnTxt, ControlsTxt, CompetencesTxt, ItemTxt, RestartTxt, QuitTxt;
00009	var localized string ConfirmQuitTxt, ConfirmRestartTxt; 
00010	
00011	//var array<string> Objectives;
00012	//var localized array<string> Objectives;
00013	var int iObjDecalY, timer;
00014	
00015	function Created()
00016	{
00017		local XIIIBaseHUD Hud;
00018		local HudMessage HMsg;
00019		local int i, OffsetInit;
00020	
00021	
00022	    Super.Created();
00023	
00024		OffsetInit = 155;
00025		i = 0;
00026	    SaveBtn = XIIIbutton(CreateControl(class'XIIIbutton', 230, OffsetInit*fScaleTo, 200, 30*fScaleTo));
00027	    SaveBtn.Text = SaveTxt;
00028	    SaveBtn.bUseBorder = false;
00029		i++;
00030	
00031	    ReturnBtn = XIIIbutton(CreateControl(class'XIIIbutton', 230, (OffsetInit + 30*i)*fScaleTo, 200, 30*fScaleTo));
00032	    ReturnBtn.Text = ReturnTxt;
00033	    ReturnBtn.bUseBorder = false;
00034		i++;
00035	
00036	    ControlsBtn = XIIIbutton(CreateControl(class'XIIIbutton', 230, (OffsetInit + 30*i)*fScaleTo, 200, 30*fScaleTo));
00037	    ControlsBtn.Text = ControlsTxt;
00038	    ControlsBtn.bUseBorder = false;
00039		i++;
00040	
00041	    CompetencesBtn = XIIIbutton(CreateControl(class'XIIIbutton', 230, (OffsetInit + 30*i)*fScaleTo, 200, 30*fScaleTo));
00042	    CompetencesBtn.Text = CompetencesTxt;
00043	    CompetencesBtn.bUseBorder = false;
00044		i++;
00045	    
00046		//ItemBtn = XIIIbutton(CreateControl(class'XIIIbutton', 230, 265*fScaleTo, 200, 30*fScaleTo));
00047	    //ItemBtn.Text = ItemTxt;
00048	    //ItemBtn.bUseBorder = false;
00049		RestartBtn = XIIIbutton(CreateControl(class'XIIIbutton', 230, (OffsetInit + 30*i)*fScaleTo, 200, 30*fScaleTo));
00050		RestartBtn.Text = RestartTxt;
00051		RestartBtn.bUseBorder = false;
00052		i++;
00053	
00054	    if ( GetPlayerOwner().Level.Title~="mapcredits" )
00055		{
00056			RestartBtn.bNeverFocus=true;
00057			RestartBtn.TextColor=class'Canvas'.Static.MakeColor(192,192,192);
00058		}
00059	
00060	    QuitBtn = XIIIbutton(CreateControl(class'XIIIbutton', 230, (OffsetInit + 30*i)*fScaleTo, 200, 30*fScaleTo));
00061	    QuitBtn.Text = QuitTxt;
00062	    QuitBtn.bUseBorder = false;
00063	
00064	    Controls[0] = SaveBtn;
00065	    Controls[1] = ReturnBtn;
00066	    Controls[2] = ControlsBtn;
00067	    Controls[3] = CompetencesBtn;
00068		Controls[4] = RestartBtn;
00069	    Controls[5] = QuitBtn;
00070	
00071		// erase important message display
00072		Hud = XIIIBaseHUD(GetPlayerOwner().myHUD);
00073		if ( Hud != none )
00074		{
00075			for ( HMsg = Hud.HudMsg; HMsg!=none; HMsg = HMsg.NextHudMsg)
00076			{
00077				HMsg.bIsSpecial = false;
00078				HMsg.MyMessage.EndOfLife = GetPlayerOwner().Level.TimeSeconds;
00079			}
00080		}
00081		myRoot.bPerformMemoryCardReDetection = true;
00082	
00083		iObjDecalY = 30;	// antibug for XBox => Now use for all plateforms
00084	}
00085	
00086	
00087	function SetObjectives(canvas C)
00088	{
00089		local MapInfo CurrentMap;
00090		local int i,j, ob, LineY;
00091	    local float W, H, oldClipX;
00092		local array<string> MsgArray;
00093	
00094		CurrentMap = XIIIGameInfo(GetPlayerOwner().Player.Actor.Level.Game).MapInfo;
00095	/*	ob = CurrentMap.Objectif.Length;
00096		Objectives.Length = 0;
00097		for (i=0; i<ob; i++)
00098		{
00099			if (( CurrentMap.Objectif[i].bPrimary ) && ( !CurrentMap.Objectif[i].bCompleted || CurrentMap.Objectif[i].bAntigoal ))
00100			{
00101				Objectives[j] = CurrentMap.Objectif[i].GoalText;
00102				j++;
00103			}
00104		}*/
00105		//log(self@"---> LISTE DES OBJECTIFS :"@Objectives[0]@Objectives[1]@Objectives[2]@Objectives[3]);
00106	
00107		C.bUseBorder = false;
00108		C.DrawColor = WhiteColor;
00109	    C.Style = 5;
00110	    if (myRoot.GetLevel().bCineFrame)
00111			C.DrawColor.A=192;
00112		else
00113			C.DrawColor.A=128;
00114		DrawStretchedTexture(C, 0, 0, C.ClipX, 118*fScaleTo*fRatioY, myRoot.FondMenu);
00115		C.DrawColor.A=255;
00116	    C.Style = 1;
00117	
00118		LineY=0;
00119		for (j=0;j<CurrentMap.Objectif.Length;j++)
00120		{
00121			if (( CurrentMap.Objectif[j].bPrimary ) && ( !CurrentMap.Objectif[j].bCompleted || CurrentMap.Objectif[j].bAntigoal ))
00122			{
00123				MsgArray.Remove( 0, MsgArray.Length );
00124				C.WrapStringToArray( CurrentMap.Objectif[j].GoalText, MsgArray, 540*fRatioX, "|");
00125				C.bUseBorder = false;
00126				if ( CurrentMap.Objectif[j].bAntigoal )
00127					C.DrawColor = C.Static.MakeColor(144,0,0);
00128				else
00129					C.DrawColor = BlackColor;
00130				for ( i=0; i<MsgArray.Length; i++ )
00131				{
00132					C.TextSize( MsgArray[i], W, H);
00133	//				LOG( H);
00134					C.SetPos( 50*fRatioX, (LineY+6)*fRatioY/*H/4*/+iObjDecalY);
00135					C.DrawText( MsgArray[i], false);
00136					LineY+=0.9*H;
00137				}
00138				LineY+=0.15*H;
00139			}
00140		}
00141	
00142	}
00143	
00144	
00145	function ShowWindow()
00146	{
00147	    Super.ShowWindow();
00148	
00149		bShowBCK = true;
00150	    bShowSEL = true;
00151	}
00152	
00153	
00154	function BeforePaint(Canvas C, float X, float Y)
00155	{
00156	    super.BeforePaint(C, X, Y);
00157	
00158	    if (bDoQuitGame)
00159	       QuitGame();
00160	    if (bDoRestartGame)
00161	       RestartGame();
00162	
00163	    if ( GetPlayerOwner().Level.Game.bGameEnded )// game over
00164	    {
00165	        //ReturnBtn.Text="Retry";
00166			ReturnBtn.bNeverFocus=true;
00167			ReturnBtn.TextColor=class'Canvas'.Static.MakeColor(192,192,192);
00168			SaveBtn.bNeverFocus=true;
00169			SaveBtn.TextColor=class'Canvas'.Static.MakeColor(192,192,192);
00170	
00171			if (FocusedControl==Controls[0])
00172				NextControl(FocusedControl);
00173			if (FocusedControl==Controls[1])
00174				NextControl(FocusedControl);
00175	    }
00176		else
00177		{
00178			// FQ, if there's a memory card, we can save, even if we chose "Continue Without Saving"
00179			// if ((!myRoot.IsThereACheckpoint()) || (!myRoot.bSavingPossible) || (myRoot.bContinueWithoutSaving)) // nothing to save
00180			if ((!myRoot.IsThereACheckpoint()) || (!myRoot.bSavingPossible) || GetPlayerOwner().Level.Title~="mapcredits" ) // nothing to save
00181			{
00182				SaveBtn.TextColor=class'Canvas'.Static.MakeColor(192,192,192);
00183				SaveBtn.bNeverFocus=true;
00184				if (FocusedControl==Controls[0])
00185					NextControl(FocusedControl);
00186			}
00187			else
00188			{
00189				SaveBtn.TextColor=SaveBtn.Default.TextColor;
00190				SaveBtn.bNeverFocus=false;
00191			}
00192		}
00193	}
00194	
00195	
00196	function Paint(Canvas C, float X, float Y)
00197	{
00198	    local string sVersion;
00199	    local int i;
00200	
00201		if ( SaveBtn.bNeverFocus )
00202			bShowBCK = false;	
00203	
00204	    Super.Paint(C,X,Y);
00205	
00206	    timer=31;
00207	    //if ( timer < 16 )
00208	    //    timer++;
00209		C.SpaceX = 0;
00210	    // background
00211	    if (myRoot.GetLevel().bCineFrame)
00212		{
00213		    C.Style = 5;
00214			C.DrawColor = BlackColor;
00215			C.DrawColor.A = 192;
00216		    DrawStretchedTexture(C, 0, 0, WinWidth*C.ClipX, WinHeight*C.ClipY, myRoot.FondMenu);
00217			C.Style = 1;
00218		}
00219		C.DrawMsgboxBackground(false, 220*fRatioX, 130*fRatioY*fScaleTo, 10, 10, 220*fRatioX, 230*fRatioY*fScaleTo);
00220	
00221		// only selected control has a border
00222	    for (i=0; i<6; i++)
00223	        XIIIbutton(Controls[i]).bUseBorder = false;    
00224	    if (FindComponentIndex(FocusedControl)!= -1)
00225	        XIIIbutton(Controls[FindComponentIndex(FocusedControl)]).bUseBorder = true;
00226	
00227	    // page title
00228	    C.SetPos(220*fRatioX,340*fRatioY*fScaleTo);
00229		C.DrawColor = BlackColor;
00230		C.DrawColor.A = 255;
00231	//	sVersion ="no version";
00232	//	sVersion = myRoot.GetXIIIEngineVersion();
00233	//	C.DrawText(sVersion, false);
00234	
00235		// objectives
00236		SetObjectives(C);
00237		
00238		// restore old param
00239		C.DrawColor = WhiteColor;
00240	    C.DrawColor.A = 255; C.Style = 1; C.bUseBorder = false;
00241	}
00242	
00243	
00244	// Called when a button is clicked
00245	function bool InternalOnClick(GUIComponent Sender)
00246	{
00247	    local XIIIMsgBoxInGame MsgBox;
00248	
00249		if (Sender == SaveBtn)
00250		{
00251	        myRoot.OpenMenu("XIDInterf.XIIIMenuSave");
00252		}
00253	    else if (Sender == ReturnBtn) 
00254		{
00255		    /*// if game finished, disable return to game and name the button Retry, not return to game
00256			GetPlayerOwner().ResetInputs();
00257	        if (GetPlayerOwner().Level.Game.bGameEnded)// game over
00258	        {   // the game is over, start at last saved checkpoint
00259	            if (myRoot.IsThereACheckpoint()) // there is a checkpoint, 
00260	            {
00261	                myRoot.CloseAll(true);
00262	                myRoot.GotoState('');
00263	                myRoot.LoadAtCheckpoint();
00264	            }
00265	            else
00266	            {   // otherwise start at the beginning of the map
00267	                myRoot.CloseAll(true);
00268	                myRoot.GotoState('');
00269	            }
00270	        }
00271	        else
00272	        {*/
00273			    // return to game
00274				GetPlayerOwner().ResetInputs();
00275	            myRoot.CloseAll(true);
00276	            myRoot.GotoState('');
00277	        //}
00278	
00279	    }
00280	    else if (Sender == ControlsBtn)
00281	    {
00282	        if (myRoot.CurrentPF > 0)
00283				myRoot.OpenMenu("XIDInterf.XIIIMenuInGameControlsWindow"); // consoles
00284	        else 
00285				myRoot.OpenMenu("XIDInterf.XIIIMenuInputPC"); // PC
00286	    }
00287	    else if (Sender == CompetencesBtn) 
00288		{
00289	        myRoot.OpenMenu("XIDInterf.XIIIMenuCompetencesIngame");
00290	    }
00291	    else if (Sender == ItemBtn) 
00292		{
00293	        myRoot.OpenMenu("XIDInterf.XIIIMenuItemsIngame");
00294	    }
00295	    else if (Sender == RestartBtn) 
00296		{
00297			bShowBCK = false;
00298			myRoot.OpenMenu("XIDInterf.XIIIMsgBoxInGame");
00299			MsgBox = XIIIMsgBoxInGame(myRoot.ActivePage);
00300			MsgBox.InitBox(220*fRatioX, 130*fRatioY*fScaleTo, 10, 10, 220*fRatioX, 230*fRatioY*fScaleTo);
00301			MsgBox.SetupQuestion(ConfirmRestartTxt, QBTN_Yes | QBTN_No, QBTN_No,"");
00302			MsgBox.OnButtonClick = RestartMsgBoxReturn;
00303	    }
00304	    else if (Sender == QuitBtn) 
00305		{
00306			bShowBCK = false;
00307			myRoot.OpenMenu("XIDInterf.XIIIMsgBoxInGame");
00308			MsgBox = XIIIMsgBoxInGame(myRoot.ActivePage);
00309			MsgBox.InitBox(220*fRatioX, 130*fRatioY*fScaleTo, 10, 10, 220*fRatioX, 230*fRatioY*fScaleTo);
00310			MsgBox.SetupQuestion(ConfirmQuitTxt, QBTN_Yes | QBTN_No, QBTN_No,"");
00311			MsgBox.OnButtonClick = QuitMsgBoxReturn;
00312	    }
00313	    return true;
00314	}
00315	
00316	
00317	function QuitMsgBoxReturn(byte bButton)
00318	{
00319		bShowBCK = true;
00320		if ((bButton & QBTN_Yes) != 0)
00321		{
00322			QuitGame();
00323		}
00324	}
00325	
00326	function RestartMsgBoxReturn(byte bButton)
00327	{
00328		bShowBCK = true;
00329		if ((bButton & QBTN_Yes) != 0)
00330		{
00331			RestartGame();
00332		}
00333	}
00334	
00335	
00336	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00337	{
00338	 timer=31;
00339	 if (timer > 15)
00340	 {
00341	    if (State==1)// IST_Press // to avoid auto-repeat
00342	    {
00343	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00344	            return InternalOnClick(FocusedControl);
00345	
00346		    if (Key==0x08 || Key ==0x1B/*IK_Backspace*/)
00347		    {
00348				if (!GetPlayerOwner().Level.Game.bGameEnded)
00349				{
00350					GetPlayerOwner().ResetInputs();
00351					myRoot.CloseAll(true);
00352					myRoot.GotoState('');
00353				}
00354	    	    return true;
00355		    }
00356	
00357		    if (Key==0x26/*IK_Up*/)
00358		    {
00359		        PrevControl(FocusedControl);
00360	    	    return true;
00361		    }
00362	
00363		    if (Key==0x28/*IK_Down*/)
00364		    {
00365		        NextControl(FocusedControl);
00366	    	    return true;
00367		    }
00368	    }
00369	    return super.InternalOnKeyEvent(Key, state, delta);
00370	  }
00371	 else
00372		 return true;
00373	}
00374	
00375	
00376	function RestartGame()
00377	{
00378	/*    bDoRestartGame = false;
00379	    myRoot.CloseAll(true);
00380	    myRoot.GotoState('');
00381	    //GetPlayerOwner().ConsoleCommand("RestartLevel");
00382	    myRoot.LoadAtCheckpoint(true);     // force load the checkpoint at map start
00383	*/
00384	    bDoRestartGame = false;
00385		GetPlayerOwner().ResetInputs();
00386		if (myRoot.IsThereACheckpoint()) // there is a checkpoint, 
00387		{
00388			myRoot.CloseAll(true);
00389			myRoot.GotoState('');
00390			myRoot.LoadAtCheckpoint();
00391		}
00392		else
00393		{   
00394			// otherwise start at the beginning of the map
00395			myRoot.CloseAll(true);
00396			myRoot.GotoState('');
00397		}
00398	}
00399	
00400	
00401	function QuitGame()
00402	{
00403	    myRoot.CloseAll(true);
00404	    myRoot.GotoState('');
00405	    GetPlayerOwner().ClientTravel("MapMenu", TRAVEL_Absolute, false);
00406	}
00407	
00408	
00409	
00410	
00411	defaultproperties
00412	{
00413	     SaveTxt="Save game"
00414	     ReturnTxt="Return to game"
00415	     ControlsTxt="Controls"
00416	     CompetencesTxt="Skills"
00417	     ItemTxt="Items found"
00418	     RestartTxt="Retry"
00419	     QuitTxt="Main menu"
00420	     ConfirmQuitTxt="All unsaved progress will be lost.|Quit game ?"
00421	     ConfirmRestartTxt="Are you sure ?"
00422	     bForceHelp=True
00423	     Background=None
00424	     bAllowedAsLast=True
00425	}

End Source Code