home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Glypha II 1.21 / source / Code ƒ / I-Menus.p < prev    next >
Encoding:
Text File  |  1991-05-23  |  2.7 KB  |  138 lines  |  [TEXT/PJMM]

  1. unit Menus;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Palettes, Sound, Globals, AboutWndo, Dialogs, GameUtils, Enemies, GlyphaGuts, Initialize;
  7.  
  8.     procedure Handle_My_Menu (theMenu, theItem: integer; var theInput: TEHandle);
  9.  
  10. {===================================}
  11.  
  12. implementation
  13.  
  14.     procedure DoPause;
  15.     begin
  16.         pausing := not pausing;
  17.     end;
  18.  
  19. {===================================}
  20.  
  21.     procedure DoQuit;
  22.     begin
  23.         if (playing) then
  24.             begin
  25.                 if (YesNoAlert(2)) then
  26.                     begin
  27.                         playing := FALSE;
  28.                         pausing := FALSE;
  29.                         doneFlag := TRUE;
  30.                         InitCursor;
  31.                     end
  32.                 else
  33.                     Exit(DoQuit);
  34.             end
  35.         else
  36.             begin
  37.                 doneFlag := TRUE;
  38.                 InitCursor;
  39.             end;
  40.     end;
  41.  
  42. {===================================}
  43.  
  44.     procedure DoBegin;
  45.     begin
  46.         if (pausing) then
  47.             DoPause
  48.         else if (not playing) then
  49.             begin
  50.                 playing := TRUE;
  51.                 levelOn := levelStart - 1;
  52.                 mortals := mortalsStart;
  53.                 score := 0;
  54.                 oldScore := 0;
  55.                 gameCycle := 0;
  56.                 nextMortal := newMortalPts;
  57.                 HideCursor;
  58.                 AdvanceALevel;
  59.                 EnterANewMortal;
  60.                 ShowScore;
  61.                 ShowLevel;
  62.                 ShowMortals;
  63.  
  64.                 DisableItem(GetMenu(mGame), iBegin);
  65.                 EnableItem(GetMenu(mGame), iPause);
  66.                 EnableItem(GetMenu(mGame), iEnd);
  67.             end;
  68.     end;
  69.  
  70. {===================================}
  71.  
  72.     procedure Handle_My_Menu;               {Handle menu selections realtime}
  73.         var
  74.             DNA, index: integer;        {For opening DAs}
  75.             BoolHolder: boolean;        {For SystemEdit result}
  76.             DAName: Str255;                    {For getting DA name}
  77.             SavePort: GrafPtr;            {Save current port when opening DAs}
  78.  
  79.     begin
  80.         case theMenu of          {Do selected menu list}
  81.             mApple: 
  82.                 begin
  83.                     case theItem of    {Handle all commands in this menu list}
  84.                         0: 
  85.                             ;
  86.                         iAbout: 
  87.                             AboutUs;
  88.                         otherwise                {Handle the DAs}
  89.                             begin
  90.                                 GetPort(GrafPtr(SavePort));
  91.                                 GetItem(GetMenu(mApple), theItem, DAName);
  92.                                 DNA := OpenDeskAcc(DAName);
  93.                                 SetPort(GrafPtr(SavePort));
  94.                             end;
  95.                     end;                    {End of item case}
  96.                 end;                        {End for this list}
  97.  
  98.             mGame: 
  99.                 begin
  100.                     case theItem of
  101.                         iBegin: 
  102.                             DoBegin;
  103.                         iPause: 
  104.                             DoPause;
  105.                         iEnd: 
  106.                             DoEnd;
  107.                         iQuit: 
  108.                             DoQuit;
  109.                         otherwise
  110.                     end;                    {End of item case}
  111.                 end;                        {End for this list}
  112.  
  113.             mOptions: 
  114.                 begin
  115.                     case theItem of
  116.                         iConfigure_Game: 
  117.                             ConfigureGame;
  118.                         iConfigure_Controls: 
  119.                             ControlDialog(keyboardControl);
  120.                         iHelp: 
  121.                             if (not playing) then
  122.                                 DoHelpScreen;
  123.                         iClear_HiScores: 
  124.                             if (YesNoAlert(1)) then
  125.                                 FlushTheScores;
  126.                         otherwise
  127.                     end;                {End of item case}
  128.                 end;                    {End for this list}
  129.  
  130.             otherwise
  131.         end;                            {End for lists}
  132.  
  133.         HiliteMenu(0);        {Turn menu selection off}
  134.     end;                                {End of procedure Handle_My_Menu    }
  135.  
  136. {===================================}
  137.  
  138. end.