source: tags/1.2.0/Forms/UFormNew.pas

Last change on this file was 50, checked in by chronos, 5 years ago
  • Added: Support for dark theme.
File size: 1.8 KB
Line 
1unit UFormNew;
2
3{$mode delphi}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 UGame;
10
11type
12
13 { TFormNew }
14
15 TFormNew = class(TForm)
16 ButtonCancel: TButton;
17 ButtonOk: TButton;
18 CheckBoxRecordHistory: TCheckBox;
19 CheckBoxUndoEnabled: TCheckBox;
20 ComboBoxSize: TComboBox;
21 ComboBoxSkin: TComboBox;
22 Label1: TLabel;
23 Label2: TLabel;
24 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
25 procedure FormCreate(Sender: TObject);
26 procedure FormShow(Sender: TObject);
27 private
28
29 public
30 procedure Load(Game: TGame);
31 procedure Save(Game: TGame);
32 end;
33
34var
35 FormNew: TFormNew;
36
37implementation
38
39{$R *.lfm}
40
41uses
42 UCore;
43
44{ TFormNew }
45
46procedure TFormNew.FormCreate(Sender: TObject);
47var
48 I: TTileSkin;
49begin
50 Core.Translator1.TranslateComponentRecursive(Self);
51 Core.ThemeManager1.UseTheme(Self);
52 ComboBoxSkin.Items.Clear;
53 for I := Low(SkinText) to High(SkinText) do
54 ComboBoxSkin.Items.Add(SkinText[I]);
55end;
56
57procedure TFormNew.FormShow(Sender: TObject);
58begin
59 Core.PersistentForm1.Load(Self);
60end;
61
62procedure TFormNew.FormClose(Sender: TObject; var CloseAction: TCloseAction);
63begin
64 Core.PersistentForm1.Save(Self);
65end;
66
67procedure TFormNew.Load(Game: TGame);
68begin
69 ComboBoxSize.ItemIndex := Game.Board.Size.X - 2;
70 CheckBoxUndoEnabled.Checked := Game.UndoEnabled;
71 CheckBoxRecordHistory.Checked := Game.RecordHistory;
72 ComboBoxSkin.ItemIndex := Integer(Game.Skin);
73end;
74
75procedure TFormNew.Save(Game: TGame);
76begin
77 Game.Board.Size := Point(2 + ComboBoxSize.ItemIndex, 2 + ComboBoxSize.ItemIndex);
78 Game.UndoEnabled := CheckBoxUndoEnabled.Checked;
79 Game.RecordHistory := CheckBoxRecordHistory.Checked;
80 Game.Skin := TTileSkin(ComboBoxSkin.ItemIndex);
81end;
82
83end.
84
Note: See TracBrowser for help on using the repository browser.