## XIDInterf
Class XIIIMenuCreateProfile

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

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

Direct Known Subclasses:None

class XIIIMenuCreateProfile
extends XIDInterf.XIIIWindow

    //============================================================================
    // Create Profile menu.
    //
    //============================================================================

Variables
`XIIIButton` | `CreateButton`
`string` | `CreateText`
`XIIIComboControl` | `ProfileCombo`
`DisplayedText,` | `ProfileErrorTitle`
`MaxProfiles,` | `ProfileIdx`
`array` | `ProfileNameList`
`string` | `ProfileText`
`int` | `ReturnCode` to be used with profile device
`string` | `TitleText`
`int` | `i` to be used with profile device
`XIIIMsgBox` | `msgbox`
`string` | `sBackGround[4]`
`Texture` | `tBackGround[4]`

States
UseProfile, InitProfile

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

State UseProfile Function Summary

State InitProfile Function Summary

Source Code

    00001	//============================================================================
    00002	// Create Profile menu.
    00003	//
    00004	//============================================================================
    00005	class XIIIMenuCreateProfile extends XIIIWindow;
    00006
    00007	var localized string TitleText;
    00008	var localized string ProfileText;
    00009	var localized string CreateText;
    00010
    00011	var XIIIComboControl ProfileCombo;
    00012	var int MaxProfiles, ProfileIdx;
    00013
    00014	var array<string> ProfileNameList;
    00015
    00016	// FQ : Moved the SelectedProfileName into myRoot
    00017	//var string SelectedProfileName;
    00018
    00019	var XIIIButton CreateButton;
    00020
    00021	var XIIIMsgBox msgbox;
    00022	var localized string DisplayedText, ProfileErrorTitle;
    00023
    00024	var string sBackGround[4];
    00025	var texture tBackGround[4];
    00026
    00027	var int ReturnCode;       // to be used with profile device
    00028	var int i;
    00029
    00030	function Created()
    00031	{
    00032	    Super.Created();
    00033
    00034	    CreateButton = XIIIbutton(CreateControl(class'XIIIButton', 292, 228, 120, 32));
    00035	    CreateButton.Text = CreateText;
    00036	    CreateButton.bGlassLook = true;
    00037
    00038	    Controls[0] = CreateButton;
    00039
    00040	    bShowBCK = true;
    00041	    bShowSEL = true;
    00042
    00043	    GotoState('InitProfile');
    00044	}
    00045
    00046	function Paint(Canvas C, float X, float Y)
    00047	{
    00048	    local float W, H;
    00049	    local int i;
    00050
    00051	    Super.Paint(C,X,Y);
    00052
    00053	    // background
    00054	    DrawStretchedTexture(C, 0, 0, 320*fRatioX, 240*fRatioY*fScaleTo, tBackGround[0]);
    00055	    DrawStretchedTexture(C, 320*fRatioX, 0, 320*fRatioX, 240*fRatioY*fScaleTo, tBackGround[1]);
    00056	    DrawStretchedTexture(C, 0, 240*fRatioY*fScaleTo, 320*fRatioX, 240*fRatioY*fScaleTo, tBackGround[2]);
    00057	    DrawStretchedTexture(C, 320*fRatioX, 240*fRatioY*fScaleTo, 320*fRatioX, 240*fRatioY*fScaleTo, tBackGround[3]);
    00058
    00059	    // page title
    00060	    C.bUseBorder = true;
    00061	    C.DrawColor = WhiteColor;
    00062	    C.TextSize(Caps(TitleText), W, H);
    00063	    DrawStretchedTexture(C, 40, 80*fRatioY, (W+40)*fRatioX, (H+10)*fScaleTo*fRatioY, myRoot.FondMenu);
    00064	    C.DrawColor = BlackColor;
    00065	    C.SetPos(60, 80*fRatioY+H/4);
    00066	    C.DrawText(Caps(TitleText), false);
    00067
    00068	    // restore old param
    00069		C.DrawColor = WhiteColor;
    00070	    C.DrawColor.A = 255; C.Style = 1; C.bUseBorder = false;
    00071	}
    00072
    00073	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
    00074	{
    00075	    if (State==1)// IST_Press // to avoid auto-repeat
    00076	    {
    00077	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01)/*IK_LeftMouse*/)
    00078		    {
    00079	            if (FocusedControl == Controls[1])
    00080	            {
    00081	                myRoot.OpenMenu("XIDInterf.XIIIMenuCreateProfile");
    00082	            }
    00083	            else
    00084	            {
    00085	                myRoot.SelectedProfileName = ProfileCombo.GetValue();
    00086	                GotoState('UseProfile');
    00087	            }
    00088	            return true;
    00089		    }
    00090		    else if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B) /*IK_Escape*/)
    00091		    {
    00092		        myRoot.CloseMenu(true);
    00093	    	    return true;
    00094		    }
    00095		    if (Key==0x26/*IK_Up*/)
    00096		    {
    00097	  	        PrevControl(FocusedControl);
    00098	    	    return true;
    00099		    }
    00100		    if (Key==0x28/*IK_Down*/)
    00101		    {
    00102	            NextControl(FocusedControl);
    00103	    	    return true;
    00104		    }
    00105		    if ((Key==0x25/*IK_Left*/) || (Key==0x27/*IK_Right*/))
    00106		    {
    00107	            if (FocusedControl == Controls[0])
    00108		        {
    00109	                if (Key==0x25) ProfileIdx--;
    00110	                if (Key==0x27) ProfileIdx++;
    00111	                if (ProfileIdx < 0) ProfileIdx = 0;
    00112	                if (ProfileIdx > MaxProfiles-1) ProfileIdx = MaxProfiles - 1;
    00113	                ProfileCombo.SetSelectedIndex(ProfileIdx);
    00114	            }
    00115	            return true;
    00116	        }
    00117	    }
    00118	    return super.InternalOnKeyEvent(Key, state, delta);
    00119	}
    00120
    00121	State InitProfile
    00122	{
    00123	Begin:
    00124	    for (i=0; i<MaxProfiles; i++)
    00125	    {
    00126	      if (!myRoot.RequestGetProfileList())
    00127	      {
    00128	          log("Unable to read profile list");
    00129	      }
    00130	      else
    00131	      {
    00132	          while (!myRoot.IsGetProfileListFinished(ReturnCode, ProfileNameList))
    00133	          {
    00134	              Sleep(0.01);
    00135	          }
    00136	          if (ReturnCode < 0)
    00137	          {
    00138	              log("Get profile list failed");
    00139	          }
    00140	          else
    00141	          {
    00142	            MaxProfiles = ProfileNameList.Length;
    00143	            for( i=0;i < MaxProfiles ; i++ )
    00144	            {
    00145	                ProfileCombo.AddItem(ProfileNameList[i]);
    00146	            }
    00147	            if (MaxProfiles>0)
    00148	            {
    00149	                Controls[0].FocusFirst(self,true);
    00150	                ProfileCombo.SetSelectedIndex(0);
    00151	            }
    00152	            else
    00153	            {
    00154	                ProfileCombo.bVisible = false;
    00155	                ProfileCombo.bNeverFocus = true;
    00156	                Controls[1].FocusFirst(self,true);;
    00157	            }
    00158	          }
    00159	      }
    00160	  }
    00161	  GotoState('');
    00162	}
    00163
    00164	State UseProfile        // slot to use is in SlotNumberToSaveIn
    00165	{
    00166	Begin:
    00167	    if (!myRoot.RequestUseProfile(myRoot.SelectedProfileName))
    00168	    {
    00169	        log("Unable to use profile "$myRoot.SelectedProfileName);
    00170	    }
    00171	    else
    00172	    {
    00173	        while (!myRoot.IsUseProfileFinished(ReturnCode))
    00174	        {
    00175	            Sleep(0.01);
    00176	        }
    00177	        if (ReturnCode < 0)
    00178	        {
    00179	            myRoot.OpenMenu("XIDInterf.XIIIMsgBox",true);
    00180	            msgbox = XIIIMsgBox(myRoot.ActivePage);
    00181	            msgbox.InitBox(220*fRatioX, 130*fRatioY*fScaleTo, 10, 10, 220*fRatioX, 230*fRatioY*fScaleTo);
    00182	            DisplayedText = msgbox.Replace(DisplayedText, "name", myRoot.SelectedProfileName);
    00183	            msgbox.SetupQuestion(DisplayedText, QBTN_Ok, QBTN_Ok, ProfileErrorTitle);
    00184	        }
    00185	        else
    00186	        {
    00187	            myRoot.OpenMenu("XIDInterf.XIIIMenu");
    00188	        }
    00189	    }
    00190	    GotoState('');
    00191	}
    00192
    00193
    00194
    00195	defaultproperties
    00196	{
    00197	     TitleText="Select your profile"
    00198	     ProfileText="Profile"
    00199	     CreateText="new profile"
    00200	     DisplayedText="FAILED to use profile %name%"
    00201	     ProfileErrorTitle="Error in profile"
    00202	     sBackground(0)="GuiContent.BckGround.MN_fond00_1"
    00203	     sBackground(1)="GuiContent.BckGround.MN_fond00_2"
    00204	     sBackground(2)="GuiContent.BckGround.MN_fond00_3"
    00205	     sBackground(3)="GuiContent.BckGround.MN_fond00_4"
    00206	     bForceHelp=True
    00207	     Background=None
    00208	     bAllowedAsLast=True
    00209	}

End Source Code