home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / GUI / Classes / GUIPage.uc < prev    next >
Text File  |  2003-06-30  |  5KB  |  210 lines

  1. // ====================================================================
  2. //  Class:  GUI.GUIPage
  3. //
  4. //    GUIPages are the base for a full page menu.  They contain the
  5. //    Control stack for the page.
  6. //
  7. //  Written by Joe Wilcox
  8. //  (c) 2002, Epic Games, Inc.  All Rights Reserved
  9. // ====================================================================
  10.  
  11. class GUIPage extends GUIMultiComponent
  12.     Native     Abstract;
  13.  
  14. cpptext
  15. {
  16.         void Draw(UCanvas* Canvas);
  17.         UBOOL NativeKeyEvent(BYTE& iKey, BYTE& State, FLOAT Delta );
  18.         void UpdateTimers(float DeltaTime);
  19.         UBOOL PerformHitTest(INT MouseX, INT MouseY);
  20.         UBOOL MousePressed(UBOOL IsRepeat);                    // The Mouse was pressed
  21.         UBOOL MouseReleased();                                // The Mouse was released
  22.  
  23.         UBOOL XControllerEvent(int Id, eXControllerCodes iCode);
  24.  
  25. }
  26.  
  27. // Variables
  28.  
  29. var(Menu)                       Material                Background;            // The background image for the menu
  30. var(Menu)                        Color                    BackgroundColor;    // The color of the background
  31. var(Menu)                        Color                    InactiveFadeColor;    // Color Modulation for Inactive Page
  32. var(Menu)                        EMenuRenderStyle        BackgroundRStyle;
  33. var(Menu)                        bool                    bRenderWorld;        // Should this menu hide the world
  34. var(Menu)                        bool                    bPauseIfPossible;    // Should this menu pause the game if possible
  35. var(Menu)                        bool                    bCheckResolution;    // If true, the menu will be force to run at least 640x480
  36. var(Menu)                        Sound                    OpenSound;            // Sound to play when opened
  37. var(Menu)                        Sound                    CloseSound;            // Sound to play when closed
  38.  
  39.  
  40. var                                bool                    bRequire640x480;    // Does this menu require at least 640x480
  41. var                                bool                    bPersistent;        // If set in defprops, page is saved across open/close/reopen.
  42.  
  43. var                                GUIPage                    ParentPage;            // The page that exists before this one
  44. var    const                        array<GUIComponent>        Timers;                // List of components with Active Timers
  45. var                             bool                    bAllowedAsLast;        // If this is true, closing this page will not bring up the main menu
  46.                                                                             // if last on the stack.
  47.  
  48. var                                bool                    bDisconnectOnOpen;    // Should this menu for a disconnect when opened.
  49.  
  50.  
  51. // Delegates
  52.  
  53. delegate OnOpen()
  54. {
  55.     PageLoadINI();
  56. }
  57.  
  58. delegate bool OnCanClose(optional Bool bCancelled)
  59. {
  60.     return true;
  61. }
  62.  
  63. delegate OnClose(optional Bool bCancelled)
  64. {
  65.     if (!bCancelled)
  66.         PageSaveINI();
  67. }
  68.  
  69. event Opened(GUIComponent Sender)
  70. {
  71.     Super.Opened(Sender);
  72.     OnOpen();
  73. }
  74.  
  75. event Closed(GUIComponent Sender, bool bCancelled)
  76. {
  77.     Super.Closed(Sender, bCancelled);
  78.     OnClose(bCancelled);
  79. }
  80.  
  81.  
  82. function PageLoadINI()
  83. {
  84.     local int i;
  85.  
  86.     for (i=0;i<Controls.Length;i++)
  87.         Controls[i].LoadINI();
  88.  
  89.     return;
  90. }
  91.  
  92. function PageSaveINI()
  93. {
  94.     local int i;
  95.  
  96.     for (i=0;i<Controls.Length;i++)
  97.         Controls[i].SaveINI("");
  98. }
  99.  
  100. //=================================================
  101. // PlayOpenSound / PlayerClosedSound
  102.  
  103. function PlayOpenSound()
  104. {
  105.     PlayerOwner().PlayOwnedSound(OpenSound,SLOT_Interface,1.0);
  106. }
  107.  
  108. function PlayCloseSound()
  109. {
  110.     PlayerOwner().PlayOwnedSound(CloseSound,SLOT_Interface,1.0);
  111. }
  112.  
  113.  
  114. //=================================================
  115. // InitComponent is responsible for initializing all components on the page.
  116.  
  117. function InitComponent(GUIController MyController, GUIComponent MyOwner)
  118. {
  119.     Super.Initcomponent(MyController, MyOwner);
  120.  
  121.     MapControls();        // Figure out links
  122.  
  123.     FocusFirst(none);
  124. }
  125.  
  126. //=================================================
  127. // CheckResolution - Tests to see if this menu requires a resoltuion of at least 640x480 and if so, switches
  128.  
  129. function CheckResolution(bool Closing)
  130. {
  131.     local string CurrentRes;
  132.     local int I,X,Y;
  133.  
  134.     if (!Closing)
  135.     {
  136.         CurrentRes = PlayerOwner().ConsoleCommand( "GETCURRENTRES" );
  137.         I = InStr( CurrentRes, "x" );
  138.         if( i > 0 )
  139.         {
  140.             X = int( Left ( CurrentRes, i )  );
  141.             Y = int( Mid( CurrentRes, i+1 ) );
  142.         }
  143.         else
  144.         {
  145.             log("Couldn't parse GetCurrentRes call");
  146.             return;
  147.         }
  148.         if ( ( (x<640) || (y<480) ) && (bRequire640x480) )
  149.         {
  150.             Controller.GameResolution = CurrentRes;
  151.             PlayerOwner().ConsoleCommand("TEMPSETRES 640x480");
  152.         }
  153.  
  154.         return;
  155.  
  156.     }
  157.  
  158.     if ( (bRequire640x480) || (Controller.GameResolution=="") )
  159.         return;
  160.  
  161.     CurrentRes = PlayerOwner().ConsoleCommand( "GETCURRENTRES" );
  162.     if (CurrentRes != Controller.GameResolution)
  163.     {
  164.         PlayerOwner().Player.Console.ConsoleCommand("SETRES"@Controller.GameResolution);
  165.         Controller.GameResolution = "";
  166.     }
  167.  
  168. }
  169.  
  170. event ChangeHint(string NewHint)
  171. {
  172.     Hint = NewHint;
  173. }
  174.  
  175. event MenuStateChange(eMenuState Newstate)
  176. {
  177.     Super(GUIComponent).MenuStateChange(NewState);    // Skip the Multicomp's state change
  178. }
  179.  
  180. event SetFocus(GUIComponent Who)
  181. {
  182.     if (Who==None)
  183.         return;
  184.  
  185.     Super.SetFocus(Who);
  186. }
  187.  
  188. event HandleParameters(string Param1, string Param2);    // Should be subclassed
  189. event NotifyLevelChange();
  190.  
  191. event Free()             // This control is no longer needed
  192. {
  193.     local int i;
  194.     for (i=0;i<Timers.Length;i++)
  195.         Timers[i]=None;
  196.  
  197.     Super.Free();
  198. }
  199.  
  200.  
  201. defaultproperties
  202. {
  203.     bAcceptsInput=true
  204.     InactiveFadeColor=(R=128,G=128,B=128,A=255)
  205.     BackgroundColor=(R=255,G=255,B=255,A=255)
  206.     BackgroundRStyle=MSTY_Normal
  207.     bRequire640x480=true
  208.     bPersistent=false
  209.     bTabStop=false
  210. }