generated from DeveloppeurPascal/Delphi-Projects-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuSceneMenu.pas
175 lines (156 loc) · 5.11 KB
/
uSceneMenu.pas
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/// <summary>
/// ***************************************************************************
///
/// Make games in Delphi (2024 edition) - Dev Days of Summer 2024
///
/// Copyright 2024 Patrick Prémartin under AGPL 3.0 license.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
/// DEALINGS IN THE SOFTWARE.
///
/// ***************************************************************************
///
/// Samples projects for the "Make games in Delphi (2024 Edition)" talk at
/// <Dev Days of Summer> 2024 online conference.
///
/// The projects are based on the "Gamolf FMX Game Template" you can find at
/// https://gametemplate.developpeur-pascal.fr/
///
/// ***************************************************************************
///
/// Author(s) :
/// Patrick PREMARTIN
///
/// Site :
/// https://serialstreameur.fr/make-games-in-delphi-2024-edition.html
///
/// Project site :
/// https://github.com/DeveloppeurPascal/DevDaysOfSummer2024-MakeGamesInDelphi
///
/// ***************************************************************************
/// File last update : 2024-08-10T13:23:32.000+02:00
/// Signature : 211ce5732a94ae98ba9781843d3ebf94034b02b1
/// ***************************************************************************
/// </summary>
unit uSceneMenu;
interface
uses
System.SysUtils,
System.Types,
System.UITypes,
System.Classes,
System.Variants,
FMX.Types,
FMX.Graphics,
FMX.Controls,
FMX.Forms,
FMX.Dialogs,
FMX.StdCtrls,
_ScenesAncestor,
FMX.Controls.Presentation,
FMX.Layouts,
cButtonQuit,
cButtonCredits,
cButton,
cButtonPlay;
type
TSceneHome = class(T__SceneAncestor)
Layout1: TLayout;
cadButtonPlay1: TcadButtonPlay;
cadButtonCredits1: TcadButtonCredits;
cadButtonQuit1: TcadButtonQuit;
private
protected
procedure btnNewGameClick(Sender: TObject);
procedure btnCreditsClick(Sender: TObject);
procedure btnQuitClick(Sender: TObject);
public
procedure ShowScene; override;
procedure BeforeFirstShowScene; override;
end;
implementation
{$R *.fmx}
uses
System.Messaging,
uScene,
uGameData,
uConsts,
uSoundEffects,
uUIElements,
USVGInputPrompts,
uDMHelpBarManager;
{ TSceneHome }
procedure TSceneHome.BeforeFirstShowScene;
begin
inherited;
THelpBarManager.Current.TextSettings.FontColor := talphacolors.Ghostwhite;
THelpBarManager.Current.TextSettings.Font.Size :=
THelpBarManager.Current.TextSettings.Font.Size * 2;
THelpBarManager.Current.BackgroundFill.Color := talphacolors.Black;
THelpBarManager.Current.Height := 100;
end;
procedure TSceneHome.btnCreditsClick(Sender: TObject);
begin
TScene.Current := TSceneType.Credits;
end;
procedure TSceneHome.btnNewGameClick(Sender: TObject);
begin
TGameData.DefaultGameData.StartANewGame;
TScene.Current := TSceneType.game;
end;
procedure TSceneHome.btnQuitClick(Sender: TObject);
begin
TScene.Current := TSceneType.Exit;
end;
procedure TSceneHome.ShowScene;
begin
inherited;
{$IF Defined(IOS) or Defined(ANDROID)}
cadButtonQuit1.Visible := false;
{$ENDIF}
cadButtonPlay1.OnClick := btnNewGameClick;
cadButtonCredits1.OnClick := btnCreditsClick;
cadButtonQuit1.OnClick := btnQuitClick;
TUIItemsList.Current.AddControl(cadButtonPlay1, nil, cadButtonCredits1,
cadButtonCredits1, nil, true);
if cadButtonQuit1.Visible then
begin
TUIItemsList.Current.AddControl(cadButtonCredits1, cadButtonPlay1,
cadButtonQuit1, cadButtonQuit1, cadButtonPlay1);
TUIItemsList.Current.AddControl(cadButtonQuit1, cadButtonCredits1, nil, nil,
cadButtonCredits1, false, true);
end
else
TUIItemsList.Current.AddControl(cadButtonCredits1, cadButtonPlay1, nil, nil,
cadButtonPlay1);
THelpBarManager.Current.OpenHelpBar;
THelpBarManager.Current.AddItem(ord(TSVGInputPromptsIndex.KeyboardArrowUp),
ord(TSVGInputPromptsIndex.SteamDpadUpOutline));
THelpBarManager.Current.AddItem(ord(TSVGInputPromptsIndex.KeyboardArrowDown),
ord(TSVGInputPromptsIndex.SteamDpadDownOutline), 'Move');
THelpBarManager.Current.AddItem(ord(TSVGInputPromptsIndex.KeyboardSpace),
ord(TSVGInputPromptsIndex.SteamButtonColorAOutline), 'Select');
if cadButtonQuit1.Visible then
THelpBarManager.Current.AddItem(ord(TSVGInputPromptsIndex.KeyboardEscape),
ord(TSVGInputPromptsIndex.SteamButtonColorXOutline), 'Quit');
end;
initialization
TMessageManager.DefaultManager.SubscribeToMessage(TSceneFactory,
procedure(const Sender: TObject; const Msg: TMessage)
var
NewScene: TSceneHome;
begin
if (Msg is TSceneFactory) and
((Msg as TSceneFactory).SceneType = TSceneType.Menu) then
begin
NewScene := TSceneHome.Create(application.mainform);
NewScene.Parent := application.mainform;
TScene.RegisterScene(TSceneType.Menu, NewScene);
end;
end);
end.