Changeset 10 for trunk/UCore.pas
- Timestamp:
- Oct 4, 2019, 11:05:35 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r8 r10 6 6 7 7 uses 8 Classes, SysUtils, UTheme, UPersistentForm, UApplicationInfo, UTranslator; 8 Classes, SysUtils, UTheme, UPersistentForm, UApplicationInfo, UTranslator, 9 URegistry, UGame; 9 10 10 11 type … … 17 18 ThemeManager1: TThemeManager; 18 19 Translator1: TTranslator; 20 procedure DataModuleCreate(Sender: TObject); 21 procedure DataModuleDestroy(Sender: TObject); 19 22 private 20 23 procedure GameChange(Sender: TObject); 21 24 public 22 25 Game: TGame; 26 procedure LoadConfig; 27 procedure SaveConfig; 23 28 end; 24 29 … … 30 35 {$R *.lfm} 31 36 37 uses 38 UFormMain; 39 40 { TCore } 41 42 procedure TCore.DataModuleCreate(Sender: TObject); 43 begin 44 Randomize; 45 Game := TGame.Create; 46 Game.Size := Point(4, 4); 47 Game.OnChange := GameChange; 48 LoadConfig; 49 end; 50 51 procedure TCore.DataModuleDestroy(Sender: TObject); 52 begin 53 SaveConfig; 54 FreeAndNil(Game); 55 end; 56 57 procedure TCore.GameChange(Sender: TObject); 58 begin 59 FormMain.Repaint; 60 end; 61 62 procedure TCore.LoadConfig; 63 begin 64 with TRegistryEx.Create do 65 try 66 CurrentContext := ApplicationInfo1.GetRegistryContext; 67 68 Game.TopScore := ReadIntegerWithDefault('TopScore', 0); 69 finally 70 Free; 71 end; 72 end; 73 74 procedure TCore.SaveConfig; 75 begin 76 with TRegistryEx.Create do 77 try 78 CurrentContext := ApplicationInfo1.GetRegistryContext; 79 80 WriteInteger('TopScore', Game.TopScore); 81 finally 82 Free; 83 end; 84 end; 85 32 86 end. 33 87
Note:
See TracChangeset
for help on using the changeset viewer.