Changeset 128
- Timestamp:
- Jun 17, 2017, 5:55:16 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.lfm
r127 r128 194 194 Action = Core.ASettings 195 195 end 196 object MenuItem24: TMenuItem 197 Action = Core.AShowCharts 198 end 196 199 end 197 200 object MenuItem16: TMenuItem -
trunk/Forms/UFormMain.pas
r127 r128 42 42 MenuItem22: TMenuItem; 43 43 MenuItem23: TMenuItem; 44 MenuItem24: TMenuItem; 44 45 MenuItemLoadRecent: TMenuItem; 45 46 MenuItem3: TMenuItem; -
trunk/Languages/xtactics.cs.po
r127 r128 85 85 msgstr "Nastavení aplikace" 86 86 87 #: tcore.ashowcharts.caption 88 msgid "Show charts" 89 msgstr "Ukázat grafy" 90 87 91 #: tformabout.buttonclose.caption 88 92 msgid "Close" … … 111 115 msgid "Turn-based strategy game inspired by classic Risk board game. The game is highly configurable to allow to adjust battle field and game rules." 112 116 msgstr "Tahová strategie inspirovaná klasickou deskovou hrou Risk. Hra je vysoce nastavitelná a umožňuje přizpůsobit bitevní pole a herní pravidla." 117 118 #: tformcharts.caption 119 msgid "Charts" 120 msgstr "Grafy" 121 122 #: tformcharts.combobox1.text 123 msgid "Occupied cells" 124 msgstr "Obsazené buňky" 113 125 114 126 #: tformhelp.caption -
trunk/Languages/xtactics.po
r127 r128 75 75 msgstr "" 76 76 77 #: tcore.ashowcharts.caption 78 msgid "Show charts" 79 msgstr "" 80 77 81 #: tformabout.buttonclose.caption 78 82 msgid "Close" … … 102 106 msgstr "" 103 107 108 #: tformcharts.caption 109 msgid "Charts" 110 msgstr "" 111 112 #: tformcharts.combobox1.text 113 msgid "Occupied cells" 114 msgstr "" 115 104 116 #: tformhelp.caption 105 117 msgctxt "TFORMHELP.CAPTION" -
trunk/UCore.lfm
r127 r128 73 73 Caption = 'Help' 74 74 OnExecute = AHelpExecute 75 end 76 object AShowCharts: TAction 77 Caption = 'Show charts' 78 OnExecute = AShowChartsExecute 75 79 end 76 80 end -
trunk/UCore.lrt
r124 r128 15 15 TCORE.AABOUT.CAPTION=About 16 16 TCORE.AHELP.CAPTION=Help 17 TCORE.ASHOWCHARTS.CAPTION=Show charts -
trunk/UCore.pas
r127 r128 16 16 TCore = class(TDataModule) 17 17 AAbout: TAction; 18 AShowCharts: TAction; 18 19 AHelp: TAction; 19 20 AGameSave: TAction; … … 46 47 procedure AHelpExecute(Sender: TObject); 47 48 procedure ASettingsExecute(Sender: TObject); 49 procedure AShowChartsExecute(Sender: TObject); 48 50 procedure CoolTranslator1Translate(Sender: TObject); 49 51 procedure DataModuleCreate(Sender: TObject); … … 92 94 uses 93 95 UFormMove, UFormMain, UFormNew, UFormSettings, UFormAbout, UFormPlayer, 94 UFormHelp ;96 UFormHelp, UFormCharts; 95 97 96 98 const … … 354 356 end; 355 357 358 procedure TCore.AShowChartsExecute(Sender: TObject); 359 begin 360 FormCharts.Show; 361 end; 362 356 363 procedure TCore.CoolTranslator1Translate(Sender: TObject); 357 364 begin … … 400 407 FormMain.AZoomAll.Execute; 401 408 FormMain.Redraw; 409 if FormCharts.Visible then FormCharts.Redraw; 402 410 end; 403 411 … … 408 416 Game.Running := True; 409 417 FormMain.Redraw; 418 if FormCharts.Visible then FormCharts.Redraw; 410 419 UpdateActions; 411 420 end; … … 415 424 if Assigned(Game.CurrentPlayer) and Assigned(Game.CurrentPlayer.Client) then 416 425 CurrentClient := Game.CurrentPlayer.Client; 426 if FormCharts.Visible then FormCharts.Redraw; 417 427 end; 418 428 -
trunk/UGame.pas
r127 r128 7 7 uses 8 8 Classes, SysUtils, ExtCtrls, Graphics, Contnrs, XMLConf, XMLRead, XMLWrite, 9 DOM, Math, FileUtil, UXMLUtils, Dialogs, Types, LCLType, LCLIntf;9 DOM, Math, LazFileUtils, UXMLUtils, Dialogs, Types, LCLType, LCLIntf; 10 10 11 11 const … … 243 243 end; 244 244 245 { TGameTurnStat } 246 247 TGameTurnStat = class 248 OccupiedCells: Integer; 249 Units: Integer; 250 DiscoveredCells: Integer; 251 Cities: Integer; 252 procedure LoadFromNode(Node: TDOMNode); 253 procedure SaveToNode(Node: TDOMNode); 254 end; 255 256 { TGameTurnStats } 257 258 TGameTurnStats = class(TObjectList) 259 procedure LoadFromNode(Node: TDOMNode); 260 procedure SaveToNode(Node: TDOMNode); 261 end; 262 245 263 TPlayerMode = (pmHuman, pmComputer); 246 264 TComputerAgressivity = (caLow, caMedium, caHigh); … … 262 280 TotalCells: Integer; 263 281 TotalCities: Integer; 282 TotalDiscovered: Integer; 264 283 StartUnits: Integer; 265 284 StartCell: TCell; … … 267 286 Defensive: Boolean; 268 287 Agressivity: TComputerAgressivity; 288 TurnStats: TGameTurnStats; 289 procedure Clear; 269 290 procedure LoadFromNode(Node: TDOMNode); 270 291 procedure SaveToNode(Node: TDOMNode); … … 385 406 procedure MoveAll(Player: TPlayer); 386 407 procedure ClearMovesFromCell(Cell: TCell); 408 procedure RecordTurnStats; 387 409 procedure SetMapType(AValue: TMapType); 388 410 function SetMove(CellFrom, CellTo: TCell; Power: Integer; Confirmation: Boolean = True): TUnitMove; … … 543 565 end; 544 566 567 { TGameTurnStat } 568 569 procedure TGameTurnStat.LoadFromNode(Node: TDOMNode); 570 begin 571 OccupiedCells := ReadInteger(Node, 'OccupiedCells', 0); 572 Units := ReadInteger(Node, 'Units', 0); 573 DiscoveredCells := ReadInteger(Node, 'DiscoveredCells', 0); 574 Cities := ReadInteger(Node, 'Cities', 0); 575 end; 576 577 procedure TGameTurnStat.SaveToNode(Node: TDOMNode); 578 begin 579 WriteInteger(Node, 'OccupiedCells', OccupiedCells); 580 WriteInteger(Node, 'Units', Units); 581 WriteInteger(Node, 'DiscoveredCells', DiscoveredCells); 582 WriteInteger(Node, 'Cities', Cities); 583 end; 584 585 { TGameTurnStats } 586 587 procedure TGameTurnStats.LoadFromNode(Node: TDOMNode); 588 var 589 Node2: TDOMNode; 590 NewTurnStat: TGameTurnStat; 591 begin 592 Count := 0; 593 Node2 := Node.FirstChild; 594 while Assigned(Node2) and (Node2.NodeName = 'TurnStat') do begin 595 NewTurnStat := TGameTurnStat.Create; 596 NewTurnStat.LoadFromNode(Node2); 597 Add(NewTurnStat); 598 Node2 := Node2.NextSibling; 599 end; 600 end; 601 602 procedure TGameTurnStats.SaveToNode(Node: TDOMNode); 603 var 604 I: Integer; 605 NewNode: TDOMNode; 606 begin 607 for I := 0 to Count - 1 do begin; 608 NewNode := Node.OwnerDocument.CreateElement('TurnStat'); 609 Node.AppendChild(NewNode); 610 TGameTurnStat(Items[I]).SaveToNode(NewNode); 611 end; 612 end; 613 545 614 { TClients } 546 615 … … 1817 1886 end; 1818 1887 1888 procedure TPlayer.Clear; 1889 begin 1890 TurnStats.Clear; 1891 end; 1892 1819 1893 procedure TPlayer.SetClient(AValue: TClient); 1820 1894 begin … … 1843 1917 PlayerMap.LoadFromNode(NewNode); 1844 1918 end; 1919 with Node do begin 1920 NewNode := FindNode('TurnStats'); 1921 if Assigned(NewNode) then 1922 TurnStats.LoadFromNode(NewNode); 1923 end; 1845 1924 end; 1846 1925 … … 1862 1941 AppendChild(NewNode); 1863 1942 PlayerMap.SaveToNode(NewNode); 1943 end; 1944 with Node do begin 1945 NewNode := OwnerDocument.CreateElement('TurnStats'); 1946 AppendChild(NewNode); 1947 TurnStats.SaveToNode(NewNode); 1864 1948 end; 1865 1949 end; … … 2247 2331 PlayerMap := TPlayerMap.Create; 2248 2332 PlayerMap.Player := Self; 2333 TurnStats := TGameTurnStats.Create; 2249 2334 end; 2250 2335 2251 2336 destructor TPlayer.Destroy; 2252 2337 begin 2338 FreeAndNil(TurnStats); 2253 2339 FreeAndNil(PlayerMap); 2254 2340 inherited Destroy; … … 2884 2970 var 2885 2971 I: Integer; 2972 J: Integer; 2886 2973 begin 2887 2974 for I := 0 to Players.Count - 1 do … … 2890 2977 TotalCells := 0; 2891 2978 TotalCities := 0; 2892 end; 2979 2980 TotalDiscovered := 0; 2981 for J := 0 to PlayerMap.Cells.Count - 1 do 2982 with TPlayerCell(PlayerMap.Cells[J]) do begin 2983 if Explored then Inc(TotalDiscovered); 2984 end; 2985 end; 2986 2893 2987 Map.ComputePlayerStats; 2988 end; 2989 2990 procedure TGame.RecordTurnStats; 2991 var 2992 I: Integer; 2993 NewStat: TGameTurnStat; 2994 begin 2995 for I := 0 to Players.Count - 1 do 2996 with TPlayer(Players[I]) do begin 2997 NewStat := TGameTurnStat.Create; 2998 NewStat.DiscoveredCells := TotalDiscovered; 2999 NewStat.OccupiedCells := TotalCells; 3000 NewStat.Units := TotalUnits; 3001 NewStat.Cities := TotalCities; 3002 TurnStats.Add(NewStat); 3003 end; 2894 3004 end; 2895 3005 … … 2927 3037 UpdateRepeatMoves(CurrentPlayer); 2928 3038 ComputePlayerStats; 3039 RecordTurnStats; 2929 3040 PrevPlayer := CurrentPlayer; 2930 3041 // Skip dead players … … 3045 3156 for I := 0 to Players.Count - 1 do 3046 3157 with TPlayer(Players[I]) do begin 3158 Clear; 3047 3159 PlayerMap.Update; 3048 3160 if (Map.Size.X > 0) and (Map.Size.Y > 0) then begin -
trunk/xtactics.lpi
r125 r128 153 153 </local> 154 154 </RunParams> 155 <RequiredPackages Count=" 5">155 <RequiredPackages Count="6"> 156 156 <Item1> 157 <PackageName Value="TAChartLazarusPkg"/> 158 </Item1> 159 <Item2> 157 160 <PackageName Value="TemplateGenerics"/> 158 161 <DefaultFilename Value="Packages/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/> 159 </Item 1>160 <Item 2>162 </Item2> 163 <Item3> 161 164 <PackageName Value="Common"/> 162 165 <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/> 163 </Item2>164 <Item3>165 <PackageName Value="FCL"/>166 166 </Item3> 167 167 <Item4> 168 <PackageName Value="FCL"/> 169 </Item4> 170 <Item5> 168 171 <PackageName Value="CoolTranslator"/> 169 172 <DefaultFilename Value="Packages/CoolTranslator/CoolTranslator.lpk" Prefer="True"/> 170 </Item 4>171 <Item 5>173 </Item5> 174 <Item6> 172 175 <PackageName Value="LCL"/> 173 </Item 5>176 </Item6> 174 177 </RequiredPackages> 175 <Units Count="1 1">178 <Units Count="12"> 176 179 <Unit0> 177 180 <Filename Value="xtactics.lpr"/> … … 242 245 <IsPartOfProject Value="True"/> 243 246 </Unit10> 247 <Unit11> 248 <Filename Value="Forms/UFormCharts.pas"/> 249 <IsPartOfProject Value="True"/> 250 <ComponentName Value="FormCharts"/> 251 <ResourceBaseClass Value="Form"/> 252 </Unit11> 244 253 </Units> 245 254 </ProjectOptions> … … 284 293 </Linking> 285 294 <Other> 295 <CompilerMessages> 296 <IgnoredMessages idx5024="True"/> 297 </CompilerMessages> 286 298 <CustomOptions Value="-dDEBUG"/> 287 299 </Other> -
trunk/xtactics.lpr
r115 r128 8 8 {$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UGame, UCore, Common, CoolTranslator, TemplateGenerics,11 UFormPlayer10 Forms, tachartlazaruspkg, UGame, UCore, Common, CoolTranslator, 11 TemplateGenerics, UFormPlayer 12 12 { you can add units after this }, 13 13 SysUtils, UFormSettings, UFormMain, UFormMove, UFormNew, UFormAbout, 14 UFormHelp, UMap ;14 UFormHelp, UMap, UFormCharts; 15 15 16 16 {$R *.res} … … 37 37 Application.CreateForm(TFormPlayer, FormPlayer); 38 38 Application.CreateForm(TFormSettings, FormSettings); 39 Application.CreateForm(TFormCharts, FormCharts); 39 40 Application.Run; 40 41 end.
Note:
See TracChangeset
for help on using the changeset viewer.