source: trunk/Forms/FormNew.pas

Last change on this file was 120, checked in by chronos, 7 months ago
  • Modified: Packaging files update.
File size: 1.8 KB
Line 
1unit FormNew;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
7 Spin, Game, FormEx;
8
9type
10
11 { TFormNew }
12
13 TFormNew = class(TFormEx)
14 ButtonCancel: TButton;
15 ButtonOk: TButton;
16 CheckBoxRecordHistory: TCheckBox;
17 CheckBoxUndoEnabled: TCheckBox;
18 ComboBoxSize: TComboBox;
19 Label1: TLabel;
20 Label2: TLabel;
21 Label3: TLabel;
22 ScrollBox1: TScrollBox;
23 SpinEditDisabledTiles: TSpinEdit;
24 SpinEditUnmergeableTiles: TSpinEdit;
25 procedure ComboBoxSizeChange(Sender: TObject);
26 public
27 procedure UpdateInterface;
28 procedure Load(Game: TGame);
29 procedure Save(Game: TGame);
30 end;
31
32
33implementation
34
35{$R *.lfm}
36
37{ TFormNew }
38
39procedure TFormNew.ComboBoxSizeChange(Sender: TObject);
40begin
41 UpdateInterface;
42end;
43
44procedure TFormNew.UpdateInterface;
45var
46 MaxDisabledTiles: Integer;
47begin
48 MaxDisabledTiles := ComboBoxSize.ItemIndex + 2;
49 MaxDisabledTiles := MaxDisabledTiles * MaxDisabledTiles - 3;
50 SpinEditDisabledTiles.MaxValue := MaxDisabledTiles;
51 SpinEditUnmergeableTiles.MaxValue := MaxDisabledTiles;
52end;
53
54procedure TFormNew.Load(Game: TGame);
55begin
56 ComboBoxSize.ItemIndex := Game.Board.Size.X - 2;
57 CheckBoxUndoEnabled.Checked := Game.UndoEnabled;
58 CheckBoxRecordHistory.Checked := Game.RecordHistory;
59 SpinEditDisabledTiles.Value := Game.DisabledTilesCount;
60 SpinEditUnmergeableTiles.Value := Game.UnmergeableTilesCount;
61 UpdateInterface;
62end;
63
64procedure TFormNew.Save(Game: TGame);
65begin
66 Game.Board.Size := Point(2 + ComboBoxSize.ItemIndex, 2 + ComboBoxSize.ItemIndex);
67 Game.UndoEnabled := CheckBoxUndoEnabled.Checked;
68 Game.RecordHistory := CheckBoxRecordHistory.Checked;
69 Game.DisabledTilesCount := SpinEditDisabledTiles.Value;
70 Game.UnmergeableTilesCount := SpinEditUnmergeableTiles.Value;
71end;
72
73end.
74
Note: See TracBrowser for help on using the repository browser.