## XIDInterf
Class XIIIMenuMultiProfile

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

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent
             |
             +--GUI.GUIMultiComponent
                |
                +--GUI.GUIPage
                   |
                   +--XIDInterf.XIIIWindow
                      |
                      +--XIDInterf.XIIIWindowMainMenu
                         |
                         +--XIDInterf.XIIIMenuMultiBase
                            |
                            +--XIDInterf.XIIIMenuMultiProfile

Direct Known Subclasses:None

class XIIIMenuMultiProfile
extends XIDInterf.XIIIMenuMultiBase

    //============================================================================
    // Multiplayer Profile menu.
    //
    //============================================================================

Variables
`MemoName,` | `MemoTeam`
`MyName,` | `MyTeam`
`XIIIEditCtrl` | `NameButton`
`NumSkin,` | `NbSkins`
`PlayerClass,` | `PlayerSkinCode`
`XIIIComboControl` | `SkinButton`
`XIIICheckBoxControl` | `TeamButton`
`XIIIButton` | `ValidButton`
`RedText,` | `ValidText`

Function Summary
`void` | `Created()`
    //============================================================================
`bool` | `InternalOnKeyEvent(out byte, out byte, float delta)`
`bool` | `MayISave()`
`void` | `Paint(Canvas C, float X, float Y)`
`void` | `ProcessSave()`
`void` | `SaveMsgBoxReturn(byte bButton)`
`void` | `ShowWindow()`

Source Code

    00001	//============================================================================
    00002	// Multiplayer Profile menu.
    00003	//
    00004	//============================================================================
    00005	class XIIIMenuMultiProfile extends XIIIMenuMultiBase;
    00006
    00007	var localized string TitleText, TitleXBoxText, NameText, SkinText, TeamText, BlueText, RedText, ValidText;
    00008
    00009	var XIIIButton ValidButton;
    00010	var XIIIEditCtrl NameButton;
    00011	var XIIIComboControl SkinButton;
    00012	var XIIICheckboxControl TeamButton;
    00013
    00014	var int NumSkin, NbSkins;
    00015	var string MyClass, MyName, MyTeam;
    00016	var string MemoClass, MemoName, MemoTeam;
    00017
    00018	//var Array< class<XIIIMPPlayerPawn> > PlayerClass;
    00019	var Array<string> PlayerSkin, PlayerClass, PlayerSkinCode;
    00020
    00021
    00022	//============================================================================
    00023	function Created()
    00024	{
    00025	    local int i;
    00026	//	local string URL, MyClassTemp, MyNameTemp, MyTeamTemp;
    00027
    00028		Super.Created();
    00029
    00030	/*	URL = "?Map="$GetPlayerOwner().Level.GetLocalURL();
    00031		log("URL="$URL);
    00032
    00033		MyClass = LocalParseOption( URL, "Class", "");
    00034		MyName = LocalParseOption( URL, "Name", "");
    00035		MyTeam = LocalParseOption( URL, "Team", "");
    00036
    00037		log(self@"---> DONNEES PAR GET LOCAL URL : Class="$MyClass$" Name="$MyName$" Team="$MyTeam);
    00038
    00039		MyClassTemp = GetPlayerOwner().GetDefaultURL("Class");
    00040		MyNameTemp = GetPlayerOwner().GetDefaultURL("Name");
    00041		MyTeamTemp = GetPlayerOwner().GetDefaultURL("Team");
    00042
    00043		log(self@"---> DONNEES PAR GET DEFAULT URL: Class="$MyClassTemp$" Name="$MyNameTemp$" Team="$MyTeamTemp);
    00044
    00045		MyClass = string (GetPlayerOwner().PawnClass);
    00046		MyName = GetPlayerOwner().PlayerReplicationInfo.PlayerName;
    00047		MyTeam = string (GetPlayerOwner().PlayerReplicationInfo.Team.TeamIndex);
    00048
    00049		log(self@"---> DONNEES UN PEU PARTOUT: Class="$MyClass$" Name="$MyName$" Team="$MyTeam);
    00050
    00051	    MyClass = XIIIGameInfo(GetPlayerOwner().Level.Game).PlayerClass;
    00052		MyName = XIIIGameInfo(GetPlayerOwner().Level.Game).PlayerName;
    00053		MyTeam = string (XIIIGameInfo(GetPlayerOwner().Level.Game).PlayerTeam);
    00054
    00055		log(self@"---> DONNEES PAR GAMEINFO: Class="$MyClass$" Name="$MyName$" Team="$MyTeam);
    00056	*/
    00057		// version par GetDefaultUrl()
    00058		MyName = GetPlayerOwner().GetDefaultURL("MyName");
    00059		if (MyName == "")
    00060			MyName = GetPlayerOwner().GetDefaultURL("Name");
    00061		MyClass = GetPlayerOwner().GetDefaultURL("MySkin");
    00062		MyTeam = GetPlayerOwner().GetDefaultURL("MyTeam");
    00063
    00064		MemoName = MyName;
    00065		MemoClass = MyClass;
    00066		MemoTeam = MyTeam;
    00067
    00068	    NameButton = XIIIEditCtrl(CreateControl(class'XIIIEditCtrl', 160, 200*fScaleTo, 300, 32*fScaleTo));
    00069	    NameButton.TitleText = NameText;
    00070		NameButton.Text = MyName;
    00071
    00072		SkinButton = XIIIComboControl(CreateControl(class'XIIIComboControl', 160, 260*fScaleTo, 300, 32*fScaleTo));
    00073	    SkinButton.Text = SkinText;
    00074		SkinButton.bArrows = true;
    00075		NbSkins = class'MeshSkinList'.default.MeshSkinListInfo.Length;
    00076		NumSkin = 0;
    00077		for (i=0;i<NbSkins;i++)
    00078		{
    00079			PlayerSkin[i] = class'MeshSkinList'.default.MeshSkinListInfo[i].SkinReadableName;
    00080			PlayerClass[i] = class'MeshSkinList'.default.MeshSkinListInfo[i].SkinName;
    00081			PlayerSkinCode[i] = class'MeshSkinList'.default.MeshSkinListInfo[i].SkinCode;
    00082			SkinButton.AddItem(PlayerSkin[i]);
    00083			if ( MyClass == PlayerClass[i] )
    00084				NumSkin = i;
    00085		}
    00086		SkinButton.SetSelectedIndex(NumSkin);
    00087
    00088		TeamButton = XIIICheckboxControl(CreateControl(class'XIIICheckboxControl', 160, 320*fScaleTo, 300, 32*fScaleTo));
    00089		TeamButton.Text = TeamText;
    00090		TeamButton.sYes = BlueText;
    00091		TeamButton.sNo = RedText;
    00092		if ( MyTeam == "0" )
    00093			TeamButton.bChecked = false;
    00094		else
    00095			TeamButton.bChecked = true;
    00096		TeamButton.bWhiteColorOnlyWhenFocused = true;
    00097
    00098		ValidButton = XIIIButton( CreateControl( class'XIIIButton', 210, 380*fScaleTo, 200, 32*fScaleTo ) );
    00099		ValidButton.Text = ValidText;
    00100
    00101		Controls[0] = NameButton;
    00102		Controls[1] = SkinButton;
    00103		Controls[2] = TeamButton;
    00104		Controls[3] = ValidButton;
    00105	}
    00106
    00107
    00108	function ShowWindow()
    00109	{
    00110	    super.ShowWindow();
    00111	    bShowCCL = true;
    00112	//    bShowSEL = true;
    00113	}
    00114
    00115
    00116	function Paint(Canvas C, float X, float Y)
    00117	{
    00118	    local float W, H;
    00119	    local int i;
    00120
    00121		bShowACC = ( FocusedControl==ValidButton );
    00122		bShowEDT = ( FocusedControl==NameButton );
    00123
    00124	    Super.Paint(C,X,Y);
    00125
    00126	    // page title
    00127	    C.bUseBorder = true;
    00128	    C.DrawColor = WhiteColor;
    00129		if ( myRoot.CurrentPF == 2 )
    00130			TitleText = TitleXBoxText;
    00131		C.TextSize(TitleText, W, H);
    00132	    DrawStretchedTexture(C, -1, 80*fRatioY, (W+80)*fRatioX, (H+10)*fScaleTo*fRatioY, myRoot.FondMenu);
    00133	    C.DrawColor = BlackColor;
    00134	    C.SetPos(40*fRatioX, 80*fRatioY+H/4);
    00135	    C.DrawText( TitleText, false);
    00136
    00137	    // restore old param
    00138		C.DrawColor = WhiteColor;
    00139	    C.DrawColor.A = 255;
    00140		C.Style = 1;
    00141		C.bUseBorder = false;
    00142
    00143	}
    00144
    00145	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
    00146	{
    00147	    local string URL;
    00148		local XIIIMsgBox MsgBox;
    00149
    00150		if (State==1)// IST_Press // to avoid auto-repeat
    00151	    {
    00152	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01)/*IK_LeftMouse*/)
    00153		    {
    00154				if (FocusedControl==ValidButton)
    00155				{
    00156					MyName = NameButton.Text;
    00157					MyClass = PlayerClass[NumSkin];
    00158					MyTeam = string ( int( TeamButton.bChecked ) );
    00159
    00160					if ( myRoot.CurrentPF == 2 )
    00161					{
    00162						if (MayISave())
    00163						{
    00164							myRoot.OpenMenu("XIDInterf.XIIIMsgBox");
    00165							MsgBox = XIIIMsgBox(myRoot.ActivePage);
    00166							MsgBox.InitBox(220*fRatioX, 130*fRatioY*fScaleTo, 10, 10, 220*fRatioX, 230*fRatioY*fScaleTo);
    00167							MsgBox.SetupQuestion(class'XIIIMenuOptions'.default.SaveQuestionText, QBTN_Yes | QBTN_No, QBTN_Yes, "");
    00168							MsgBox.OnButtonClick = SaveMsgBoxReturn;
    00169						}
    00170						else
    00171						{
    00172							myRoot.CloseMenu(true);
    00173						}
    00174					}
    00175					else
    00176					{
    00177						ProcessSave();
    00178					}
    00179					return true;
    00180				}
    00181		    }
    00182
    00183			if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B) /*IK_Escape*/)
    00184		    {
    00185		        myRoot.CloseMenu(true);
    00186	    	    return true;
    00187		    }
    00188
    00189		    if (Key==0x26/*IK_Up*/)
    00190		    {
    00191	  	        PrevControl(FocusedControl);
    00192	    	    return true;
    00193		    }
    00194
    00195		    if (Key==0x28/*IK_Down*/)
    00196		    {
    00197	            NextControl(FocusedControl);
    00198	    	    return true;
    00199		    }
    00200
    00201			if ((Key==0x25) || (Key==0x27))
    00202			{
    00203				if (FocusedControl == Controls[1])
    00204				{
    00205					if (Key == 0x25)
    00206						NumSkin --;
    00207					if (Key == 0x27)
    00208						NumSkin ++;
    00209					NumSkin = Clamp(NumSkin,0,NbSkins - 1);
    00210					SkinButton.SetSelectedIndex(NumSkin);
    00211				}
    00212
    00213				if (FocusedControl == Controls[2])
    00214				{
    00215					if (Key==0x25)
    00216						TeamButton.bChecked = true;
    00217					if (Key==0x27)
    00218						TeamButton.bChecked = false;
    00219				}
    00220
    00221			}
    00222	    }
    00223	    return super.InternalOnKeyEvent(Key, state, delta);
    00224	}
    00225
    00226
    00227	function bool MayISave()
    00228	{
    00229		return (
    00230			( MemoName != MyName )
    00231		||	( MemoClass != MyClass )
    00232		||	( MemoTeam != MyTeam )
    00233		);
    00234	}
    00235	function SaveMsgBoxReturn(byte bButton)
    00236	{
    00237		if ( (bButton & QBTN_Yes) != 0)
    00238		{
    00239			ProcessSave();
    00240		}
    00241		else
    00242		{
    00243			myRoot.CloseMenu(true);
    00244		}
    00245
} 00246 00247 00248 function ProcessSave() 00249 { 00250 GetPlayerOwner().ChangeName(MyName); 00251 GetPlayerOwner().UpdateURL("MyName",MyName,true); 00252 GetPlayerOwner().UpdateURL("MySkin",MyClass,true); 00253 GetPlayerOwner().UpdateURL("MyTeam",MyTeam,true); 00254 00255 SaveConfigs(); 00256 } 00257 00258 00259 00260 00261 defaultproperties 00262 { 00263 TitleText="Online multiplayer profile" 00264 TitleXBoxText="System link profile" 00265 NameText="Name" 00266 SkinText="Skin" 00267 TeamText="Team" 00268 BlueText="Blue" 00269 RedText="Red" 00270 ValidText="Accept" 00271 bForceHelp=True 00272 }

End Source Code