Changeset 63 for trunk/Forms


Ignore:
Timestamp:
Nov 26, 2020, 1:18:19 PM (4 years ago)
Author:
chronos
Message:
  • Added: Support for full screen mode.
Location:
trunk/Forms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r62 r63  
    88  ClientWidth = 1276
    99  DesignTimePPI = 144
     10  OnActivate = FormActivate
     11  OnClose = FormClose
    1012  OnCreate = FormCreate
    1113  OnDestroy = FormDestroy
    1214  OnKeyPress = FormKeyPress
     15  OnKeyUp = FormKeyUp
    1316  OnShow = FormShow
    1417  LCLVersion = '2.0.10.0'
    15   WindowState = wsMaximized
    1618  object PaintBox1: TPaintBox
    1719    Left = 0
     
    5759    Top = 460
    5860  end
     61  object PersistentForm1: TPersistentForm
     62    MinVisiblePart = 50
     63    EntireVisible = False
     64    Left = 488
     65    Top = 536
     66  end
    5967end
  • trunk/Forms/UFormMain.pas

    r62 r63  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
    9   ExtCtrls, UEngine, LCLType, types, UTranslator, UApplicationInfo, URegistry;
     9  ExtCtrls, UEngine, LCLType, types, UTranslator, UApplicationInfo, URegistry,
     10  UPersistentForm;
    1011
    1112type
     
    1617    ApplicationInfo1: TApplicationInfo;
    1718    PaintBox1: TPaintBox;
     19    PersistentForm1: TPersistentForm;
    1820    Timer1: TTimer;
    1921    Translator1: TTranslator;
     22    procedure FormActivate(Sender: TObject);
     23    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2024    procedure FormCreate(Sender: TObject);
    2125    procedure FormDestroy(Sender: TObject);
    2226    procedure FormKeyPress(Sender: TObject; var Key: char);
     27    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    2328    procedure FormShow(Sender: TObject);
    2429    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
     
    3641    procedure Timer1Timer(Sender: TObject);
    3742  private
     43    Initialized: Boolean;
    3844    procedure LoadConfig;
    3945    procedure SaveConfig;
    4046  public
     47    FullScreen: Boolean;
    4148    Engine: TEngine;
    4249    procedure EraseBackground(DC: HDC); override;
     
    4552var
    4653  FormMain: TFormMain;
     54
    4755
    4856implementation
     
    6371end;
    6472
     73procedure TFormMain.FormActivate(Sender: TObject);
     74begin
     75  if not Initialized then begin
     76    Initialized := True;
     77  end;
     78end;
     79
     80procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     81begin
     82  PersistentForm1.Save(Self);
     83end;
     84
    6585procedure TFormMain.FormDestroy(Sender: TObject);
    6686begin
     
    7191procedure TFormMain.FormKeyPress(Sender: TObject; var Key: char);
    7292begin
    73   if (Key = #32) then begin
     93  if Key = #32 then begin
    7494    if Engine.State = gsRunning then Engine.State := gsPaused
    7595    else if Engine.State = gsPaused then Engine.State := gsRunning;
     
    7797end;
    7898
     99procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
     100  );
     101const
     102  KeyF11 = 122;
     103begin
     104  if Key = KeyF11 then begin
     105    FormMain.FullScreen := not FormMain.FullScreen;
     106    FormMain.PersistentForm1.SetFullScreen(FormMain.FullScreen);
     107  end;
     108end;
     109
    79110procedure TFormMain.FormShow(Sender: TObject);
    80111begin
     112  PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext;
     113  PersistentForm1.Load(Self, False, True);
    81114  Randomize;
    82115  Engine.ImagePassenger.Picture.Assign(FormImages.ImagePassenger.Picture);
Note: See TracChangeset for help on using the changeset viewer.