Changeset 6 for trunk/UMainForm.pas


Ignore:
Timestamp:
Mar 6, 2011, 7:31:53 PM (14 years ago)
Author:
george
Message:
  • Added: Fullscreen mode.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMainForm.pas

    r4 r6  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    9   ComCtrls, Menus, UCore;
     9  ComCtrls, Menus, ActnList, UCore;
    1010
    1111type
     
    1414
    1515  TMainForm = class(TForm)
     16    AShowMap: TAction;
     17    ANewGame: TAction;
     18    AExit: TAction;
     19    AFullScreen: TAction;
     20    ActionList1: TActionList;
    1621    Image1: TImage;
    1722    MainMenu1: TMainMenu;
     
    1924    MenuItem2: TMenuItem;
    2025    MenuItem3: TMenuItem;
    21     MenuItemShowMap: TMenuItem;
     26    MenuItem4: TMenuItem;
     27    MenuItem5: TMenuItem;
     28    MenuItem6: TMenuItem;
    2229    StatusBar1: TStatusBar;
    2330    TimerDraw: TTimer;
    2431    TimerEngineTick: TTimer;
     32    procedure AExitExecute(Sender: TObject);
     33    procedure AFullScreenExecute(Sender: TObject);
     34    procedure ANewGameExecute(Sender: TObject);
     35    procedure AShowMapExecute(Sender: TObject);
    2536    procedure FormCreate(Sender: TObject);
    2637    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
     
    2839    procedure FormShow(Sender: TObject);
    2940    procedure Image1Resize(Sender: TObject);
    30     procedure MenuItem2Click(Sender: TObject);
    31     procedure MenuItem3Click(Sender: TObject);
    32     procedure MenuItemShowMapClick(Sender: TObject);
    3341    procedure TimerDrawTimer(Sender: TObject);
    3442    procedure TimerEngineTickTimer(Sender: TObject);
    3543  private
     44    OriginalBounds: TRect;
     45    OriginalWindowState: TWindowState;
     46    ScreenBounds: TRect;
    3647  public
    3748    { public declarations }
     
    106117end;
    107118
     119procedure TMainForm.AFullScreenExecute(Sender: TObject);
     120begin
     121  if BorderStyle <> bsNone then begin
     122    // To full screen
     123    OriginalWindowState := WindowState;
     124    OriginalBounds := BoundsRect;
     125
     126    BorderStyle := bsNone;
     127    ScreenBounds := Screen.MonitorFromWindow(Handle).BoundsRect;
     128    with ScreenBounds do
     129      SetBounds(Left, Top, Right - Left, Bottom - Top) ;
     130  end else begin
     131    // From full screen
     132    {$IFDEF MSWINDOWS}
     133    BorderStyle := bsSizeable;
     134    {$ENDIF}
     135    if OriginalWindowState = wsMaximized then
     136      WindowState := wsMaximized
     137    else
     138      with OriginalBounds do
     139        SetBounds(Left, Top, Right - Left, Bottom - Top) ;
     140    {$IFDEF LINUX}
     141    BorderStyle := bsSizeable;
     142    {$ENDIF}
     143  end;
     144end;
     145
     146procedure TMainForm.ANewGameExecute(Sender: TObject);
     147begin
     148  Engine.NewGame;
     149end;
     150
     151procedure TMainForm.AShowMapExecute(Sender: TObject);
     152begin
     153  MapForm.Show;
     154end;
     155
     156procedure TMainForm.AExitExecute(Sender: TObject);
     157begin
     158  Close;
     159end;
     160
    108161procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
    109162  Shift: TShiftState);
     
    129182end;
    130183
    131 procedure TMainForm.MenuItem2Click(Sender: TObject);
    132 begin
    133   Close;
    134 end;
    135 
    136 procedure TMainForm.MenuItem3Click(Sender: TObject);
    137 begin
    138   Engine.NewGame;
    139 end;
    140 
    141 procedure TMainForm.MenuItemShowMapClick(Sender: TObject);
    142 begin
    143   MapForm.Show;
    144 end;
    145 
    146184end.
    147185
Note: See TracChangeset for help on using the changeset viewer.