Changeset 11 for trunk/Forms
- Timestamp:
- Oct 4, 2019, 11:57:05 PM (5 years ago)
- Location:
- trunk/Forms
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.lfm
r8 r11 20 20 Caption = 'Game' 21 21 object MenuItemNew: TMenuItem 22 Action = AGameNew 22 Action = Core.AGameNew 23 end 24 object MenuItem1: TMenuItem 25 Action = Core.ASettings 23 26 end 24 27 object MenuItemExit: TMenuItem 25 Action = AExit28 Action = Core.AExit 26 29 end 27 30 end … … 29 32 Caption = 'Help' 30 33 object MenuItemAbout: TMenuItem 31 Action = AAbout34 Action = Core.AAbout 32 35 end 33 36 end 34 37 end 35 object ActionList1: TActionList 36 left = 144 38 object TimerDraw: TTimer 39 Interval = 20 40 OnTimer = TimerDrawTimer 41 left = 138 37 42 top = 152 38 object AGameNew: TAction39 Caption = 'New...'40 OnExecute = AGameNewExecute41 end42 object AExit: TAction43 Caption = 'Exit'44 OnExecute = AExitExecute45 end46 object AAbout: TAction47 Caption = 'About'48 OnExecute = AAboutExecute49 end50 43 end 51 44 end -
trunk/Forms/UFormMain.lrj
r8 r11 2 2 {"hash":128377605,"name":"tformmain.caption","sourcebytes":[50,48,52,56,32,103,97,109,101],"value":"2048 game"}, 3 3 {"hash":317493,"name":"tformmain.menuitemgame.caption","sourcebytes":[71,97,109,101],"value":"Game"}, 4 {"hash":322608,"name":"tformmain.menuitemhelp.caption","sourcebytes":[72,101,108,112],"value":"Help"}, 5 {"hash":88908046,"name":"tformmain.agamenew.caption","sourcebytes":[78,101,119,46,46,46],"value":"New..."}, 6 {"hash":315140,"name":"tformmain.aexit.caption","sourcebytes":[69,120,105,116],"value":"Exit"}, 7 {"hash":4691652,"name":"tformmain.aabout.caption","sourcebytes":[65,98,111,117,116],"value":"About"} 4 {"hash":322608,"name":"tformmain.menuitemhelp.caption","sourcebytes":[72,101,108,112],"value":"Help"} 8 5 ]} -
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 -
trunk/Forms/UFormSettings.lfm
r8 r11 5 5 Width = 480 6 6 Caption = 'Settings' 7 ClientHeight = 360 8 ClientWidth = 480 7 9 DesignTimePPI = 144 10 OnShow = FormShow 8 11 LCLVersion = '2.0.2.0' 12 object Label1: TLabel 13 Left = 19 14 Height = 26 15 Top = 24 16 Width = 150 17 Caption = 'Animation speed:' 18 ParentColor = False 19 end 20 object TrackBar1: TTrackBar 21 Left = 208 22 Height = 58 23 Top = 16 24 Width = 240 25 Max = 100 26 Position = 0 27 Anchors = [akTop, akLeft, akRight] 28 TabOrder = 0 29 end 30 object ButtonOk: TButton 31 Left = 112 32 Height = 38 33 Top = 291 34 Width = 113 35 Anchors = [akLeft, akBottom] 36 Caption = 'OK' 37 OnClick = ButtonOkClick 38 TabOrder = 1 39 end 40 object ButtonCancel: TButton 41 Left = 256 42 Height = 38 43 Top = 288 44 Width = 113 45 Anchors = [akLeft, akBottom] 46 Caption = 'Cancel' 47 OnClick = ButtonCancelClick 48 TabOrder = 2 49 end 9 50 end -
trunk/Forms/UFormSettings.lrj
r8 r11 1 1 {"version":1,"strings":[ 2 {"hash":213582195,"name":"tformsettings.caption","sourcebytes":[83,101,116,116,105,110,103,115],"value":"Settings"} 2 {"hash":213582195,"name":"tformsettings.caption","sourcebytes":[83,101,116,116,105,110,103,115],"value":"Settings"}, 3 {"hash":69745274,"name":"tformsettings.label1.caption","sourcebytes":[65,110,105,109,97,116,105,111,110,32,115,112,101,101,100,58],"value":"Animation speed:"}, 4 {"hash":1339,"name":"tformsettings.buttonok.caption","sourcebytes":[79,75],"value":"OK"}, 5 {"hash":77089212,"name":"tformsettings.buttoncancel.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"} 3 6 ]} -
trunk/Forms/UFormSettings.pas
r8 r11 6 6 7 7 uses 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs ;8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls; 9 9 10 10 type 11 12 { TFormSettings } 13 11 14 TFormSettings = class(TForm) 15 ButtonOk: TButton; 16 ButtonCancel: TButton; 17 Label1: TLabel; 18 TrackBar1: TTrackBar; 19 procedure ButtonCancelClick(Sender: TObject); 20 procedure ButtonOkClick(Sender: TObject); 21 procedure FormShow(Sender: TObject); 12 22 private 13 23 … … 23 33 {$R *.lfm} 24 34 35 uses 36 UCore; 37 38 { TFormSettings } 39 40 procedure TFormSettings.ButtonCancelClick(Sender: TObject); 41 begin 42 Close; 43 end; 44 45 procedure TFormSettings.ButtonOkClick(Sender: TObject); 46 begin 47 Core.Game.AnimationDuration := TrackBar1.Position; 48 Close; 49 end; 50 51 procedure TFormSettings.FormShow(Sender: TObject); 52 begin 53 TrackBar1.Position := Core.Game.AnimationDuration; 54 end; 55 25 56 end. 26 57
Note:
See TracChangeset
for help on using the changeset viewer.