| 1 | unit FormNew;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
|---|
| 7 | Spin, Game, FormEx;
|
|---|
| 8 |
|
|---|
| 9 | type
|
|---|
| 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 |
|
|---|
| 33 | implementation
|
|---|
| 34 |
|
|---|
| 35 | {$R *.lfm}
|
|---|
| 36 |
|
|---|
| 37 | { TFormNew }
|
|---|
| 38 |
|
|---|
| 39 | procedure TFormNew.ComboBoxSizeChange(Sender: TObject);
|
|---|
| 40 | begin
|
|---|
| 41 | UpdateInterface;
|
|---|
| 42 | end;
|
|---|
| 43 |
|
|---|
| 44 | procedure TFormNew.UpdateInterface;
|
|---|
| 45 | var
|
|---|
| 46 | MaxDisabledTiles: Integer;
|
|---|
| 47 | begin
|
|---|
| 48 | MaxDisabledTiles := ComboBoxSize.ItemIndex + 2;
|
|---|
| 49 | MaxDisabledTiles := MaxDisabledTiles * MaxDisabledTiles - 3;
|
|---|
| 50 | SpinEditDisabledTiles.MaxValue := MaxDisabledTiles;
|
|---|
| 51 | SpinEditUnmergeableTiles.MaxValue := MaxDisabledTiles;
|
|---|
| 52 | end;
|
|---|
| 53 |
|
|---|
| 54 | procedure TFormNew.Load(Game: TGame);
|
|---|
| 55 | begin
|
|---|
| 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;
|
|---|
| 62 | end;
|
|---|
| 63 |
|
|---|
| 64 | procedure TFormNew.Save(Game: TGame);
|
|---|
| 65 | begin
|
|---|
| 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;
|
|---|
| 71 | end;
|
|---|
| 72 |
|
|---|
| 73 | end.
|
|---|
| 74 |
|
|---|