Changeset 36
- Timestamp:
- Jan 1, 2018, 8:57:03 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UMainForm.lfm
r34 r36 5 5 Width = 514 6 6 Caption = 'Tunneler' 7 ClientHeight = 3 837 ClientHeight = 378 8 8 ClientWidth = 514 9 9 Menu = MainMenu1 … … 15 15 OnKeyUp = FormKeyUp 16 16 OnShow = FormShow 17 LCLVersion = '1. 5'17 LCLVersion = '1.8.0.4' 18 18 object StatusBar1: TStatusBar 19 19 Left = 0 20 Height = 2921 Top = 3 5420 Height = 30 21 Top = 348 22 22 Width = 514 23 23 Panels = < … … 47 47 object Image1: TImage 48 48 Left = 0 49 Height = 3 5449 Height = 348 50 50 Top = 0 51 51 Width = 514 … … 135 135 VersionMinor = 0 136 136 VersionBugFix = 0 137 VersionSuffix = 'alfa' 137 138 CompanyName = 'Chronosoft' 138 139 HomePage = 'http://svn.zdechov.net/trac/Tunneler/' … … 140 141 EmailContact = 'robie@centrum.cz' 141 142 AppName = 'Tunneler' 142 ReleaseDate = 4 1160143 ReleaseDate = 43064 143 144 RegistryKey = '\Software\Chronosoft\Tunneler' 144 145 RegistryRoot = rrKeyCurrentUser 146 License = 'CC0' 145 147 left = 99 146 148 top = 176 147 149 end 150 object XMLConfig1: TXMLConfig 151 StartEmpty = False 152 RootName = 'CONFIG' 153 ReadOnly = False 154 left = 99 155 top = 240 156 end 148 157 end -
trunk/Forms/UMainForm.pas
r34 r36 6 6 7 7 uses 8 Registry, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 9 ComCtrls, Menus, ActnList, UCore, UPlatform, Math, DateUtils, GraphType, 10 UPersistentForm, UApplicationInfo, UCoolTranslator, LCLType, URegistry; 8 Registry, XMLConf, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, 9 Dialogs, ExtCtrls, ComCtrls, Menus, ActnList, UCore, UPlatform, Math, 10 DateUtils, GraphType, UPersistentForm, UApplicationInfo, UCoolTranslator, 11 LCLType, URegistry; 11 12 12 13 type … … 37 38 TimerDraw: TTimer; 38 39 TimerEngineTick: TTimer; 40 XMLConfig1: TXMLConfig; 39 41 procedure AExitExecute(Sender: TObject); 40 42 procedure AFullScreenExecute(Sender: TObject); … … 60 62 DrawDuration: TDateTime; 61 63 Drawing: Boolean; 64 procedure LoadConfig; 65 procedure SaveConfig; 62 66 public 63 67 PersistentForm: TPersistentForm; … … 110 114 end; 111 115 116 procedure TMainForm.LoadConfig; 117 begin 118 if not FileExists(XMLConfig1.Filename) then Exit; 119 if Assigned(Engine) then Engine.LoadConfig(XMLConfig1, ''); 120 end; 121 122 procedure TMainForm.SaveConfig; 123 begin 124 if Assigned(Engine) then Engine.SaveConfig(XMLConfig1, ''); 125 XMLConfig1.Flush; 126 end; 127 112 128 procedure TMainForm.EraseBackground(DC: HDC); 113 129 begin … … 117 133 procedure TMainForm.FormCreate(Sender: TObject); 118 134 begin 135 XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml'; 136 119 137 PersistentForm := TPersistentForm.Create(nil); 120 138 PersistentForm.RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot), … … 126 144 Engine := TEngine.Create; 127 145 Engine.Bitmap := Image1.Picture.Bitmap; 146 LoadConfig; 128 147 Engine.NewGame; 129 148 Engine.Active := True; … … 193 212 begin 194 213 PersistentForm.Save(Self); 214 SaveConfig; 195 215 end; 196 216 -
trunk/Forms/UNewGameForm.lfm
r34 r36 120 120 end 121 121 object EditDown: TEdit 122 Left = 8 8122 Left = 86 123 123 Height = 36 124 124 Top = 32 … … 186 186 Width = 176 187 187 OnChange = EditNameChange 188 OnKeyDown = EditUpKeyDown189 188 TabOrder = 4 190 189 end -
trunk/UCore.pas
r34 r36 8 8 Dialogs, Classes, SysUtils, Graphics, SpecializedMatrix, SpecializedList, 9 9 IntfGraphics, FPImage, LCLType, SpecializedBitmap, GraphType, Math, URectangle, 10 Syncobjs, UThreading, Forms, DateUtils, UAudioSystem, UAudioSystemMPlayer; 10 Syncobjs, UThreading, Forms, DateUtils, UAudioSystem, UAudioSystemMPlayer, 11 XMLConf, DOM; 11 12 12 13 const … … 63 64 Image: TMatrixByte; 64 65 Mask: TMatrixByte; 66 procedure Assign(Source: TTank); 65 67 constructor Create; 66 68 destructor Destroy; override; 69 end; 70 71 { TTanks } 72 73 TTanks = class(TListObject) 74 procedure Assign(Source: TTanks); 67 75 end; 68 76 … … 109 117 Name: string; 110 118 Keys: TPlayerKeys; 111 Tanks: T ListObject; // TListObject<TTank>119 Tanks: TTanks; 112 120 Bullets: TListObject; // TListObject<TBullet> 113 121 LastShootTime: TDateTime; … … 133 141 destructor Destroy; override; 134 142 procedure Assign(Source: TPlayer); 143 procedure LoadConfig(Config: TXMLConfig; Path: string); 144 procedure SaveConfig(Config: TXMLConfig; Path: string); 135 145 property Exploded: Boolean read FExploded write SetExploded; 136 146 end; … … 139 149 140 150 TPlayers = class(TListObject) 151 Engine: TEngine; 141 152 procedure Assign(Players: TPlayers); 153 procedure LoadConfig(Config: TXMLConfig; Path: string); 154 procedure SaveConfig(Config: TXMLConfig; Path: string); 142 155 end; 143 156 … … 212 225 procedure DoDrawToBitmap; 213 226 procedure InitPlayerPool; 227 procedure InitPlayers; 214 228 public 215 229 Keyboard: TKeyboard; … … 232 246 procedure NewGame; 233 247 procedure NewRound; 248 procedure LoadConfig(Config: TXMLConfig; Path: string); 249 procedure SaveConfig(Config: TXMLConfig; Path: string); 234 250 property Bitmap: TBitmap read FBitmap write SetBitmap; 235 251 property Active: Boolean read FActive write SetActive; … … 267 283 end; 268 284 285 { TTanks } 286 287 procedure TTanks.Assign(Source: TTanks); 288 var 289 I: Integer; 290 begin 291 Clear; 292 Count := Source.Count; 293 for I := 0 to Count - 1 do begin 294 Items[I] := TTank.Create; 295 TTank(Items[I]).Assign(TTank(Source.Items[I])); 296 end; 297 end; 298 269 299 { TPlayers } 270 300 … … 279 309 end; 280 310 311 procedure TPlayers.SaveConfig(Config: TXMLConfig; Path: string); 312 var 313 I: Integer; 314 begin 315 Config.SetValue(DOMString(Path + '/Count'), Count); 316 for I := 0 to Count - 1 do 317 TPlayer(Items[I]).SaveConfig(Config, Path + '/Player' + IntToStr(I)); 318 end; 319 320 procedure TPlayers.LoadConfig(Config: TXMLConfig; Path: string); 321 var 322 I: Integer; 323 begin 324 Clear; 325 Count := Config.GetValue(DOMString(Path + '/Count'), 0); 326 for I := 0 to Count - 1 do begin 327 Items[I] := TPlayer.Create; 328 TPlayer(Items[I]).Engine := Engine; 329 TPlayer(Items[I]).Id := I; 330 TPlayer(Items[I]).LoadConfig(Config, Path + '/Player' + IntToStr(I)); 331 end; 332 end; 333 281 334 { TSystemThread } 282 335 … … 319 372 { TTank } 320 373 374 procedure TTank.Assign(Source: TTank); 375 begin 376 Image.Assign(Source.Image); 377 Mask.Assign(Source.Mask); 378 end; 379 321 380 constructor TTank.Create; 322 381 begin … … 327 386 destructor TTank.Destroy; 328 387 begin 329 Mask.Free;330 Image.Free;388 FreeAndNil(Mask); 389 FreeAndNil(Image); 331 390 inherited Destroy; 332 391 end; … … 694 753 destructor TWorld.Destroy; 695 754 begin 696 Surface.Free;697 Matter.Free;755 FreeAndNil(Surface); 756 FreeAndNil(Matter); 698 757 inherited Destroy; 699 758 end; … … 1186 1245 constructor TPlayer.Create; 1187 1246 begin 1188 Tanks := T ListObject.Create;1247 Tanks := TTanks.Create; 1189 1248 Bullets := TListObject.Create; 1190 1249 House := TRectangle.Create; … … 1194 1253 destructor TPlayer.Destroy; 1195 1254 begin 1196 ScreenFrame.Free;1197 House.Free;1198 Bullets.Free;1199 Tanks.Free;1255 FreeAndNil(ScreenFrame); 1256 FreeAndNil(House); 1257 FreeAndNil(Bullets); 1258 FreeAndNil(Tanks); 1200 1259 inherited Destroy; 1201 1260 end; … … 1203 1262 procedure TPlayer.Assign(Source: TPlayer); 1204 1263 begin 1264 Engine := Source.Engine; 1265 Id := Source.Id; 1205 1266 Keys := Source.Keys; 1206 1267 Color := Source.Color; … … 1211 1272 Position := Source.Position; 1212 1273 Score := Source.Score; 1274 Tanks.Assign(Source.Tanks); 1275 end; 1276 1277 procedure TPlayer.LoadConfig(Config: TXMLConfig; Path: string); 1278 begin 1279 with Config do begin 1280 Self.Name := GetValue(DOMString(Path + '/Name'), ''); 1281 Color := GetValue(DOMString(Path + '/Color'), 0); 1282 Enabled := GetValue(DOMString(Path + '/Enabled'), False); 1283 Keys.Left := GetValue(DOMString(Path + '/Keys/Left'), 0); 1284 Keys.Right := GetValue(DOMString(Path + '/Keys/Right'), 0); 1285 Keys.Down := GetValue(DOMString(Path + '/Keys/Down'), 0); 1286 Keys.Up := GetValue(DOMString(Path + '/Keys/Up'), 0); 1287 Keys.Shoot := GetValue(DOMString(Path + '/Keys/Shoot'), 0); 1288 end; 1289 InitTanks; 1290 end; 1291 1292 procedure TPlayer.SaveConfig(Config: TXMLConfig; Path: string); 1293 begin 1294 with Config do begin 1295 SetValue(DOMString(Path + '/Name'), Self.Name); 1296 SetValue(DOMString(Path + '/Color'), Color); 1297 SetValue(DOMString(Path + '/Enabled'), Enabled); 1298 SetValue(DOMString(Path + '/Keys/Left'), Keys.Left); 1299 SetValue(DOMString(Path + '/Keys/Right'), Keys.Right); 1300 SetValue(DOMString(Path + '/Keys/Down'), Keys.Down); 1301 SetValue(DOMString(Path + '/Keys/Up'), Keys.Up); 1302 SetValue(DOMString(Path + '/Keys/Shoot'), Keys.Shoot); 1303 end; 1213 1304 end; 1214 1305 … … 1517 1608 end; 1518 1609 1610 procedure TEngine.InitPlayers; 1611 var 1612 I: Integer; 1613 NewPlayer: TPlayer; 1614 begin 1615 Players.Clear; 1616 for I := 0 to PlayerPool.Count - 1 do 1617 with TPlayer(PlayerPool[I]) do 1618 if Enabled then begin 1619 NewPlayer := TPlayer.Create; 1620 NewPlayer.Assign(TPlayer(PlayerPool[I])); 1621 Players.Add(NewPlayer); 1622 Score := 0; 1623 end; 1624 end; 1625 1519 1626 procedure TEngine.CheckGameEnd; 1520 1627 var … … 1573 1680 IntfImage := TLazIntfImage.Create(1, 1); 1574 1681 PlayerPool := TPlayers.Create; 1682 PlayerPool.Engine := Self; 1575 1683 Players := TPlayers.Create; 1576 Players. OwnsObjects := False;1684 Players.Engine := Self; 1577 1685 Keyboard := TKeyboard.Create; 1578 1686 World := TWorld.Create; … … 1651 1759 begin 1652 1760 Active := False; 1653 Players.Clear; 1654 for I := 0 to PlayerPool.Count - 1 do 1655 with TPlayer(PlayerPool[I]) do 1656 if Enabled then begin 1657 Players.Add(PlayerPool[I]); 1658 Score := 0; 1659 end; 1761 InitPlayers; 1660 1762 ResizePlayerFrames; 1661 1763 CurrentRound := 0; … … 1681 1783 end; 1682 1784 1785 procedure TEngine.LoadConfig(Config: TXMLConfig; Path: string); 1786 begin 1787 PlayerPool.LoadConfig(Config, Path + '/Players'); 1788 end; 1789 1790 procedure TEngine.SaveConfig(Config: TXMLConfig; Path: string); 1791 begin 1792 PlayerPool.SaveConfig(Config, Path + '/Players'); 1793 end; 1794 1683 1795 end. 1684 1796 -
trunk/tunneler.lpi
r35 r36 71 71 </local> 72 72 </RunParams> 73 <RequiredPackages Count=" 5">73 <RequiredPackages Count="6"> 74 74 <Item1> 75 <PackageName Value="FCL"/> 76 </Item1> 77 <Item2> 75 78 <PackageName Value="CoolAudio"/> 76 79 <DefaultFilename Value="Components/CoolAudio/CoolAudio.lpk" Prefer="True"/> 77 </Item 1>78 <Item 2>80 </Item2> 81 <Item3> 79 82 <PackageName Value="Common"/> 80 83 <DefaultFilename Value="Components/Common/Common.lpk" Prefer="True"/> 81 </Item 2>82 <Item 3>84 </Item3> 85 <Item4> 83 86 <PackageName Value="CoolTranslator"/> 84 87 <DefaultFilename Value="Components/CoolTranslator/CoolTranslator.lpk" Prefer="True"/> 85 </Item 3>86 <Item 4>88 </Item4> 89 <Item5> 87 90 <PackageName Value="TemplateGenerics"/> 88 91 <DefaultFilename Value="Components/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/> 89 </Item 4>90 <Item 5>92 </Item5> 93 <Item6> 91 94 <PackageName Value="LCL"/> 92 </Item 5>95 </Item6> 93 96 </RequiredPackages> 94 97 <Units Count="9">
Note:
See TracChangeset
for help on using the changeset viewer.