Advertisement
Guest User

My Example Main Menu

a guest
May 16th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //------------------------------------------------------------------------------
  2. // Main Menu where all the fancy stuff takes place.
  3. //------------------------------------------------------------------------------
  4. class MyMainMenuScene extends GUIMenuScene;
  5.  
  6. event InitMenuScene()
  7. {
  8.     FindComponentByTag("TitleBackground").OnMouseReleased = TitleBackgroundEvent;
  9.     FindComponentByTag("BackToTitleButton").OnMouseReleased = BackToTitleButtonEvent;
  10.     FindComponentByTag("StartButton").OnMouseReleased = StartButtonEvent;
  11.  
  12.     super.InitMenuScene();
  13. }
  14.  
  15.  
  16. // Override the mouse cursor function. The reason is that our cursor texture is
  17. // large and should point at it's middle rather than using the top-left corner.
  18. function DrawCursor(Canvas C, float PosX, float PosY, optional bool bHasSelection)
  19. {
  20.     C.SetPos(PosX - OwnerHUD.RatioX * (CursorTexture.SizeX/2), PosY - OwnerHUD.RatioX * (CursorTexture.SizeX/2));
  21.  
  22.     if (bHasSelection)
  23.     {
  24.         // Set the cursor color
  25.         C.DrawColor = SelectionCursorColor;
  26.         // Draw the texture on the screen
  27.         C.DrawTile(SelectionCursorTexture, SelectionCursorTexture.SizeX, SelectionCursorTexture.SizeY,
  28.                    0.f, 0.f, SelectionCursorTexture.SizeX, SelectionCursorTexture.SizeY,, true);
  29.     }
  30.     else
  31.     {
  32.         // Set the cursor color
  33.         C.DrawColor = CursorColor;
  34.         // Draw the texture on the screen
  35.         C.DrawTile(CursorTexture, OwnerHUD.RatioX * CursorTexture.SizeX, OwnerHUD.RatioX * CursorTexture.SizeY,
  36.                    0.f, 0.f, CursorTexture.SizeX, CursorTexture.SizeY,, true);
  37.     }
  38. }
  39.  
  40.  
  41. // Go from Title screen to the next one.
  42. function TitleBackgroundEvent(optional GUIComponent Component, optional byte ButtonNum)
  43. {
  44.     FindComponentByTag("CharSelContainer").bEnabled = True;
  45.     FindComponentByTag("TitleContainer").bEnabled = False;
  46. }
  47.  
  48. // Go from Char Select screen back to title.
  49. function BackToTitleButtonEvent(optional GUIComponent Component, optional byte ButtonNum)
  50. {
  51.     FindComponentByTag("TitleContainer").bEnabled = True;
  52.     FindComponentByTag("CharSelContainer").bEnabled = False;
  53. }
  54.  
  55. // Start the actual game map.
  56. function StartButtonEvent(optional GUIComponent Component, optional byte ButtonNum)
  57. {
  58.     FindComponentByTag("StartButton").OnMouseReleased = None; // Need to release this delegate first to prevent an app crash.
  59.     ConsoleCommand("open MyMap");
  60. }
  61.  
  62. DefaultProperties
  63. {
  64.     bDrawGUIComponents = True
  65.     bCaptureMouseInput = True
  66.     CursorTexture = Texture2D'MyUI.HUD.AimCrossred'
  67.     SelectionCursorTexture = Texture2D'MyUI.HUD.AimCrossred'
  68.  
  69.  
  70.     // A GUI page for the Title screen.
  71.     Begin Object class=GUIContainerComponent Name=TitleScreen
  72.         Tag = "TitleContainer"
  73.         PosX = 0.0
  74.         PosY = 0.0
  75.         PosXEnd = 1.0
  76.         PosYEnd = 1.0
  77.  
  78.         // Make the background image a button to capture a mouse input everywhere on the screen.
  79.         Begin Object class=GUIButtonComponent Name=TitleBackgroundImage
  80.             Tag = "TitleBackground"
  81.             PosX = 0.0
  82.             PosY = 0.0
  83.             PosXEnd = 1.0
  84.             PosYEnd = 1.0
  85.             bDrawCaption = False
  86.  
  87.             bForceNormalDrawInfo = True
  88.             bForceNormalCaptionInfo = True
  89.  
  90.             // button is simply drawn normal
  91.             DrawInfo(0) = (ComponentTexture=Texture2D'MyUI.TitleScreen.Titelscreen', SubUVEnd=(X=2048,Y=2048), bStretchHorizontally=false, bStretchVertically=false)
  92.         End Object
  93.         ChildComponents.Add(TitleBackgroundImage)
  94.  
  95.         // With the huge title screen button, we no longer need an actual button element for this, so make it a VisualComponent instead.
  96.         Begin Object class=GUIVisualComponent Name=TitleConfirmButton
  97.             Tag = "TitleConfirmButton"
  98.             PosX = 0.35
  99.             PosY = 0.74
  100.             PosXEnd = 0.6
  101.             PosYEnd = 0.8
  102.  
  103.             // button is simply drawn normal
  104.             DrawInfo(0) = (ComponentTexture=Texture2D'MyUI.TitleScreen.PressStart', SubUVEnd=(X=1024,Y=128), bStretchHorizontally=false, bStretchVertically=false)
  105.         End Object
  106.         ChildComponents.Add(TitleConfirmButton)
  107.  
  108.     End Object
  109.     GUIComponents.Add(TitleScreen)
  110.  
  111.  
  112.  
  113.     // A GUI page for the Character Selection screen.
  114.     Begin Object class=GUIContainerComponent Name=CharSelectScreen
  115.         Tag = "CharSelContainer"
  116.         PosX = 0.0
  117.         PosY = 0.0
  118.         PosXEnd = 1.0
  119.         PosYEnd = 1.0
  120.         bEnabled = False
  121.  
  122.         Begin Object class=GUIVisualComponent Name=CharBackgroundImage
  123.             Tag = "CharBackground"
  124.             PosX = 0.0
  125.             PosY = 0.0
  126.             PosXEnd = 1.0
  127.             PosYEnd = 1.0
  128.  
  129.             bForceNormalDrawInfo = True
  130.  
  131.             // button is simply drawn normal
  132.             DrawInfo(0) = (ComponentTexture=Texture2D'MyUI.CharacterScreen.CharselectBG', SubUVEnd=(X=2048,Y=2048), bStretchHorizontally=false, bStretchVertically=false)
  133.         End Object
  134.         ChildComponents.Add(CharBackgroundImage)
  135.  
  136.  
  137.         Begin Object class=GUIButtonComponent Name=PreviousButton
  138.             Tag = "PreviousButton"
  139.             PosX = 0.24
  140.             PosY = 0.37
  141.             PosXEnd = 0.31
  142.             PosYEnd = 0.42
  143.             bDrawCaption = False
  144.  
  145.             bForceNormalDrawInfo = True
  146.             bForceNormalCaptionInfo = True
  147.  
  148.             // button is simply drawn normal
  149.             DrawInfo(0) = (ComponentTexture=Texture2D'MyUI.CharacterScreen.backbutton', SubUVEnd=(X=256,Y=64), bStretchHorizontally=false, bStretchVertically=false)
  150.         End Object
  151.         ChildComponents.Add(PreviousButton)
  152.  
  153.  
  154.         Begin Object class=GUIButtonComponent Name=NextButton
  155.             Tag = "NextButton"
  156.             PosX = 0.687
  157.             PosY = 0.37
  158.             PosXEnd = 0.757
  159.             PosYEnd = 0.42
  160.             bDrawCaption = False
  161.  
  162.             bForceNormalDrawInfo = True
  163.             bForceNormalCaptionInfo = True
  164.  
  165.             // button is simply drawn normal
  166.             DrawInfo(0) = (ComponentTexture=Texture2D'MyUI.CharacterScreen.NextButton', SubUVEnd=(X=256,Y=64), bStretchHorizontally=false, bStretchVertically=false)
  167.         End Object
  168.         ChildComponents.Add(NextButton)
  169.  
  170.  
  171.         Begin Object class=GUIButtonComponent Name=StartButton
  172.             Tag = "StartButton"
  173.             PosX = 0.36
  174.             PosY = 0.744
  175.             PosXEnd = 0.59
  176.             PosYEnd = 0.79
  177.             bDrawCaption = False
  178.  
  179.             bForceNormalDrawInfo = True
  180.             bForceNormalCaptionInfo = True
  181.  
  182.             // button is simply drawn normal
  183.             DrawInfo(0) = (ComponentTexture=Texture2D'MyUI.CharacterScreen.enterlevel', SubUVEnd=(X=512,Y=64), bStretchHorizontally=false, bStretchVertically=false)
  184.         End Object
  185.         ChildComponents.Add(StartButton)
  186.  
  187.  
  188.         Begin Object class=GUIButtonComponent Name=BackToTitleButton
  189.             Tag = "BackToTitleButton"
  190.             PosX = 0.635
  191.             PosY = 0.11
  192.             PosXEnd = 0.76
  193.             PosYEnd = 0.136
  194.             bDrawCaption = False
  195.  
  196.             bForceNormalDrawInfo = True
  197.             bForceNormalCaptionInfo = True
  198.  
  199.             // button is simply drawn normal
  200.             DrawInfo(0) = (ComponentTexture=Texture2D'MyUI.CharacterScreen.backtotitle', SubUVEnd=(X=256,Y=32), bStretchHorizontally=false, bStretchVertically=false)
  201.         End Object
  202.         ChildComponents.Add(BackToTitleButton)
  203.  
  204.     End Object
  205.     GUIComponents.Add(CharSelectScreen)
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement