Changeset 11 for trunk/Forms/UFormMain.pas
- Timestamp:
- Oct 4, 2019, 11:57:05 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r10 r11 14 14 15 15 TFormMain = class(TForm) 16 AAbout: TAction;17 AExit: TAction;18 AGameNew: TAction;19 ActionList1: TActionList;20 16 MainMenu1: TMainMenu; 17 MenuItem1: TMenuItem; 21 18 MenuItemNew: TMenuItem; 22 19 MenuItemExit: TMenuItem; … … 24 21 MenuItemAbout: TMenuItem; 25 22 MenuItemGame: TMenuItem; 26 procedure AAboutExecute(Sender: TObject); 27 procedure AExitExecute(Sender: TObject); 28 procedure AGameNewExecute(Sender: TObject); 23 TimerDraw: TTimer; 29 24 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 30 25 procedure FormCreate(Sender: TObject); … … 33 28 procedure FormPaint(Sender: TObject); 34 29 procedure FormShow(Sender: TObject); 30 procedure TimerDrawTimer(Sender: TObject); 35 31 private 32 RedrawPending: Boolean; 36 33 public 34 procedure Redraw; 37 35 end; 38 36 … … 45 43 46 44 uses 47 UCore , UFormNew, UFormAbout;45 UCore; 48 46 49 47 { TFormMain } … … 53 51 MovedCount: Integer; 54 52 begin 55 if Core.Game.Running then begin53 if Core.Game.Running and not Core.Game.Moving then begin 56 54 MovedCount := 0; 57 55 case Key of … … 72 70 end; 73 71 74 procedure TFormMain.AGameNewExecute(Sender: TObject);75 begin76 FormNew := TFormNew.Create(nil);77 try78 FormNew.Load(Core.Game);79 if FormNew.ShowModal = mrOk then begin80 FormNew.Save(Core.Game);81 Core.Game.New;82 end;83 finally84 FreeAndNil(FormNew);85 end;86 end;87 88 72 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 89 73 begin 90 74 Core.PersistentForm1.Save(Self); 91 end;92 93 procedure TFormMain.AExitExecute(Sender: TObject);94 begin95 Close;96 end;97 98 procedure TFormMain.AAboutExecute(Sender: TObject);99 begin100 FormAbout := TFormAbout.Create(nil);101 try102 FormAbout.ApplicationInfo := Core.ApplicationInfo1;103 FormAbout.ShowModal;104 finally105 FreeAndNil(FormAbout);106 end;107 75 end; 108 76 … … 122 90 end; 123 91 92 procedure TFormMain.TimerDrawTimer(Sender: TObject); 93 begin 94 if RedrawPending then begin 95 RedrawPending := False; 96 Repaint; 97 end; 98 end; 99 100 procedure TFormMain.Redraw; 101 begin 102 RedrawPending := True; 103 end; 104 124 105 end. 125 106
Note:
See TracChangeset
for help on using the changeset viewer.