Changeset 83


Ignore:
Timestamp:
May 17, 2024, 4:52:24 PM (6 months ago)
Author:
chronos
Message:
  • Modified: Use F10 as exit according to the original game.
  • Modified: Better menu items drawing.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Engine.pas

    r80 r83  
    207207    FBitmap: TBitmap;
    208208    FBitmapLock: TCriticalSection;
     209    FOnClose: TNotifyEvent;
    209210    FOnGameEnd: TNotifyEvent;
    210211    FRedrawPending: Boolean;
     
    232233    procedure DrawMap;
    233234    procedure SetState(AValue: TGameState);
     235    procedure ShowMenuItem(Key, Text: string; X, Y: Integer; Canvas: TCanvas);
    234236    function TextOutWordWrap(Canvas: TCanvas; X, Y: Integer; Text: string; Width: Integer): Integer;
    235237  public
     
    264266    property State: TGameState read FState write SetState;
    265267    property OnGameEnd: TNotifyEvent read FOnGameEnd write FOnGameEnd;
     268    property OnClose: TNotifyEvent read FOnClose write FOnClose;
    266269  end;
    267270
     
    16111614end;
    16121615
     1616procedure TEngine.ShowMenuItem(Key, Text: string; X, Y: Integer; Canvas: TCanvas);
     1617begin
     1618  Canvas.TextOut(X, Y, '<' + Key + '>');
     1619  Canvas.TextOut(X + 140, Y, Text);
     1620end;
     1621
    16131622procedure TEngine.DrawMenu;
    16141623var
     
    16441653    Font.Color := clPurple;
    16451654    Font.Size := 20;
    1646     Text := '<F1>  ' + SStartGame;
    1647     TextOut((MenuWidth - TextWidth(Text)) div 2, Bitmap.Height div 10 * 4, Text);
    1648     Text := '<F2>  ' + SInstructions;
    1649     TextOut((MenuWidth - TextWidth(Text)) div 2, Bitmap.Height div 10 * 4 + 40, Text);
    1650     Text := '<F3>  ' + SInformation;
    1651     TextOut((MenuWidth - TextWidth(Text)) div 2, Bitmap.Height div 10 * 4 + 80, Text);
    1652     Text := '<Alt+F4>  ' + SExit;
    1653     TextOut((MenuWidth - TextWidth(Text)) div 2, Bitmap.Height div 10 * 4 + 120, Text);
     1655
     1656    ShowMenuItem('F1', SStartGame, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4, Bitmap.Canvas);
     1657    ShowMenuItem('F2', SInstructions, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 40, Bitmap.Canvas);
     1658    ShowMenuItem('F3', SInformation, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 80, Bitmap.Canvas);
     1659    ShowMenuItem('F10', SExit, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 120, Bitmap.Canvas);
    16541660
    16551661    Font.Color := clDarkGreen;
     
    19471953  KeyF3 = 114;
    19481954  KeyF4 = 115;
     1955  KeyF10 = 121;
    19491956  KeyEsc = 27;
    19501957var
     
    19631970    if Key = KeyF3 then begin
    19641971      State := gsInformation;
     1972    end else
     1973    if Key = KeyF10 then begin
     1974      if Assigned(FOnClose) then FOnClose(Self);
    19651975    end;
    19661976  end else
  • trunk/Forms/FormMain.lfm

    r74 r83  
    55  Width = 770
    66  Caption = 'Tunneler'
    7   ClientHeight = 583
     7  ClientHeight = 617
    88  ClientWidth = 770
    99  DesignTimePPI = 144
     
    1616  OnKeyUp = FormKeyUp
    1717  OnShow = FormShow
    18   LCLVersion = '2.2.4.0'
     18  LCLVersion = '3.2.0.0'
    1919  object StatusBar1: TStatusBar
    2020    Left = 0
    2121    Height = 28
    22     Top = 555
     22    Top = 589
    2323    Width = 770
    24     Panels = <
     24    Panels = <   
    2525      item
    2626        Width = 74
    27       end
     27      end   
    2828      item
    2929        Width = 74
    30       end
     30      end   
    3131      item
    3232        Width = 74
    33       end
     33      end   
    3434      item
    3535        Width = 74
    36       end
     36      end   
    3737      item
    3838        Width = 74
    39       end
     39      end   
    4040      item
    4141        Width = 74
    42       end
     42      end   
    4343      item
    4444        Width = 74
     
    5050  object Image1: TImage
    5151    Left = 0
    52     Height = 555
     52    Height = 589
    5353    Top = 0
    5454    Width = 770
     
    109109      Caption = 'Exit'
    110110      OnExecute = AExitExecute
    111       ShortCut = 32883
     111      ShortCut = 121
    112112    end
    113113    object ANewGame: TAction
  • trunk/Forms/FormMain.pas

    r74 r83  
    183183  DoubleBuffered := False;
    184184  Engine := TEngine.Create(nil);
     185  Engine.OnClose := AExitExecute;
    185186  LoadConfig;
    186187  Engine.InitPlayerPool;
Note: See TracChangeset for help on using the changeset viewer.