-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuInstructions.pas
More file actions
126 lines (112 loc) · 3.24 KB
/
uInstructions.pas
File metadata and controls
126 lines (112 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
unit uInstructions;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.Objects, uSelector, uButton, FMX.Effects,
FMX.Layouts;
type
TInstructions = class(TFrame)
Rectangle1: TRectangle;
FieldName: TImage;
Field1: TImage;
Field2: TImage;
Field3: TImage;
Field4: TImage;
Field5: TImage;
FIeld6: TImage;
Field7: TImage;
Image: TRectangle;
FieldSize: TSelector;
FieldDifficulty: TSelector;
Layout1: TLayout;
ShadowEffect1: TShadowEffect;
BtIniciar: TImage;
BtCancelar: TImage;
Image3: TImage;
Image4: TImage;
procedure BtCancelarClick(Sender: TObject);
procedure BtIniciarClick(Sender: TObject);
private
public
Constructor Create(aOwner : TComponent); Override;
Procedure SetField(aValue : Integer);
Procedure ShowIn(aControl : TControl);
Procedure CloseFrame;
end;
Var
FrameInstructions : TInstructions;
implementation
Uses
FMX.Ani,
uImages,
uMedia,
uGameInterfaces;
{$R *.fmx}
{ TInstructions }
constructor TInstructions.Create(aOwner: TComponent);
begin
inherited;
FieldDifficulty.SetOptions([Images.VeryEasy, Images.Easy, Images.Medium, Images.Hard, Images.VeryHard]);
FieldSize .SetOptions([Images.VerySmall, Images.Small, Images.Medium, Images.Large, Images.VeryLarge]);
end;
procedure TInstructions.ShowIn(aControl: TControl);
begin
{$IF Defined(Android) Or Defined(iOS)}
Image.Align := TAlignLayout.Client;
{$ELSE}
Image.Align := TAlignLayout.Center;
{$ENDIF}
Parent := aControl;
Width := aControl.Width;
Height := aControl.Width;
Position.X := 0;
Position.Y := aControl.Height+1;
TAnimator.AnimateFloat(Self, 'Position.Y', aControl.Height - Height, 0.5, TAnimationType.Out, TInterpolationType.Back);
end;
procedure TInstructions.CloseFrame;
begin
TAnimator.AnimateFloat(Self, 'Position.Y', (Parent As TControl).Height + Height+1 , 0.5, TAnimationType.In, TInterpolationType.Back);
TThread.CreateAnonymousThread(
Procedure
Begin
Sleep(510);
TThread.Queue(Nil, Procedure Begin Parent := Nil; End);
End);
end;
procedure TInstructions.BtCancelarClick(Sender: TObject);
begin
media.Click3;
(Owner As IMinesweeper).ShowStartScreen;
Closeframe;
end;
procedure TInstructions.BtIniciarClick(Sender: TObject);
begin
media.Click3;
CloseFrame;
TThread.CreateAnonymousThread(
procedure
Begin
Sleep(600);
TThread.Synchronize(Nil,
Procedure
Begin
(Owner As IMinesweeper)
.SetDifficulty(TFieldDifficulty(FieldDifficulty.ItemIndex))
.SetFieldSize(TFieldSize(FieldSize.ItemIndex))
.StartGame;
End);
End).Start;
end;
procedure TInstructions.SetField(aValue: Integer);
begin
Case aValue Of
1 : FieldName.Bitmap.Assign(Field1.Bitmap);
2 : FieldName.Bitmap.Assign(Field2.Bitmap);
3 : FieldName.Bitmap.Assign(Field3.Bitmap);
4 : FieldName.Bitmap.Assign(Field4.Bitmap);
5 : FieldName.Bitmap.Assign(Field5.Bitmap);
6 : FieldName.Bitmap.Assign(Field6.Bitmap);
7 : FieldName.Bitmap.Assign(Field7.Bitmap);
End;
end;
end.