Changeset 35 for trunk/UGame.pas
- Timestamp:
- Oct 13, 2019, 2:28:55 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r34 r35 43 43 NewItemPos: TPoint; 44 44 NewItemValue: Integer; 45 procedure SaveToRegistry(Reg Context: TRegistryContext);46 procedure LoadFromRegistry(Reg Context: TRegistryContext);45 procedure SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 46 procedure LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 47 47 end; 48 48 … … 50 50 51 51 THistoryMoves = class(TFPGObjectList<THistoryMove>) 52 procedure SaveToRegistry(Reg Context: TRegistryContext);53 procedure LoadFromRegistry(Reg Context: TRegistryContext);52 procedure SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 53 procedure LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 54 54 end; 55 55 … … 63 63 constructor Create; 64 64 destructor Destroy; override; 65 procedure SaveToRegistry(Reg Context: TRegistryContext);66 procedure LoadFromRegistry(Reg Context: TRegistryContext);65 procedure SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 66 procedure LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 67 67 end; 68 68 … … 82 82 function GetEmptyTilesCount: Integer; 83 83 procedure GetEmptyTiles(EmptyTiles: TTiles); 84 procedure SaveToRegistry(Reg Context: TRegistryContext);85 procedure LoadFromRegistry(Reg Context: TRegistryContext);84 procedure SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 85 procedure LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 86 86 destructor Destroy; override; 87 87 property Size: TPoint read FSize write SetSize; … … 157 157 { THistoryMoves } 158 158 159 procedure THistoryMoves.SaveToRegistry(Reg Context: TRegistryContext);159 procedure THistoryMoves.SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 160 160 var 161 161 I: Integer; 162 162 begin 163 with TRegistryEx.Create do 164 try 163 with Reg do begin 165 164 CurrentContext := RegContext; 166 165 WriteInteger('Count', Count); 167 166 for I := 0 to Count - 1 do begin 168 Items[I].SaveToRegistry(TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '/' + IntToStr(I))); 169 end; 170 finally 171 Free; 172 end; 173 end; 174 175 procedure THistoryMoves.LoadFromRegistry(RegContext: TRegistryContext); 167 Items[I].SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '/' + IntToStr(I))); 168 end; 169 end; 170 end; 171 172 procedure THistoryMoves.LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 176 173 var 177 174 I: Integer; … … 179 176 HistoryMove: THistoryMove; 180 177 begin 181 with TRegistryEx.Create do 182 try 178 with Reg do begin 183 179 CurrentContext := RegContext; 184 180 C := ReadIntegerWithDefault('Count', 0); … … 186 182 HistoryMove := THistoryMove.Create; 187 183 Add(HistoryMove); 188 HistoryMove.LoadFromRegistry(TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '/' + IntToStr(I))); 189 end; 190 finally 191 Free; 184 HistoryMove.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '/' + IntToStr(I))); 185 end; 192 186 end; 193 187 end; … … 195 189 { THistoryMove } 196 190 197 procedure THistoryMove.SaveToRegistry(RegContext: TRegistryContext); 198 begin 199 with TRegistryEx.Create do 200 try 191 procedure THistoryMove.SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 192 begin 193 with Reg do begin 201 194 CurrentContext := RegContext; 202 195 WriteInteger('Direction', Integer(Direction)); … … 204 197 WriteInteger('NewItemPosY', NewItemPos.Y); 205 198 WriteInteger('NewItemValue', NewItemValue); 206 finally 207 Free; 208 end; 209 end; 210 211 procedure THistoryMove.LoadFromRegistry(RegContext: TRegistryContext); 212 begin 213 with TRegistryEx.Create do 214 try 199 end; 200 end; 201 202 procedure THistoryMove.LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 203 begin 204 with Reg do begin 215 205 CurrentContext := RegContext; 216 206 Direction := TMoveDirection(ReadIntegerWithDefault('Direction', Integer(drNone))); … … 218 208 ReadIntegerWithDefault('NewItemPosY', 0)); 219 209 NewItemValue := ReadIntegerWithDefault('NewItemValue', 0); 220 finally221 Free;222 210 end; 223 211 end; … … 254 242 end; 255 243 256 procedure THistory.SaveToRegistry(Reg Context: TRegistryContext);244 procedure THistory.SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 257 245 var 258 246 I: Integer; 259 247 begin 260 with TRegistryEx.Create do 261 try 248 with Reg do begin 262 249 CurrentContext := TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\InitialTilesPos'); 263 250 WriteInteger('Count', Length(InitialTilesPos)); … … 266 253 WriteInteger('Y' + IntToStr(I), InitialTilesPos[I].Y); 267 254 end; 268 finally 269 Free; 270 end; 271 Moves.SaveToRegistry(RegContext); 272 end; 273 274 procedure THistory.LoadFromRegistry(RegContext: TRegistryContext); 255 Moves.SaveToRegistry(Reg, RegContext); 256 end; 257 end; 258 259 procedure THistory.LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 275 260 var 276 261 I: Integer; 277 262 begin 278 with TRegistryEx.Create do 279 try 263 with Reg do begin 280 264 CurrentContext := TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\InitialTilesPos'); 281 265 SetLength(InitialTilesPos, ReadIntegerWithDefault('Count', 0)); … … 284 268 ReadIntegerWithDefault('Y' + IntToStr(I), 0)); 285 269 end; 286 finally 287 Free; 288 end; 289 Moves.LoadFromRegistry(RegContext); 270 end; 271 Moves.LoadFromRegistry(Reg, RegContext); 290 272 end; 291 273 … … 349 331 end; 350 332 351 procedure TBoard.SaveToRegistry(Reg Context: TRegistryContext);333 procedure TBoard.SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 352 334 var 353 335 X, Y: Integer; 354 336 Value: string; 355 337 begin 356 with TRegistryEx.Create do 357 try 338 with Reg do begin 358 339 CurrentContext := RegContext; 359 340 … … 369 350 end; 370 351 WriteString('TileValues', Value); 371 finally 372 Free; 373 end; 374 end; 375 376 procedure TBoard.LoadFromRegistry(RegContext: TRegistryContext); 352 end; 353 end; 354 355 procedure TBoard.LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 377 356 var 378 357 X, Y: Integer; … … 381 360 Number: Integer; 382 361 begin 383 with TRegistryEx.Create do 384 try 362 with Reg do begin 385 363 CurrentContext := RegContext; 386 364 … … 400 378 Lines.Free; 401 379 Items.Free; 402 finally403 Free;404 380 end; 405 381 end; … … 912 888 913 889 procedure TGame.SaveToRegistry(RegContext: TRegistryContext); 914 begin 915 with TRegistryEx.Create do 890 var 891 Reg: TRegistryEx; 892 begin 893 Reg := TRegistryEx.Create; 894 with Reg do 916 895 try 917 896 CurrentContext := RegContext; … … 923 902 WriteBool('CanUndo', FCanUndo); 924 903 WriteBool('UndoEnabled', UndoEnabled); 904 FBoardUndo.SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\BoardUndo')); 905 Board.SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Board')); 906 History.SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\History')); 925 907 finally 926 908 Free; 927 909 end; 928 FBoardUndo.SaveToRegistry(TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\BoardUndo'));929 Board.SaveToRegistry(TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Board'));930 History.SaveToRegistry(TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\History'));931 910 end; 932 911 933 912 procedure TGame.LoadFromRegistry(RegContext: TRegistryContext); 934 begin 935 with TRegistryEx.Create do 913 var 914 Reg: TRegistryEx; 915 begin 916 Reg := TRegistryEx.Create; 917 with Reg do 936 918 try 937 919 CurrentContext := RegContext; … … 942 924 FCanUndo := ReadBoolWithDefault('CanUndo', False); 943 925 UndoEnabled := ReadBoolWithDefault('UndoEnabled', True); 926 FBoardUndo.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\BoardUndo')); 927 Board.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Board')); 928 History.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\History')); 944 929 finally 945 930 Free; 946 931 end; 947 FBoardUndo.LoadFromRegistry(TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\BoardUndo'));948 Board.LoadFromRegistry(TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Board'));949 History.LoadFromRegistry(TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\History'));950 932 DoChange; 951 933 end;
Note:
See TracChangeset
for help on using the changeset viewer.