## XIDInterf
Class XIIIMenuFreeBlock

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

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

Direct Known Subclasses:None

class XIIIMenuFreeBlock
extends XIDInterf.XIIIWindow

    //============================================================================
    // Press start page.
    //
    //============================================================================

Variables
`string` | `TitleText` message "Free block"
`int` | `iNbBlocks` message "Free block"
`string` | `sBackGround[4]` message "Free block"
`Texture` | `tBackGround[4]` message "Free block"

Function Summary
`void` | `Created()`
`bool` | `InternalOnKeyEvent(out byte, out byte, float delta)`
`void` | `Paint(Canvas C, float X, float Y)`
`string` | `Replace(string Src, string Tag, string Value)`

Source Code

    00001	//============================================================================
    00002	// Press start page.
    00003	//
    00004	//============================================================================
    00005	class XIIIMenuFreeBlock extends XIIIWindow;
    00006
    00007	var localized string TitleText;		// message "Free block"
    00008	var string sBackGround[4];
    00009	var texture tBackGround[4];
    00010	var int iNbBlocks;
    00011
    00012	function string Replace(string Src, string Tag, string Value)
    00013	{
    00014	local string retval;
    00015	local int p, tsz;
    00016
    00017		Tag="%"$Tag$"%";
    00018		tsz = Len(Tag);
    00019		p = InStr(Src, Tag);
    00020		while (p != -1)
    00021		{
    00022			retval = retval$Left(Src, p)$Value;
    00023			Src=Mid(Src, p+tsz);
    00024			p = InStr(Src, Tag);
    00025		}
    00026	    return retval$Src;
    00027	}
    00028
    00029	function Created()
    00030	{
    00031	    local int i;
    00032
    00033	    Super.Created();
    00034
    00035	    for (i=0; i<4; i++)
    00036	        tBackGround[i] = texture(DynamicLoadObject(sBackGround[i], class'Texture'));
    00037
    00038		bForceHelp = false;
    00039
    00040		bDisplayBar	= false;
    00041	}
    00042
    00043	event HandleParameters(String Param1,String Param2)
    00044	{
    00045		iNbBlocks = int(Param1);
    00046		TitleText = Replace(TitleText, "nbblocks", Param1);
    00047	}
    00048
    00049	function Paint(Canvas C, float X, float Y)
    00050	{
    00051		local array<string> MsgArray;
    00052		local float W, H;
    00053		local int i;
    00054		local int Length;
    00055		local int TextWith;
    00056
    00057		TextWith = 400;
    00058		C.WrapStringToArray(TitleText, MsgArray, TextWith, "|");
    00059
    00060		Super.Paint(C,X,Y);
    00061
    00062		// draw background texture
    00063	    // background
    00064	    // 293 is (640-27*2)/2
    00065	    DrawStretchedTexture(C, 32*fRatioX, 24*fRatioY*fScaleTo, 288*fRatioX, 216*fRatioY*fScaleTo, tBackGround[0]);
    00066	    DrawStretchedTexture(C, 320*fRatioX, 24*fRatioY*fScaleTo, 288*fRatioX, 216*fRatioY*fScaleTo, tBackGround[1]);
    00067	    DrawStretchedTexture(C, 32*fRatioX, 240*fRatioY*fScaleTo, 288*fRatioX, 216*fRatioY*fScaleTo, tBackGround[2]);
    00068	    DrawStretchedTexture(C, 320*fRatioX, 240*fRatioY*fScaleTo, 288*fRatioX, 216*fRatioY*fScaleTo, tBackGround[3]);
    00069
    00070		// draw page title
    00071		C.bUseBorder = true;
    00072		Length = MsgArray.Length;
    00073		C.DrawColor = WhiteColor;
    00074		C.TextSize(TitleText, W, H);
    00075		DrawStretchedTexture(C, 50, 110, 540, (2*H*Length*fRatioY), myRoot.FondMenu);
    00076		C.DrawColor = BlackColor;
    00077		for(i=0;i<Length;i++)
    00078		{
    00079			C.TextSize(MsgArray[i], W, H);
    00080			C.SetPos((C.SizeX/2)-W/2, 110 + (2*H*i*fRatioY));
    00081			C.DrawText(MsgArray[i], false);
    00082		}
    00083
    00084		// restore old param
    00085		C.DrawColor = WhiteColor;
    00086		C.DrawColor.A = 255; C.Style = 1; C.bUseBorder = false;
    00087	}
    00088
    00089	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
    00090	{
    00091		local int  iStatus;
    00092		local bool bPlayingVideo;
    00093
    00094	    if (State==1) // IST_Press // to avoid auto-repeat
    00095	    {
    00096			if ( (Key==13) /*A button*/ )
    00097			{
    00098				myRoot.bContinueWithoutSaving=true;
    00099				myRoot.bSavingPossible=false;
    00100				myRoot.bProfileSelected=true;
    00101				myRoot.OpenMenu("XIDInterf.XIIIMenu");
    00102				return true;
    00103			}
    00104
    00105			if ( (Key==8) /*B button*/ )
    00106			{
    00107				//GetPlayerOwner().ConsoleCommand("QUIT");
    00108				// 2 is XLD_LAUNCH_DASHBOARD_MEMORY see Xbox.h
    00109				// 85 is 'U'
    00110				myRoot.RebootToDashboardFromScripts(2, 85, iNbBlocks);
    00111
    00112				return true;
    00113			}
    00114	    }
    00115
    00116	    return super.InternalOnKeyEvent(Key, state, delta);
    00117	}
    00118
    00119	event Tick(float fDeltatime)
    00120	{
    00121	}
    00122
    00123

End Source Code