| 1 | unit FormCharts;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, FileUtil, TAGraph, TASeries, Forms, Controls, Graphics,
|
|---|
| 7 | Dialogs, StdCtrls, FormEx, Game;
|
|---|
| 8 |
|
|---|
| 9 | type
|
|---|
| 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 |
|
|---|
| 29 | implementation
|
|---|
| 30 |
|
|---|
| 31 | {$R *.lfm}
|
|---|
| 32 |
|
|---|
| 33 | uses
|
|---|
| 34 | Player;
|
|---|
| 35 |
|
|---|
| 36 | resourcestring
|
|---|
| 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 |
|
|---|
| 45 | procedure TFormCharts.ComboBox1Change(Sender: TObject);
|
|---|
| 46 | begin
|
|---|
| 47 | Redraw;
|
|---|
| 48 | end;
|
|---|
| 49 |
|
|---|
| 50 | procedure TFormCharts.ButtonCloseClick(Sender: TObject);
|
|---|
| 51 | begin
|
|---|
| 52 | Close;
|
|---|
| 53 | end;
|
|---|
| 54 |
|
|---|
| 55 | procedure TFormCharts.FormShow(Sender: TObject);
|
|---|
| 56 | begin
|
|---|
| 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;
|
|---|
| 62 | end;
|
|---|
| 63 |
|
|---|
| 64 | procedure TFormCharts.Redraw;
|
|---|
| 65 | var
|
|---|
| 66 | I: Integer;
|
|---|
| 67 | X: Integer;
|
|---|
| 68 | NewSeries: TLineSeries;
|
|---|
| 69 | begin
|
|---|
| 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;
|
|---|
| 85 | end;
|
|---|
| 86 |
|
|---|
| 87 | procedure TFormCharts.Translate;
|
|---|
| 88 | var
|
|---|
| 89 | LastIndex: Integer;
|
|---|
| 90 | begin
|
|---|
| 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;
|
|---|
| 102 | end;
|
|---|
| 103 |
|
|---|
| 104 | end.
|
|---|
| 105 |
|
|---|