Ignore:
Timestamp:
Oct 4, 2019, 11:57:05 PM (5 years ago)
Author:
chronos
Message:
  • Added: Configurable speed of animations.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r10 r11  
    1414
    1515  TFormMain = class(TForm)
    16     AAbout: TAction;
    17     AExit: TAction;
    18     AGameNew: TAction;
    19     ActionList1: TActionList;
    2016    MainMenu1: TMainMenu;
     17    MenuItem1: TMenuItem;
    2118    MenuItemNew: TMenuItem;
    2219    MenuItemExit: TMenuItem;
     
    2421    MenuItemAbout: TMenuItem;
    2522    MenuItemGame: TMenuItem;
    26     procedure AAboutExecute(Sender: TObject);
    27     procedure AExitExecute(Sender: TObject);
    28     procedure AGameNewExecute(Sender: TObject);
     23    TimerDraw: TTimer;
    2924    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    3025    procedure FormCreate(Sender: TObject);
     
    3328    procedure FormPaint(Sender: TObject);
    3429    procedure FormShow(Sender: TObject);
     30    procedure TimerDrawTimer(Sender: TObject);
    3531  private
     32    RedrawPending: Boolean;
    3633  public
     34    procedure Redraw;
    3735  end;
    3836
     
    4543
    4644uses
    47   UCore, UFormNew, UFormAbout;
     45  UCore;
    4846
    4947{ TFormMain }
     
    5351  MovedCount: Integer;
    5452begin
    55   if Core.Game.Running then begin
     53  if Core.Game.Running and not Core.Game.Moving then begin
    5654    MovedCount := 0;
    5755    case Key of
     
    7270end;
    7371
    74 procedure TFormMain.AGameNewExecute(Sender: TObject);
    75 begin
    76   FormNew := TFormNew.Create(nil);
    77   try
    78     FormNew.Load(Core.Game);
    79     if FormNew.ShowModal = mrOk then begin
    80       FormNew.Save(Core.Game);
    81       Core.Game.New;
    82     end;
    83   finally
    84     FreeAndNil(FormNew);
    85   end;
    86 end;
    87 
    8872procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    8973begin
    9074  Core.PersistentForm1.Save(Self);
    91 end;
    92 
    93 procedure TFormMain.AExitExecute(Sender: TObject);
    94 begin
    95   Close;
    96 end;
    97 
    98 procedure TFormMain.AAboutExecute(Sender: TObject);
    99 begin
    100   FormAbout := TFormAbout.Create(nil);
    101   try
    102     FormAbout.ApplicationInfo := Core.ApplicationInfo1;
    103     FormAbout.ShowModal;
    104   finally
    105     FreeAndNil(FormAbout);
    106   end;
    10775end;
    10876
     
    12290end;
    12391
     92procedure TFormMain.TimerDrawTimer(Sender: TObject);
     93begin
     94  if RedrawPending then begin
     95    RedrawPending := False;
     96    Repaint;
     97  end;
     98end;
     99
     100procedure TFormMain.Redraw;
     101begin
     102  RedrawPending := True;
     103end;
     104
    124105end.
    125106
Note: See TracChangeset for help on using the changeset viewer.