1 | unit UFormCharts;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, TAGraph, TASeries, Forms, Controls, Graphics,
|
---|
9 | Dialogs, StdCtrls;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormCharts }
|
---|
14 |
|
---|
15 | TFormCharts = class(TForm)
|
---|
16 | Chart1: TChart;
|
---|
17 | ComboBox1: TComboBox;
|
---|
18 | procedure ComboBox1Change(Sender: TObject);
|
---|
19 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
20 | procedure FormShow(Sender: TObject);
|
---|
21 | private
|
---|
22 | { private declarations }
|
---|
23 | public
|
---|
24 | procedure Redraw;
|
---|
25 | procedure Translate;
|
---|
26 | end;
|
---|
27 |
|
---|
28 | var
|
---|
29 | FormCharts: TFormCharts;
|
---|
30 |
|
---|
31 | implementation
|
---|
32 |
|
---|
33 | {$R *.lfm}
|
---|
34 |
|
---|
35 | uses
|
---|
36 | UCore, UGame;
|
---|
37 |
|
---|
38 | resourcestring
|
---|
39 | SOccupiedCells = 'Occupied cells';
|
---|
40 | SMilitaryPower = 'Military power';
|
---|
41 | SDiscoveredCells = 'Discovered cells';
|
---|
42 | SCitiesCount = 'Cities count';
|
---|
43 |
|
---|
44 |
|
---|
45 | { TFormCharts }
|
---|
46 |
|
---|
47 | procedure TFormCharts.ComboBox1Change(Sender: TObject);
|
---|
48 | begin
|
---|
49 | Redraw;
|
---|
50 | end;
|
---|
51 |
|
---|
52 | procedure TFormCharts.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
53 | begin
|
---|
54 | Core.PersistentForm.Save(Self);
|
---|
55 | end;
|
---|
56 |
|
---|
57 | procedure TFormCharts.FormShow(Sender: TObject);
|
---|
58 | begin
|
---|
59 | Core.PersistentForm.Load(Self);
|
---|
60 | if (ComboBox1.ItemIndex = -1) and (ComboBox1.Items.Count > 0) then
|
---|
61 | ComboBox1.ItemIndex := 0;
|
---|
62 | Redraw;
|
---|
63 | Translate;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TFormCharts.Redraw;
|
---|
67 | var
|
---|
68 | I: Integer;
|
---|
69 | X: Integer;
|
---|
70 | NewSeries: TLineSeries;
|
---|
71 | begin
|
---|
72 | Chart1.Series.Clear;
|
---|
73 | for I := 0 to Core.Game.Players.Count - 1 do
|
---|
74 | with TPlayer(Core.Game.Players[I]) do begin
|
---|
75 | NewSeries := TLineSeries.Create(nil);
|
---|
76 | NewSeries.LinePen.Color := Color;
|
---|
77 | for X := 0 to TurnStats.Count - 1 do begin
|
---|
78 | if ComboBox1.ItemIndex = 0 then NewSeries.AddXY(X, TGameTurnStat(TurnStats[X]).OccupiedCells)
|
---|
79 | else if ComboBox1.ItemIndex = 1 then NewSeries.AddXY(X, TGameTurnStat(TurnStats[X]).Units)
|
---|
80 | else if ComboBox1.ItemIndex = 2 then NewSeries.AddXY(X, TGameTurnStat(TurnStats[X]).DiscoveredCells)
|
---|
81 | else if ComboBox1.ItemIndex = 3 then NewSeries.AddXY(X, TGameTurnStat(TurnStats[X]).Cities);
|
---|
82 | end;
|
---|
83 | Chart1.AddSeries(NewSeries);
|
---|
84 | end;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | procedure TFormCharts.Translate;
|
---|
88 | var
|
---|
89 | LastIndex: Integer;
|
---|
90 | begin
|
---|
91 | Core.CoolTranslator1.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 | ItemIndex := LastIndex;
|
---|
100 | end;
|
---|
101 | end;
|
---|
102 |
|
---|
103 | end.
|
---|
104 |
|
---|