Changeset 29 for trunk/UCore.pas
- Timestamp:
- Oct 6, 2019, 9:53:39 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r28 r29 7 7 uses 8 8 Classes, SysUtils, UTheme, UPersistentForm, UApplicationInfo, UTranslator, 9 URegistry, UGame, ActnList, Forms, Controls ;9 URegistry, UGame, ActnList, Forms, Controls, Dialogs; 10 10 11 11 type … … 15 15 TCore = class(TDataModule) 16 16 AAbout: TAction; 17 AComputer: TAction; 17 18 AHelp: TAction; 18 19 AUndo: TAction; … … 26 27 Translator1: TTranslator; 27 28 procedure AAboutExecute(Sender: TObject); 29 procedure AComputerExecute(Sender: TObject); 28 30 procedure AExitExecute(Sender: TObject); 29 31 procedure AHelpExecute(Sender: TObject); … … 35 37 private 36 38 procedure GameChange(Sender: TObject); 39 procedure GameWin(Sender: TObject); 40 procedure GameOver(Sender: TObject); 37 41 public 38 42 Game: TGame; … … 50 54 51 55 uses 52 UFormMain, UFormSettings, UFormAbout, UFormNew, UFormHelp; 56 UFormMain, UFormSettings, UFormAbout, UFormNew, UFormHelp, UFormComputer; 57 58 resourcestring 59 SGameOverCaption = 'Lost'; 60 SGameOverMessage = 'Game over!'; 61 SWinCaption = 'Win'; 62 SWinMessage = 'You reached %d and won! You can continue to play to get higher score.'; 53 63 54 64 { TCore } … … 66 76 Game.Board.Size := Point(4, 4); 67 77 Game.OnChange := GameChange; 78 Game.OnWin := GameWin; 68 79 LoadConfig; 69 80 end; … … 92 103 finally 93 104 FreeAndNil(FormAbout); 105 end; 106 end; 107 108 procedure TCore.AComputerExecute(Sender: TObject); 109 begin 110 FormComputer := TFormComputer.Create(nil); 111 try 112 FormComputer.ShowModal; 113 finally 114 FreeAndNil(FormComputer); 94 115 end; 95 116 end; … … 136 157 end; 137 158 159 procedure TCore.GameWin(Sender: TObject); 160 begin 161 MessageDlg(SWinCaption, Format(SWinMessage, [Game.WinScore]), mtInformation, [mbOk], 0); 162 end; 163 164 procedure TCore.GameOver(Sender: TObject); 165 begin 166 MessageDlg(SGameOverCaption, SGameOverMessage, mtInformation, [mbOK], 0); 167 end; 168 138 169 procedure TCore.UpdateInterface; 139 170 begin 140 171 AUndo.Enabled := Game.CanUndo; 172 {$IFDEF DEBUG} 173 AComputer.Enabled := True; 174 {$ELSE} 175 AComputer.Enabled := False; 176 {$ENDIF} 141 177 end; 142 178
Note:
See TracChangeset
for help on using the changeset viewer.