Changeset 83 for trunk/Engine.pas


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.
File:
1 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
Note: See TracChangeset for help on using the changeset viewer.