XIDInterf
Class XIIIRootWindow

source: C:\XIII\XIDInterf\Classes\XIIIRootWindow.uc
Core.Object
   |
   +--Engine.Interactions
      |
      +--Engine.Interaction
         |
         +--Engine.BaseGUIController
            |
            +--GUI.GUIController
               |
               +--XIDInterf.XIIIRootWindow
Direct Known Subclasses:None

class XIIIRootWindow
extends GUI.GUIController

//============================================================================ // this is the main window and is accessible from any window // It handles the drawing of the background, the basic scaling ratio // and the drawing of the side bars (if used) //============================================================================
Variables
 int DefaultUserConfig
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 BlackColor, FilterColor
 tFondNoir, FondMenu
 float GUIScale
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 JoyLEFT, JoyRIGHT
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 XIIILiveMsgBox MsgBox
 XIIISaveMenuStack SaveMenuStack
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 CurrentPF, ScreenHeight
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 string SelectedProfileName
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 float XS
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 bMapMenu, bCloseAfterLoading
           Is a key/button being pressed
 bFired, bClosed
           , bCanceled; // confirm, quit and save, quit
 bUpOrDown2, bLeftOrRight2
           Is a key/button being pressed
 bool bPerformMemoryCardReDetection
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 bMusicPlay, bShowFX
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 bSkinMenuDone, bSkinMenuDisplayed
           Is a key/button being pressed
 bool bStatsAlreadyDisplayed
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 bProfileMenu, bXboxStartup
           which menu is active ?
 bool be3Version
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 float fTextureScaleFactorForConsole
           , _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
 myCrossX, myCrossY
           value of the pad axis/keyboard arrows
 sFondMenu, sFondNoir
 XboxLiveManager xboxLive

States
UWindows

Function Summary
 void RestoreMenuStack()


State UWindows Function Summary
 void SetControllerStatus(bool On)
 void DrawStretchedTexture(Canvas C, float X, float Y, float W, float H, Texture Tex)
 void Printf(Canvas C, string text, float x, float y, int maxlen)
 LevelInfo GetLevel()
 PlayerController GetPlayerOwner()
 void EndState()
 void BeginState()



Source Code


00001	//============================================================================
00002	// this is the main window and is accessible from any window
00003	// It handles the drawing of the background, the basic scaling ratio
00004	// and the drawing of the side bars (if used)
00005	//============================================================================
00006	class XIIIRootWindow extends GUIController;
00007	
00008	var texture tLoadTex, tFondNoir, FondMenu;
00009	var string sFondMenu, sFondNoir;
00010	var color BlackColor, FilterColor;
00011	
00012	var XBoxLiveManager xboxLive;
00013	var XIIILiveMsgBox MsgBox;
00014	
00015	var float myJoyX, myJoyY, myCrossX, myCrossY;     // value of the pad axis/keyboard arrows
00016	var bool  bFired, bClosed;//, bCanceled;             // confirm, quit and save, quit
00017	var bool  bIamInGame, bIamInMulti, bProfileMenu, bXboxStartup; // which menu is active ?
00018	var bool  bUpOrDown, bLeftOrRight, bUpOrDown2, bLeftOrRight2;    // Is a key/button being pressed
00019	var bool  bFirstTime, bCinematic, bPressEsc, bBriefing, bOnline, bSkinMenuDone, bSkinMenuDisplayed;
00020	var bool  bBriefingDone, bMapMenu, bCloseAfterLoading;
00021	
00022	var float XS;//, _DT, _SH, fMaxSH, fadeAccum;//, _SN; //WinScale;
00023	var float GUIScale;
00024	var float fTextureScaleFactorForConsole;
00025	
00026	var int CurrentPF, ScreenHeight;
00027	var int JoyUP, JoyDOWN, JoyLEFT, JoyRIGHT;
00028	var bool bMusicPlay, bShowFX;
00029	
00030	var string SelectedProfileName;
00031	var bool bPerformMemoryCardReDetection;
00032	
00033	var config bool be3Version;
00034	var int DefaultUserConfig;
00035	
00036	var XIIISaveMenuStack SaveMenuStack;
00037	
00038	var bool bStatsAlreadyDisplayed;
00039	
00040	
00041	//var sound hMenuMuzik;
00042	
00043	event InitializeController()
00044	{
00045	     log("CREATING ROOT WINDOW: "$self);
00046	//     bFirstTime = true;
00047	     super.InitializeController();
00048	     FondMenu = texture(DynamicLoadObject(sFondMenu, class'Texture'));
00049	     tFondNoir = texture(DynamicLoadObject(sFondNoir, class'Texture'));
00050	     
00051	     CableDisconnected = false;
00052	}
00053	
00054	
00055	event Tick(float DeltaTime)
00056	{
00057	  local int Status;
00058	  local string ErrorMsg;
00059	//    bSavingPossible=IsSavingMediaAvailable();
00060	// bSaving always possible since save are done on DD
00061	// but since bSavingPossible is used to display save
00062	// menu option, bSavingPossible is bContinueWithoutSaving
00063	// complement so save menu does'not appear when bContinueWithoutSaving
00064	// is true
00065	  bSavingPossible=!bContinueWithoutSaving;
00066	  
00067	  Status = GetConnectionStatus(ErrorMsg);
00068	  if ((Status != 0) && !bStatsAlreadyDisplayed)
00069	  {
00070	    OpenMenu("XIDInterf.XIIIMenuLiveStatsWritePage", false, "netfailure");
00071	    bStatsAlreadyDisplayed = true;
00072	  }
00073	}
00074	
00075	
00076	
00077	event SetMenuStackBackup(string MenuStackAsText)
00078	{
00079	    local int i, Pos, NextPos, LastMenuStackTextLength;
00080	    local string MenuStackText;
00081	
00082	    if (MenuStackAsText != "")
00083	    {
00084	        if (SaveMenuStack == none)
00085	        {
00086	            SaveMenuStack = new(none) class'XIIISaveMenuStack';
00087	        }
00088	        else
00089	        {
00090	            SaveMenuStack.Menu.Length = 0;
00091	        }
00092	
00093	        i = 0;
00094	        MenuStackText = "MenuStack"$i$"=";
00095	        Pos = InStr(MenuStackAsText, MenuStackText);
00096	
00097	        while (Pos != -1)
00098	        {
00099	            i++;
00100	            LastMenuStackTextLength = Len(MenuStackText);
00101	            MenuStackText = "MenuStack"$i$"=";
00102	            NextPos = InStr(MenuStackAsText, MenuStackText);
00103	
00104	            if (NextPos != -1)
00105	            {
00106	                SaveMenuStack.AddMenu(Mid(MenuStackAsText, LastMenuStackTextLength, NextPos-LastMenuStackTextLength));
00107	                MenuStackAsText = Mid(MenuStackAsText, NextPos);
00108	            }
00109	            else
00110	            {
00111	                SaveMenuStack.AddMenu(Mid(MenuStackAsText, LastMenuStackTextLength));
00112	            }
00113	
00114	            Pos = NextPos;
00115	        }
00116	    }
00117	}
00118	
00119	event string GetMenuStackBackup()
00120	{
00121	    local string str;
00122	    local int i;
00123	
00124	    str = "";
00125	
00126	    for (i=0;i<SaveMenuStack.Menu.Length;i++)
00127	    {
00128	        str = str $ "MenuStack"$i$"="$SaveMenuStack.Menu[i];
00129	    }
00130	
00131	    return str;
00132	}
00133	
00134	function RestoreMenuStack()
00135	{
00136	    local int i, FirstQuestionMarkPos;
00137	    local string str;
00138	
00139	    if (SaveMenuStack == none)
00140	        return;
00141	
00142	    for (i=0; i<SaveMenuStack.Menu.Length; i++)
00143	    {
00144	        str = SaveMenuStack.Menu[i];
00145	        FirstQuestionMarkPos = InStr(str, "?");
00146	        if (FirstQuestionMarkPos == -1)
00147	        {
00148	            OpenMenu(str, false);
00149	        }
00150	        else
00151	        {
00152	            OpenMenu(Left(str, FirstQuestionMarkPos), false);
00153	            ActivePage.SetPageParameters(Mid(str, FirstQuestionMarkPos));
00154	        }
00155	    }
00156	}
00157	
00158	
00159	state UWindows
00160	{
00161	     function BeginState()
00162	     {
00163	          local int index;
00164	
00165	          Super.BeginState();
00166	          XIIIPlayerController(GetPlayerOwner()).bMenuIsActive = true;
00167	          //log("BEGIN STATE: "$self);
00168	          //log("-BeginState PO: "$GetPlayerOwner());
00169	
00170	          bMapMenu = XIIIConsole(Master.GlobalInteractions[0]).bMapMenu;
00171	          if (bMapMenu && ViewportOwner.Actor.Level.bLonePlayer) 
00172	          {
00173	               ViewportOwner.Actor.SetPause( false );
00174	          }
00175	          else
00176	          {
00177	    			  if ( ( GetLevel().Game.NumPlayers == 1 ) && ( GetLevel().NetMode == 0) )
00178	                    ViewportOwner.Actor.SetPause( true );
00179	                else
00180	                    ViewportOwner.Actor.bIsInMenu=true;
00181	          }
00182	          if ( ViewportOwner.Actor.Level.Pauser!=none )
00183	              GetPlayerOwner().PauseAllSounds();
00184	
00185	          CurrentPF = 2;//int(XIIIGameInfo(ViewportOwner.Actor.Level.Game).PlateForme);
00186	          ScreenHeight = 448;
00187	          fTextureScaleFactorForConsole = ScreenHeight / 480.0;
00188	
00189	          log("Loneplayer: "$ViewportOwner.Actor.Level.bLonePlayer);
00190	          log("bSkinMenuDone :"$bSkinMenuDone);
00191	
00192	          if (bMapMenu)
00193	          {
00194				  bMusicPlay = true;
00195	              
00196				  LoadMainMenu();
00197	              InitController();
00198	
00199	            if (SaveMenuStack != none)
00200	            {
00201	                RestoreMenuStack();
00202	                SaveMenuStack = none;
00203	            }
00204	            else
00205	            {
00206	            if (xboxLive == none) // SouthEnd
00207	              xboxLive = new class'xboxlivemanager';
00208	            if (xboxLive.IsLoggedIn(xboxLive.GetCurrentUser()) )
00209	            {
00210	              OpenMenu("XIDInterf.XIIIMenu");
00211	
00212	              xboxLive.SessionDelete();
00213	            }
00214	            else
00215	            {
00216					OpenMenu("XIDInterf.XIIIMenuPressStart");
00217	            }
00218	           }
00219	        }
00220	        else
00221	        {
00222	          // MLK: Tests wether we're in SOLO mode or not
00223	          if (ViewportOwner.Actor.Level.bLonePlayer)
00224	          {
00225	                        OpenMenu("XIDInterf.XIIIMenuInGame");
00226	          }
00227	          else
00228	          {
00229	              if (xboxLive == none) // SouthEnd
00230	                xboxLive = new class'xboxlivemanager';
00231	              // MLK add profile-menu here, then "Else if"
00232	              if (bXboxStartup && xboxLive.IsLoggedIn(xboxLive.GetCurrentUser()))
00233	              {
00234	                OpenMenu("XIDInterf.XIIIMenuLiveStartup");
00235	                bXboxStartup = false;
00236	              }
00237	              //else if (bProfileMenu)
00238	              //  OpenMenu("XIDInterf.XIIIMenuProfileClient");
00239	              else if (bIamInMulti)
00240	              {
00241	                if (xboxLive.IsLoggedIn(xboxLive.GetCurrentUser()) )
00242	                  OpenMenu("XIDInterf.XIIIMenuInGameXboxLive");
00243	                else
00244	                  OpenMenu("XIDInterf.XIIIMenuInGameMulti");
00245	              }
00246	          }
00247	        }
00248	    }
00249	    
00250	
00251	    event CloseAll(bool bCancel)
00252	    {
00253	        local int i;
00254	
00255	        if (bMapMenu)           // only save the menu stack in the main menu !
00256	        {
00257	            SaveMenuStack = new(none) class'XIIISaveMenuStack';
00258	            
00259	            for (i=0;i<MenuStack.Length;i++)
00260	            {
00261	                if (MenuStack[i].bDoStoreInSaveMenuStack)
00262	                {
00263	                    SaveMenuStack.AddMenu(MenuStack[i].GetPageParameters());
00264	                }
00265	            }
00266	          }
00267	
00268	        Super.CloseAll(bCancel);
00269	     }
00270	
00271	
00272	     function EndState()
00273	     {
00274	         log("END STATE: "$self);
00275	          //CloseAll(true);
00276	          XIIIPlayerController(GetPlayerOwner()).bMenuIsActive = false;
00277	          if (bMapMenu)
00278	          {
00279	            XIIIConsole(Master.GlobalInteractions[0]).bMapMenu = false;
00280	            bMapMenu = false;
00281	          }
00282	          bIamInGame = false;
00283	          bIamInMulti = false;
00284	          if ( ViewportOwner.Actor.Level.Pauser!=none )
00285	              GetPlayerOwner().ResumeAllSounds();
00286	          if ( ( GetLevel().Game.NumPlayers == 1 ) && ( GetLevel().NetMode == 0) )
00287	              ViewportOwner.Actor.SetPause( false );
00288	          else
00289	              ViewportOwner.Actor.bIsInMenu=false;
00290	          Super.EndState();
00291	     }
00292	
00293	}
00294	
00295	
00296	final function PlayerController GetPlayerOwner()
00297	{
00298	        return ViewportOwner.Actor;
00299	}
00300	
00301	final function LevelInfo GetLevel()
00302	{
00303	        return ViewportOwner.Actor.Level;
00304	}
00305	
00306	
00307	function Printf(canvas C, string text, float x, float y, int maxlen)
00308	{
00309	     local string temp;
00310	     local float XS, YS;
00311	     local int maxchar, i;
00312	//     local color blackcolor, oldcolor;
00313	
00314	//     blackcolor.R = 0; blackcolor.G = 0; blackcolor.B = 0; blackcolor.A = 255;
00315	//temp     C.Font = Fonts[F_Normal];
00316	     C.StrLen("A", XS, YS);
00317	     maxchar = (maxlen/XS) + 12;//14
00318	     text = Caps(Text);
00319	     while (text != "")
00320	     {
00321	          C.SetPos(x,y);
00322	          temp = left(text, maxchar); y += YS;
00323	          text = mid(text, maxchar);
00324	
00325	          // MLK: draw full line if a blank char encountered -- empty line quits
00326	          if ((text == "") || (left(text, 1) == " ") || (right(temp, 1) == " "))
00327	          {
00328	//               oldcolor = C.DrawColor; C.SetPos(x+1,y+1);
00329	               C.DrawText(temp, false);
00330	//               C.DrawColor = blackcolor; C.DrawText(temp, false); C.DrawColor = oldcolor;
00331	          }
00332	          else
00333	          {
00334	               i = maxchar;
00335	               // MLK: Cut the last word and paste to the processed text
00336	               while( left(mid(temp, i), 1) != " ")
00337	                    i--;
00338	               text = right(temp, maxchar-i-1)$text;
00339	               temp = left(temp, i);
00340	               C.DrawText(temp, false);
00341	          }
00342	     }
00343	}
00344	
00345	
00346	final function DrawStretchedTexture( Canvas C, float X, float Y, float W, float H, texture Tex )
00347	{
00348	        local float OrgX, OrgY, ClipX, ClipY, tW, tH;
00349	
00350	    tW = Tex.USize; tH = Tex.VSize;
00351	        OrgX = C.OrgX;
00352	        OrgY = C.OrgY;
00353	        ClipX = C.ClipX;
00354	        ClipY = C.ClipY;
00355	
00356	//      C.SetOrigin(OrgX + ClipX*GUIScale, OrgY + ClippingRegion.Y*GUIScale);
00357	//      C.SetClip(ClippingRegion.W*GUIScale, ClippingRegion.H*GUIScale);
00358	
00359	        C.SetPos(X, Y);//(X - ClippingRegion.X)*GUIScale, (Y - ClippingRegion.Y)*GUIScale);
00360	        C.DrawTileClipped( Tex, W*GUIScale, H*GUIScale, 0, 0, tW, tH);
00361	
00362	        C.SetClip(ClipX, ClipY);
00363	        C.SetOrigin(OrgX, OrgY);
00364	}
00365	
00366	function SetControllerStatus(bool On)
00367	{	// idem GUIController.uc but the requiresTick variable is set to true all the time
00368	
00369		bActive = On;
00370		bVisible = On;
00371	//	bRequiresTick=On;
00372		bRequiresTick=true;
00373	
00374		// Attempt to Pause as well as show the windows mouse cursor.
00375		ViewportOwner.bShowWindowsMouse=On;
00376	
00377		// Add code to pause/unpause/hide/etc the game here.
00378		if (On)
00379			bIgnoreUntilPress = true;
00380		else
00381			ViewportOwner.Actor.ConsoleCommand("toggleime 0");
00382	}
00383	
00384	
00385	
00386	
00387	defaultproperties
00388	{
00389	     sFondMenu="XIIIMenuStart.menublanc"
00390	     sFondNoir="XIIIMenuStart.menunoir"
00391	     BlackColor=(A=255)
00392	     FilterColor=(B=255,G=255,R=255)
00393	     bFirstTime=True
00394	     GUIScale=1.000000
00395	     FontStack(0)=GUISmallFont'GUI.GUIController.GUI_SmallFont'
00396	     FontStack(1)=GUIBigFont'GUI.GUIController.GUI_BigFont'
00397	     StyleNames(0)="GUI.STY_SquareButton"
00398	     StyleNames(1)="GUI.STY_Listbox"
00399	     StyleNames(2)="GUI.STY_NoAlphaButton"
00400	     StyleNames(3)="GUI.STY_ScaleButton"
00401	     StyleNames(4)="GUI.STY_Label"
00402	     StyleNames(5)="GUI.STY_LabelWhite"
00403	     StyleNames(6)="GUI.STY_MsgBoxButton"
00404	     MouseCursors(0)=Texture'XIIIMenuStart.MouseCursorM'
00405	}

End Source Code