source: trunk/Forms/FormCharts.pas

Last change on this file was 400, checked in by chronos, 4 days ago
  • Fixed: Scale charts line width.
  • Fixed: Item form made bigger to avoid showing scrollbars.
  • Fixed: Item form string control made shorter.
File size: 2.4 KB
Line 
1unit FormCharts;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, TAGraph, TASeries, Forms, Controls, Graphics,
7 Dialogs, StdCtrls, FormEx, Game;
8
9type
10
11 { TFormCharts }
12
13 TFormCharts = class(TFormEx)
14 ButtonClose: TButton;
15 Chart1: TChart;
16 ComboBox1: TComboBox;
17 procedure ButtonCloseClick(Sender: TObject);
18 procedure ComboBox1Change(Sender: TObject);
19 procedure FormShow(Sender: TObject);
20 private
21 FGame: TGame;
22 public
23 procedure Redraw;
24 procedure Translate;
25 property Game: TGame read FGame write FGame;
26 end;
27
28
29implementation
30
31{$R *.lfm}
32
33uses
34 Player;
35
36resourcestring
37 SOccupiedCells = 'Occupied cells';
38 SMilitaryPower = 'Military power';
39 SDiscoveredCells = 'Discovered cells';
40 SCitiesCount = 'Cities count';
41 SWinObjectiveCells = 'Win objective cells';
42
43{ TFormCharts }
44
45procedure TFormCharts.ComboBox1Change(Sender: TObject);
46begin
47 Redraw;
48end;
49
50procedure TFormCharts.ButtonCloseClick(Sender: TObject);
51begin
52 Close;
53end;
54
55procedure TFormCharts.FormShow(Sender: TObject);
56begin
57 Translate;
58 if (ComboBox1.ItemIndex = -1) and (ComboBox1.Items.Count > 0) then
59 ComboBox1.ItemIndex := 0;
60 Chart1.BackColor := ThemeManager.ActualTheme.ColorWindow;
61 Redraw;
62end;
63
64procedure TFormCharts.Redraw;
65var
66 I: Integer;
67 X: Integer;
68 NewSeries: TLineSeries;
69begin
70 Chart1.Series.Clear;
71 for I := 0 to Game.Players.Count - 1 do
72 with Game.Players[I] do begin
73 NewSeries := TLineSeries.Create(nil);
74 NewSeries.LinePen.Color := Color;
75 NewSeries.LinePen.Width := Scale96ToScreen(1);
76 for X := 0 to TurnStats.Count - 1 do begin
77 if ComboBox1.ItemIndex = 0 then NewSeries.AddXY(X, TurnStats[X].OccupiedCells)
78 else if ComboBox1.ItemIndex = 1 then NewSeries.AddXY(X, TurnStats[X].Units)
79 else if ComboBox1.ItemIndex = 2 then NewSeries.AddXY(X, TurnStats[X].DiscoveredCells)
80 else if ComboBox1.ItemIndex = 3 then NewSeries.AddXY(X, TurnStats[X].Cities)
81 else if ComboBox1.ItemIndex = 4 then NewSeries.AddXY(X, TurnStats[X].WinObjectiveCells);
82 end;
83 Chart1.AddSeries(NewSeries);
84 end;
85end;
86
87procedure TFormCharts.Translate;
88var
89 LastIndex: Integer;
90begin
91 TFormEx.Translator.TranslateComponentRecursive(Self);
92 with ComboBox1 do begin
93 LastIndex := ItemIndex;
94 Clear;
95 Items.Add(SOccupiedCells);
96 Items.Add(SMilitaryPower);
97 Items.Add(SDiscoveredCells);
98 Items.Add(SCitiesCount);
99 Items.Add(SWinObjectiveCells);
100 ItemIndex := LastIndex;
101 end;
102end;
103
104end.
105
Note: See TracBrowser for help on using the repository browser.