- Timestamp:
- Oct 5, 2019, 1:00:29 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r17 r19 89 89 Core.PersistentForm1.RegistryContext := Core.ApplicationInfo1.GetRegistryContext; 90 90 Core.PersistentForm1.Load(Self); 91 Core.Game.New; 91 if not Core.Game.Running then 92 Core.Game.New; 92 93 end; 93 94 -
trunk/Forms/UFormSettings.lfm
r13 r19 16 16 Height = 26 17 17 Top = 24 18 Width = 1 5019 Caption = 'Animation speed:'18 Width = 172 19 Caption = 'Animation duration:' 20 20 ParentColor = False 21 21 end … … 52 52 object ComboBoxLanguage: TComboBox 53 53 Left = 208 54 Height = 4 354 Height = 42 55 55 Top = 86 56 56 Width = 230 -
trunk/Forms/UFormSettings.lrj
r13 r19 1 1 {"version":1,"strings":[ 2 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:"},3 {"hash":10139450,"name":"tformsettings.label1.caption","sourcebytes":[65,110,105,109,97,116,105,111,110,32,100,117,114,97,116,105,111,110,58],"value":"Animation duration:"}, 4 4 {"hash":1339,"name":"tformsettings.buttonok.caption","sourcebytes":[79,75],"value":"OK"}, 5 5 {"hash":77089212,"name":"tformsettings.buttoncancel.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"}, -
trunk/Install/win/Game2048.iss
r6 r19 55 55 Source: "{#MyAppSubDir}\lib\x86_64-win64-Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode 56 56 Source: "{#MyAppSubDir}\lib\i386-win32-Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode 57 ;Source: "{#MyAppSubDir}\Languages\*.po"; DestDir: "{app}\Languages"; Flags: ignoreversion57 Source: "{#MyAppSubDir}\Languages\*.po"; DestDir: "{app}\Languages"; Flags: ignoreversion 58 58 59 59 -
trunk/Languages/Game2048.cs.po
r14 r19 99 99 100 100 #: tformsettings.label1.caption 101 msgid "Animation speed:"102 msgstr " Rychlostanimace:"101 msgid "Animation duration:" 102 msgstr "Trvání animace:" 103 103 104 104 #: tformsettings.label2.caption -
trunk/Languages/Game2048.po
r14 r19 89 89 90 90 #: tformsettings.label1.caption 91 msgid "Animation speed:"91 msgid "Animation duration:" 92 92 msgstr "" 93 93 -
trunk/UCore.pas
r17 r19 115 115 CurrentContext := ApplicationInfo1.GetRegistryContext; 116 116 117 Game.TopScore := ReadIntegerWithDefault('TopScore', 0);118 Game.Board.Size := Point(ReadIntegerWithDefault('SizeX', 4), ReadIntegerWithDefault('SizeY', 4));119 Game.AnimationDuration := ReadIntegerWithDefault('AnimationDuration', 30);120 117 if ValueExists('LanguageCode') then 121 118 Translator1.Language := Translator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', '')) … … 124 121 Free; 125 122 end; 123 Game.LoadFromRegistry(ApplicationInfo1.GetRegistryContext); 126 124 end; 127 125 … … 132 130 CurrentContext := ApplicationInfo1.GetRegistryContext; 133 131 134 WriteInteger('TopScore', Game.TopScore);135 WriteInteger('SizeX', Game.Board.Size.X);136 WriteInteger('SizeY', Game.Board.Size.Y);137 WriteInteger('AnimationDuration', Game.AnimationDuration);138 132 if Assigned(Translator1.Language) and (Translator1.Language.Code <> '') then 139 133 WriteString('LanguageCode', Translator1.Language.Code) … … 142 136 Free; 143 137 end; 138 Game.SaveToRegistry(ApplicationInfo1.GetRegistryContext); 144 139 end; 145 140 -
trunk/UGame.pas
r17 r19 7 7 uses 8 8 Classes, SysUtils, Dialogs, fgl, Graphics, Types, Forms, Math, DateUtils, 9 Controls ;9 Controls, URegistry; 10 10 11 11 type … … 39 39 function GetEmptyTilesCount: Integer; 40 40 procedure GetEmptyTiles(EmptyTiles: TTiles); 41 procedure SaveToRegistry(RegContext: TRegistryContext); 42 procedure LoadFromRegistry(RegContext: TRegistryContext); 41 43 destructor Destroy; override; 42 44 property Size: TPoint read FSize write SetSize; … … 72 74 procedure MoveTile(SourceTile, TargetTile: TTile); 73 75 function IsValidPos(Pos: TPoint): Boolean; 76 procedure SaveToRegistry(RegContext: TRegistryContext); 77 procedure LoadFromRegistry(RegContext: TRegistryContext); 74 78 constructor Create; 75 79 destructor Destroy; override; … … 131 135 if Tiles[Y, X].Value = 0 then 132 136 EmptyTiles.Add(Tiles[Y, X]); 137 end; 138 139 procedure TBoard.SaveToRegistry(RegContext: TRegistryContext); 140 var 141 X, Y: Integer; 142 Value: string; 143 begin 144 with TRegistryEx.Create do 145 try 146 CurrentContext := RegContext; 147 148 Value := ''; 149 for Y := 0 to Size.Y - 1 do begin 150 for X := 0 to Size.X - 1 do begin 151 Value := Value + IntToStr(Tiles[Y, X].Value); 152 if X < Size.X - 1 then Value := Value + ','; 153 end; 154 if Y < Size.Y - 1 then Value := Value + ';' 155 end; 156 WriteString('TileValues', Value); 157 finally 158 Free; 159 end; 160 end; 161 162 procedure TBoard.LoadFromRegistry(RegContext: TRegistryContext); 163 var 164 X, Y: Integer; 165 Items: TStringList; 166 Lines: TStringList; 167 Number: Integer; 168 begin 169 with TRegistryEx.Create do 170 try 171 CurrentContext := RegContext; 172 173 Items := TStringList.Create; 174 Items.Delimiter := ','; 175 Lines := TStringList.Create; 176 Lines.Delimiter := ';'; 177 Lines.DelimitedText := ReadStringWithDefault('TileValues', ''); 178 for Y := 0 to Lines.Count - 1 do begin 179 Items.DelimitedText := Lines[Y]; 180 for X := 0 to Items.Count - 1 do begin 181 if TryStrToInt(Items[X], Number) and (X < Size.X) and (Y < Size.Y) then 182 Tiles[Y, X].Value := Number; 183 end; 184 end; 185 finally 186 Free; 187 end; 133 188 end; 134 189 … … 497 552 end; 498 553 554 procedure TGame.SaveToRegistry(RegContext: TRegistryContext); 555 begin 556 with TRegistryEx.Create do 557 try 558 CurrentContext := RegContext; 559 560 WriteInteger('TopScore', TopScore); 561 WriteInteger('AnimationDuration', AnimationDuration); 562 WriteInteger('SizeX', Board.Size.X); 563 WriteInteger('SizeY', Board.Size.Y); 564 WriteInteger('Score', Score); 565 WriteBool('GameRunning', FRunning); 566 WriteBool('Won', Won); 567 finally 568 Free; 569 end; 570 Board.SaveToRegistry(RegContext); 571 end; 572 573 procedure TGame.LoadFromRegistry(RegContext: TRegistryContext); 574 begin 575 with TRegistryEx.Create do 576 try 577 CurrentContext := RegContext; 578 Board.Size := Point(ReadIntegerWithDefault('SizeX', 4), ReadIntegerWithDefault('SizeY', 4)); 579 AnimationDuration := ReadIntegerWithDefault('AnimationDuration', 30); 580 TopScore := ReadIntegerWithDefault('TopScore', 0); 581 Score := ReadIntegerWithDefault('Score', 0); 582 FRunning := ReadBoolWithDefault('GameRunning', False); 583 Won := ReadBoolWithDefault('Won', False); 584 finally 585 Free; 586 end; 587 Board.LoadFromRegistry(RegContext); 588 end; 589 499 590 constructor TGame.Create; 500 591 begin
Note:
See TracChangeset
for help on using the changeset viewer.